From 2e620f0b3834e5a612a38d61b7e50a561d7f11e8 Mon Sep 17 00:00:00 2001
From: Daniel Pfeifer <daniel@pfeifer-mail.de>
Date: Sat, 5 Nov 2016 21:40:14 +0100
Subject: Fix several include-what-you-use findings

---
 Source/CTest/cmCTestScriptHandler.cxx          |  1 +
 Source/QtDialog/CMakeSetup.cxx                 |  2 ++
 Source/cmAlgorithms.h                          | 14 ++++++--
 Source/cmCMakeMinimumRequired.cxx              |  6 ++++
 Source/cmCMakeMinimumRequired.h                |  6 ++++
 Source/cmCTest.cxx                             | 45 +++++++++++++-------------
 Source/cmCacheManager.cxx                      | 11 ++++---
 Source/cmCacheManager.h                        |  6 ++--
 Source/cmCommandArgumentsHelper.h              |  6 ++--
 Source/cmCommonTargetGenerator.cxx             |  3 +-
 Source/cmCommonTargetGenerator.h               |  5 +--
 Source/cmConditionEvaluator.cxx                | 12 ++++++-
 Source/cmConditionEvaluator.h                  | 10 ++++--
 Source/cmCoreTryCompile.cxx                    | 14 ++++++--
 Source/cmCoreTryCompile.h                      |  5 +++
 Source/cmCreateTestSourceList.cxx              |  4 +++
 Source/cmCreateTestSourceList.h                |  7 ++++
 Source/cmDefinitions.cxx                       |  1 +
 Source/cmDefinitions.h                         |  8 ++---
 Source/cmDependsC.cxx                          |  7 ++--
 Source/cmDependsFortran.cxx                    | 17 +++++-----
 Source/cmDependsJavaParserHelper.h             |  2 ++
 Source/cmExecutionStatus.h                     |  4 ---
 Source/cmExpandedCommandArgument.h             |  4 +--
 Source/cmExportBuildAndroidMKGenerator.cxx     | 18 ++++++++---
 Source/cmExportBuildAndroidMKGenerator.h       | 10 ++++--
 Source/cmExportInstallAndroidMKGenerator.cxx   | 11 ++++---
 Source/cmExportInstallAndroidMKGenerator.h     | 10 +++++-
 Source/cmExtraCodeBlocksGenerator.cxx          | 11 +++----
 Source/cmExtraEclipseCDT4Generator.cxx         | 17 +++++-----
 Source/cmExtraSublimeTextGenerator.cxx         | 14 ++++----
 Source/cmFileCommand.cxx                       |  1 +
 Source/cmFileTimeComparison.cxx                |  1 -
 Source/cmFindBase.cxx                          |  6 ++++
 Source/cmFindBase.h                            |  5 +++
 Source/cmFindCommon.cxx                        |  7 ++--
 Source/cmFindCommon.h                          |  9 ++++++
 Source/cmFunctionBlocker.h                     |  7 ++--
 Source/cmFunctionCommand.cxx                   |  1 -
 Source/cmGeneratedFileStream.cxx               |  5 +--
 Source/cmGeneratorExpression.cxx               |  7 ++--
 Source/cmGeneratorExpressionEvaluationFile.cxx | 11 ++++---
 Source/cmGeneratorExpressionEvaluationFile.h   | 13 +++++---
 Source/cmGeneratorTarget.cxx                   | 22 +++++++------
 Source/cmGetCMakePropertyCommand.cxx           |  1 -
 Source/cmGlobalBorlandMakefileGenerator.cxx    |  1 +
 Source/cmGlobalGenerator.cxx                   | 21 ++++++------
 Source/cmGlobalGenerator.h                     | 22 ++++++-------
 Source/cmGlobalGeneratorFactory.h              |  7 ++--
 Source/cmGlobalJOMMakefileGenerator.cxx        |  1 +
 Source/cmGlobalMSYSMakefileGenerator.cxx       |  4 ++-
 Source/cmGlobalMinGWMakefileGenerator.cxx      |  1 +
 Source/cmGlobalNMakeMakefileGenerator.cxx      |  1 +
 Source/cmGlobalNinjaGenerator.cxx              | 24 ++++++++------
 Source/cmGlobalNinjaGenerator.h                | 22 +++++++------
 Source/cmGlobalUnixMakefileGenerator3.cxx      | 11 ++++---
 Source/cmGlobalUnixMakefileGenerator3.h        | 10 +++---
 Source/cmGlobalWatcomWMakeGenerator.cxx        |  1 -
 Source/cmGraphAdjacencyList.h                  |  4 +--
 Source/cmGraphVizWriter.cxx                    | 11 ++++---
 Source/cmHexFileConverter.cxx                  |  5 +--
 Source/cmHexFileConverter.h                    |  4 ---
 Source/cmInstallCommand.cxx                    |  1 -
 Source/cmInstallCommandArguments.cxx           |  2 ++
 Source/cmInstallCommandArguments.h             |  5 +--
 Source/cmInstallTargetGenerator.cxx            | 13 ++++----
 Source/cmLinkItem.h                            |  8 +++++
 Source/cmLinkLineComputer.cxx                  |  5 +++
 Source/cmLinkLineComputer.h                    |  4 +++
 Source/cmLinkedTree.h                          |  4 +--
 Source/cmLocalCommonGenerator.cxx              |  5 +--
 Source/cmLocalCommonGenerator.h                |  5 ++-
 Source/cmLocalGenerator.cxx                    |  3 +-
 Source/cmLocalGenerator.h                      | 19 ++++++-----
 Source/cmLocalNinjaGenerator.cxx               | 15 +++++----
 Source/cmLocalNinjaGenerator.h                 | 10 +++---
 Source/cmLocalUnixMakefileGenerator3.cxx       | 19 +++++------
 Source/cmLocale.h                              |  2 --
 Source/cmMSVC60LinkLineComputer.cxx            |  6 ++++
 Source/cmMSVC60LinkLineComputer.h              |  7 ++++
 Source/cmMacroCommand.cxx                      |  1 -
 Source/cmMakefile.cxx                          | 28 ++++++++--------
 Source/cmMakefile.h                            | 20 ++++++------
 Source/cmMakefileExecutableTargetGenerator.cxx | 11 ++++---
 Source/cmMakefileLibraryTargetGenerator.cxx    | 11 +++++--
 Source/cmMakefileTargetGenerator.cxx           | 14 ++++----
 Source/cmMakefileTargetGenerator.h             | 12 ++++---
 Source/cmMakefileUtilityTargetGenerator.cxx    | 10 +++---
 Source/cmMessageCommand.cxx                    |  2 --
 Source/cmNinjaLinkLineComputer.cxx             |  4 +++
 Source/cmNinjaLinkLineComputer.h               |  7 +++-
 Source/cmNinjaNormalTargetGenerator.cxx        | 21 ++++++------
 Source/cmNinjaTargetGenerator.cxx              | 19 ++++++-----
 Source/cmNinjaTypes.h                          |  6 ++--
 Source/cmOptionCommand.cxx                     |  2 --
 Source/cmOutputConverter.cxx                   | 11 ++++---
 Source/cmOutputConverter.h                     |  6 ++--
 Source/cmParseArgumentsCommand.cxx             |  1 -
 Source/cmPathLabel.cxx                         |  2 ++
 Source/cmPathLabel.h                           |  4 +--
 Source/cmQtAutoGeneratorInitializer.cxx        |  2 --
 Source/cmQtAutoGenerators.cxx                  | 23 +++++++------
 Source/cmRulePlaceholderExpander.cxx           |  4 +++
 Source/cmRulePlaceholderExpander.h             |  1 -
 Source/cmSearchPath.cxx                        |  2 ++
 Source/cmSearchPath.h                          |  4 ++-
 Source/cmServer.cxx                            |  1 +
 Source/cmServerConnection.cxx                  |  1 +
 Source/cmSetCommand.cxx                        |  1 -
 Source/cmSourceFile.cxx                        |  5 ++-
 Source/cmState.cxx                             | 16 ++++-----
 Source/cmState.h                               | 15 ++++-----
 Source/cmStateDirectory.cxx                    | 10 ++++++
 Source/cmStateDirectory.h                      |  3 +-
 Source/cmStatePrivate.h                        |  7 ++++
 Source/cmStateSnapshot.cxx                     | 14 +++++++-
 Source/cmStateSnapshot.h                       |  2 +-
 Source/cmStateTypes.h                          |  4 +--
 Source/cmStringCommand.cxx                     |  1 -
 Source/cmSystemTools.h                         |  6 ++++
 Source/cmTarget.cxx                            | 18 ++++++-----
 Source/cmTarget.h                              | 17 +++++-----
 Source/cmTargetCompileFeaturesCommand.cxx      |  1 -
 Source/cmTargetCompileOptionsCommand.cxx       |  1 -
 Source/cmTargetDepend.h                        |  4 +--
 Source/cmTargetExport.h                        |  6 ++--
 Source/cmTargetPropCommandBase.cxx             |  3 ++
 Source/cmTargetPropCommandBase.h               |  5 +++
 Source/cmTargetPropertyComputer.cxx            | 11 +++----
 Source/cmTargetPropertyComputer.h              |  7 ++--
 Source/cmTargetSourcesCommand.cxx              |  1 -
 Source/cmTest.cxx                              |  1 -
 Source/cmTestGenerator.cxx                     |  9 +++---
 Source/cmTimestamp.cxx                         |  8 ++---
 Source/cmTimestamp.h                           |  4 +--
 Source/cm_codecvt.hxx                          |  3 +-
 Source/cmake.cxx                               |  5 +--
 Source/cmake.h                                 | 12 ++++---
 Source/cmakemain.cxx                           |  1 +
 Source/cmcmd.cxx                               |  1 +
 140 files changed, 660 insertions(+), 442 deletions(-)

diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 7ee0f75..08ea4ee 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -22,6 +22,7 @@
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmake.h"
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 9038469..5e03c39 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -5,6 +5,7 @@
 #include "CMakeSetupDialog.h"
 #include "cmAlgorithms.h"
 #include "cmDocumentation.h"
+#include "cmDocumentationEntry.h"
 #include "cmVersion.h"
 #include "cmake.h"
 #include <QApplication>
@@ -17,6 +18,7 @@
 #include <cmsys/CommandLineArguments.hxx>
 #include <cmsys/Encoding.hxx>
 #include <cmsys/SystemTools.hxx>
+#include <iostream>
 
 #include "cmSystemTools.h" // IWYU pragma: keep
 
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index aa55379..22f69fa 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -3,9 +3,17 @@
 #ifndef cmAlgorithms_h
 #define cmAlgorithms_h
 
-#include <cmConfigure.h>
-
-#include "cmStandardIncludes.h"
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <algorithm>
+#include <cm_kwiml.h>
+#include <functional>
+#include <iterator>
+#include <sstream>
+#include <string.h>
+#include <string>
+#include <utility>
+#include <vector>
 
 inline bool cmHasLiteralPrefixImpl(const std::string& str1, const char* str2,
                                    size_t N)
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index 655c42a..942688c 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -2,9 +2,15 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCMakeMinimumRequired.h"
 
+#include <sstream>
+#include <stdio.h>
+
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
 #include "cmVersion.h"
+#include "cmake.h"
+
+class cmExecutionStatus;
 
 // cmCMakeMinimumRequired
 bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args,
diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h
index 3acedd2..08a5c38 100644
--- a/Source/cmCMakeMinimumRequired.h
+++ b/Source/cmCMakeMinimumRequired.h
@@ -3,8 +3,14 @@
 #ifndef cmCMakeMinimumRequired_h
 #define cmCMakeMinimumRequired_h
 
+#include <cmConfigure.h>
+#include <string>
+#include <vector>
+
 #include "cmCommand.h"
 
+class cmExecutionStatus;
+
 /** \class cmCMakeMinimumRequired
  * \brief cmake_minimum_required command
  *
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 024260c..010fc4e 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2,6 +2,27 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCTest.h"
 
+#include <cm_curl.h>
+#include <cm_zlib.h>
+#include <cmsys/Base64.h>
+#include <cmsys/Directory.hxx>
+#include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
+#include <cmsys/Process.h>
+#include <cmsys/String.hxx>
+#include <cmsys/SystemInformation.hxx>
+#include <ctype.h>
+#include <iostream>
+#include <map>
+#include <sstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+#include <time.h>
+#include <utility>
+#include <vector>
+
 #include "cmAlgorithms.h"
 #include "cmCTestBuildAndTestHandler.h"
 #include "cmCTestBuildHandler.h"
@@ -21,35 +42,15 @@
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmState.h"
+#include "cmStateSnapshot.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmVersion.h"
 #include "cmVersionConfig.h"
 #include "cmXMLWriter.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <cm_auto_ptr.hxx>
-#include <cm_curl.h>
-#include <cm_zlib.h>
-#include <cmsys/Base64.h>
-#include <cmsys/Directory.hxx>
-#include <cmsys/FStream.hxx>
-#include <cmsys/Glob.hxx>
-#include <cmsys/Process.h>
-#include <cmsys/String.hxx>
-#include <cmsys/SystemInformation.hxx>
-#include <ctype.h>
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <string>
-#include <time.h>
-#include <utility>
-#include <vector>
-
 #if defined(__BEOS__) || defined(__HAIKU__)
 #include <be/kernel/OS.h> /* disable_debugger() API. */
 #endif
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index e84012c..cb0ba63 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -2,11 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCacheManager.h"
 
-#include "cmGeneratedFileStream.h"
-#include "cmSystemTools.h"
-#include "cmVersion.h"
-#include "cmake.h"
-
 #include <algorithm>
 #include <cmsys/FStream.hxx>
 #include <cmsys/Glob.hxx>
@@ -14,6 +9,12 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "cmGeneratedFileStream.h"
+#include "cmState.h"
+#include "cmSystemTools.h"
+#include "cmVersion.h"
+#include "cmake.h"
+
 cmCacheManager::cmCacheManager()
 {
   this->CacheMajorVersion = 0;
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index 90731f5..e82c9ef 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -5,9 +5,6 @@
 
 #include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmPropertyMap.h"
-#include "cmState.h"
-
 #include <iosfwd>
 #include <map>
 #include <set>
@@ -15,6 +12,9 @@
 #include <utility>
 #include <vector>
 
+#include "cmPropertyMap.h"
+#include "cmStateTypes.h"
+
 class cmake;
 
 /** \class cmCacheManager
diff --git a/Source/cmCommandArgumentsHelper.h b/Source/cmCommandArgumentsHelper.h
index 50af2e2..b19b0f9 100644
--- a/Source/cmCommandArgumentsHelper.h
+++ b/Source/cmCommandArgumentsHelper.h
@@ -5,10 +5,12 @@
 
 #include <cmConfigure.h>
 
-#include "cmStandardIncludes.h"
+#include <set>
+#include <string>
+#include <vector>
 
-class cmCommandArgumentsHelper;
 class cmCommandArgumentGroup;
+class cmCommandArgumentsHelper;
 
 /* cmCommandArgumentsHelper, cmCommandArgumentGroup and cmCommandArgument (i.e.
 its derived classes cmCAXXX can be used to simplify the processing of
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 95b95c1..c3a925f 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCommonTargetGenerator.h"
 
-#include <algorithm>
 #include <cmConfigure.h>
 #include <set>
 #include <sstream>
@@ -16,8 +15,8 @@
 #include "cmLocalCommonGenerator.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
+#include "cmOutputConverter.h"
 #include "cmSourceFile.h"
-#include "cmStateDirectory.h"
 #include "cmStateTypes.h"
 
 cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index fe27038..bdd6645 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -4,19 +4,16 @@
 #define cmCommonTargetGenerator_h
 
 #include <cmConfigure.h> // IWYU pragma: keep
-
-#include "cmOutputConverter.h"
-
 #include <map>
 #include <string>
 #include <vector>
 
 class cmGeneratorTarget;
 class cmGlobalCommonGenerator;
+class cmLinkLineComputer;
 class cmLocalCommonGenerator;
 class cmMakefile;
 class cmSourceFile;
-class cmLinkLineComputer;
 
 /** \class cmCommonTargetGenerator
  * \brief Common infrastructure for Makefile and Ninja per-target generators
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 71d6c4e..f2eb601 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -2,12 +2,22 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmConditionEvaluator.h"
 
+#include <algorithm>
+#include <cmConfigure.h>
+#include <cmsys/RegularExpression.hxx>
+#include <sstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include "cmAlgorithms.h"
 #include "cmMakefile.h"
-#include "cmOutputConverter.h"
 #include "cmState.h"
 #include "cmSystemTools.h"
 
+class cmCommand;
+class cmTest;
+
 static std::string const keyAND = "AND";
 static std::string const keyCOMMAND = "COMMAND";
 static std::string const keyDEFINED = "DEFINED";
diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h
index 3c9d2cd..5815177 100644
--- a/Source/cmConditionEvaluator.h
+++ b/Source/cmConditionEvaluator.h
@@ -3,12 +3,18 @@
 #ifndef cmConditionEvaluator_h
 #define cmConditionEvaluator_h
 
-#include "cmCommand.h"
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <list>
+#include <string>
+#include <vector>
+
 #include "cmExpandedCommandArgument.h"
 #include "cmListFileCache.h"
+#include "cmPolicies.h"
 #include "cmake.h"
 
-#include <list>
+class cmMakefile;
 
 class cmConditionEvaluator
 {
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index b7d2196..3b46fc0 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -2,16 +2,24 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCoreTryCompile.h"
 
+#include <cmConfigure.h>
+#include <cmsys/Directory.hxx>
+#include <set>
+#include <sstream>
+#include <stdio.h>
+#include <string.h>
+
 #include "cmAlgorithms.h"
 #include "cmExportTryCompileFileGenerator.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmOutputConverter.h"
+#include "cmPolicies.h"
 #include "cmState.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
+#include "cmVersion.h"
 #include "cmake.h"
-#include <cmsys/Directory.hxx>
-
-#include <assert.h>
 
 static std::string const kCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN =
   "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN";
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index 0d9bb79..1c94f09 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -3,6 +3,11 @@
 #ifndef cmCoreTryCompile_h
 #define cmCoreTryCompile_h
 
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
 #include "cmCommand.h"
 #include "cmStateTypes.h"
 
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 14a6c88..69532e6 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -2,10 +2,14 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCreateTestSourceList.h"
 
+#include <algorithm>
+
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmSystemTools.h"
 
+class cmExecutionStatus;
+
 // cmCreateTestSourceList
 bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
                                          cmExecutionStatus&)
diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h
index 2f71a00..5e003cf 100644
--- a/Source/cmCreateTestSourceList.h
+++ b/Source/cmCreateTestSourceList.h
@@ -3,8 +3,15 @@
 #ifndef cmCreateTestSourceList_h
 #define cmCreateTestSourceList_h
 
+#include <cmConfigure.h>
+
+#include <string>
+#include <vector>
+
 #include "cmCommand.h"
 
+class cmExecutionStatus;
+
 /** \class cmCreateTestSourceList
  * \brief Test driver generation command
  *
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 0b459f9..47fe76a 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -3,6 +3,7 @@
 #include "cmDefinitions.h"
 
 #include <assert.h>
+#include <cmConfigure.h>
 #include <set>
 #include <utility>
 
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 8dfb9ea..ad40665 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -3,14 +3,14 @@
 #ifndef cmDefinitions_h
 #define cmDefinitions_h
 
-#include <cmConfigure.h>
-
-#include "cmLinkedTree.h"
-#include "cm_unordered_map.hxx"
+#include <cmConfigure.h> // IWYU pragma: keep
 
 #include <string>
 #include <vector>
 
+#include "cmLinkedTree.h"
+#include "cm_unordered_map.hxx"
+
 /** \class cmDefinitions
  * \brief Store a scope of variable definitions for CMake language.
  *
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 84ab072..e6000db 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -2,16 +2,15 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmDependsC.h"
 
+#include <cmsys/FStream.hxx>
+#include <utility>
+
 #include "cmAlgorithms.h"
 #include "cmFileTimeComparison.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#include "cmOutputConverter.h"
 #include "cmSystemTools.h"
 
-#include <cmsys/FStream.hxx>
-#include <utility>
-
 #define INCLUDE_REGEX_LINE                                                    \
   "^[ \t]*#[ \t]*(include|import)[ \t]*[<\"]([^\">]+)([\">])"
 
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index c8723d0..7927402 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -2,14 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmDependsFortran.h"
 
-#include "cmFortranParser.h" /* Interface to parser object.  */
-#include "cmGeneratedFileStream.h"
-#include "cmLocalGenerator.h"
-#include "cmMakefile.h"
-#include "cmOutputConverter.h"
-#include "cmStateDirectory.h"
-#include "cmSystemTools.h"
-
 #include <assert.h>
 #include <cmsys/FStream.hxx>
 #include <iostream>
@@ -18,6 +10,15 @@
 #include <string.h>
 #include <utility>
 
+#include "cmFortranParser.h" /* Interface to parser object.  */
+#include "cmGeneratedFileStream.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmOutputConverter.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmSystemTools.h"
+
 // 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.
diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h
index 1597ea7..71b939c 100644
--- a/Source/cmDependsJavaParserHelper.h
+++ b/Source/cmDependsJavaParserHelper.h
@@ -8,6 +8,8 @@
 #include <string>
 #include <vector>
 
+class cmDependsJavaParserHelper;
+
 #define YYSTYPE cmDependsJavaParserHelper::ParserType
 #define YYSTYPE_IS_DECLARED
 #define YY_EXTRA_TYPE cmDependsJavaParserHelper*
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index 7d4e97c..fd3c416 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -3,10 +3,6 @@
 #ifndef cmExecutionStatus_h
 #define cmExecutionStatus_h
 
-#include <cmConfigure.h>
-
-#include "cmStandardIncludes.h"
-
 /** \class cmExecutionStatus
  * \brief Superclass for all command status classes
  *
diff --git a/Source/cmExpandedCommandArgument.h b/Source/cmExpandedCommandArgument.h
index 39cffce..9770fe6 100644
--- a/Source/cmExpandedCommandArgument.h
+++ b/Source/cmExpandedCommandArgument.h
@@ -3,9 +3,9 @@
 #ifndef cmExpandedCommandArgument_h
 #define cmExpandedCommandArgument_h
 
-#include <cmConfigure.h>
+#include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmStandardIncludes.h"
+#include <string>
 
 /** \class cmExpandedCommandArgument
  * \brief Represents an expanded command argument
diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx
index 38f95d2..dab0c2c 100644
--- a/Source/cmExportBuildAndroidMKGenerator.cxx
+++ b/Source/cmExportBuildAndroidMKGenerator.cxx
@@ -2,14 +2,22 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmExportBuildAndroidMKGenerator.h"
 
-#include "cmExportSet.h"
+#include <algorithm>
+#include <map>
+#include <sstream>
+#include <utility>
+
+#include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
-#include "cmGlobalGenerator.h"
+#include "cmLinkItem.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#include "cmTargetExport.h"
-
-#include <algorithm>
+#include "cmPolicies.h"
+#include "cmStateTypes.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
+#include "cm_auto_ptr.hxx"
+#include "cmake.h"
 
 cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator()
 {
diff --git a/Source/cmExportBuildAndroidMKGenerator.h b/Source/cmExportBuildAndroidMKGenerator.h
index c9e0145..2a5a42e 100644
--- a/Source/cmExportBuildAndroidMKGenerator.h
+++ b/Source/cmExportBuildAndroidMKGenerator.h
@@ -3,10 +3,16 @@
 #ifndef cmExportBuildAndroidMKGenerator_h
 #define cmExportBuildAndroidMKGenerator_h
 
+#include <cmConfigure.h>
+
+#include <iosfwd>
+#include <string>
+#include <vector>
+
 #include "cmExportBuildFileGenerator.h"
-#include "cmListFileCache.h"
+#include "cmExportFileGenerator.h"
 
-class cmExportSet;
+class cmGeneratorTarget;
 
 /** \class cmExportBuildAndroidMKGenerator
  * \brief Generate a file exporting targets from a build tree.
diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx
index 2069785..9772f49 100644
--- a/Source/cmExportInstallAndroidMKGenerator.cxx
+++ b/Source/cmExportInstallAndroidMKGenerator.cxx
@@ -2,16 +2,17 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmExportInstallAndroidMKGenerator.h"
 
-#include "cmAlgorithms.h"
+#include <ostream>
+#include <stddef.h>
+
 #include "cmExportBuildAndroidMKGenerator.h"
 #include "cmExportSet.h"
-#include "cmExportSetMap.h"
-#include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
-#include "cmGlobalGenerator.h"
 #include "cmInstallExportGenerator.h"
 #include "cmInstallTargetGenerator.h"
-#include "cmLocalGenerator.h"
+#include "cmStateTypes.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
 #include "cmTargetExport.h"
 
 cmExportInstallAndroidMKGenerator::cmExportInstallAndroidMKGenerator(
diff --git a/Source/cmExportInstallAndroidMKGenerator.h b/Source/cmExportInstallAndroidMKGenerator.h
index c713027..f2f8927 100644
--- a/Source/cmExportInstallAndroidMKGenerator.h
+++ b/Source/cmExportInstallAndroidMKGenerator.h
@@ -3,10 +3,18 @@
 #ifndef cmExportInstallAndroidMKGenerator_h
 #define cmExportInstallAndroidMKGenerator_h
 
+#include <cmConfigure.h>
+
+#include <iosfwd>
+#include <set>
+#include <string>
+#include <vector>
+
+#include "cmExportFileGenerator.h"
 #include "cmExportInstallFileGenerator.h"
 
+class cmGeneratorTarget;
 class cmInstallExportGenerator;
-class cmInstallTargetGenerator;
 
 /** \class cmExportInstallAndroidMKGenerator
  * \brief Generate a file exporting targets from an install tree.
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 41fc428..b0a4c47 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -2,6 +2,11 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmExtraCodeBlocksGenerator.h"
 
+#include <map>
+#include <ostream>
+#include <string.h>
+#include <utility>
+
 #include "cmAlgorithms.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
@@ -14,12 +19,6 @@
 #include "cmXMLWriter.h"
 #include "cmake.h"
 
-#include <algorithm>
-#include <map>
-#include <ostream>
-#include <string.h>
-#include <utility>
-
 /* Some useful URLs:
 Homepage:
 http://www.codeblocks.org
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index c4e86a9..ff2703e 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -2,13 +2,20 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmExtraEclipseCDT4Generator.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <cmsys/RegularExpression.hxx>
+#include <map>
+#include <sstream>
+#include <stdio.h>
+#include <utility>
+
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#include "cmOutputConverter.h"
 #include "cmSourceFile.h"
 #include "cmSourceGroup.h"
 #include "cmState.h"
@@ -17,14 +24,6 @@
 #include "cmXMLWriter.h"
 #include "cmake.h"
 
-#include <algorithm>
-#include <assert.h>
-#include <cmsys/RegularExpression.hxx>
-#include <map>
-#include <sstream>
-#include <stdio.h>
-#include <utility>
-
 static void AppendAttribute(cmXMLWriter& xml, const char* keyval)
 {
   xml.StartElement("attribute");
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 9ef684d..5712ab2 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -2,7 +2,14 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmExtraSublimeTextGenerator.h"
 
+#include <cmsys/RegularExpression.hxx>
+#include <set>
+#include <sstream>
+#include <string.h>
+#include <utility>
+
 #include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
 #include "cmLocalGenerator.h"
@@ -10,12 +17,7 @@
 #include "cmSourceFile.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
-
-#include <cmsys/RegularExpression.hxx>
-#include <ostream>
-#include <set>
-#include <string.h>
-#include <utility>
+#include "cmake.h"
 
 /*
 Sublime Text 2 Generator
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 1bade57..afff0f3 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -20,6 +20,7 @@
 
 #undef GetCurrentDirectory
 #include <assert.h>
+#include <stdlib.h>
 
 #include <sys/types.h>
 // include sys/stat.h after sys/types.h
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 55d8c2a..991ebb8 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmFileTimeComparison.h"
 
-#include <cmConfigure.h>
 #include <string>
 #include <time.h>
 #include <utility>
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 3d67ac1..dce5021 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -2,8 +2,14 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmFindBase.h"
 
+#include <cmConfigure.h>
+#include <iostream>
+#include <map>
+#include <stddef.h>
+
 #include "cmAlgorithms.h"
 #include "cmMakefile.h"
+#include "cmSearchPath.h"
 #include "cmState.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h
index 2b8d4a2..423d453 100644
--- a/Source/cmFindBase.h
+++ b/Source/cmFindBase.h
@@ -3,6 +3,11 @@
 #ifndef cmFindBase_h
 #define cmFindBase_h
 
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
 #include "cmFindCommon.h"
 
 /** \class cmFindBase
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 75d1453..110195c 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -2,12 +2,13 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmFindCommon.h"
 
+#include <algorithm>
+#include <string.h>
+#include <utility>
+
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
 
-#include <algorithm>
-#include <functional>
-
 cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL");
 cmFindCommon::PathLabel cmFindCommon::PathLabel::CMake("CMAKE");
 cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeEnvironment(
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 1809c0a..4d6d569 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -3,10 +3,19 @@
 #ifndef cmFindCommon_h
 #define cmFindCommon_h
 
+#include <cmConfigure.h>
+
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
 #include "cmCommand.h"
 #include "cmPathLabel.h"
 #include "cmSearchPath.h"
 
+class cmMakefile;
+
 /** \class cmFindCommon
  * \brief Base class for FIND_XXX implementations.
  *
diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h
index 388115d..b3450b3 100644
--- a/Source/cmFunctionBlocker.h
+++ b/Source/cmFunctionBlocker.h
@@ -3,12 +3,9 @@
 #ifndef cmFunctionBlocker_h
 #define cmFunctionBlocker_h
 
-#include <cmConfigure.h>
-
-#include "cmStandardIncludes.h"
-
-#include "cmExecutionStatus.h"
 #include "cmListFileCache.h"
+
+class cmExecutionStatus;
 class cmMakefile;
 
 class cmFunctionBlocker
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index 0ba575a..31adcb7 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmFunctionCommand.h"
 
-#include <algorithm>
 #include <sstream>
 
 #include "cmAlgorithms.h"
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 6cdb7f5..4731493 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -2,11 +2,12 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGeneratedFileStream.h"
 
-#include "cmSystemTools.h"
-
 #include <stdio.h>
 
+#include "cmSystemTools.h"
+
 #if defined(CMAKE_BUILD_WITH_CMAKE)
+#include "cm_codecvt.hxx"
 #include <cm_zlib.h>
 #endif
 
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 34f763c..1f2d2b4 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -2,6 +2,9 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGeneratorExpression.h"
 
+#include <cmsys/RegularExpression.hxx>
+#include <utility>
+
 #include "assert.h"
 #include "cmAlgorithms.h"
 #include "cmGeneratorExpressionContext.h"
@@ -9,9 +12,7 @@
 #include "cmGeneratorExpressionLexer.h"
 #include "cmGeneratorExpressionParser.h"
 #include "cmSystemTools.h"
-
-#include <cmsys/RegularExpression.hxx>
-#include <utility>
+#include "cm_auto_ptr.hxx"
 
 cmGeneratorExpression::cmGeneratorExpression(
   const cmListFileBacktrace& backtrace)
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index c6c4c3a..aeb005f 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -2,6 +2,11 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGeneratorExpressionEvaluationFile.h"
 
+#include <cmConfigure.h>
+#include <cmsys/FStream.hxx>
+#include <sstream>
+#include <utility>
+
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
 #include "cmListFileCache.h"
@@ -9,13 +14,9 @@
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmSystemTools.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <cmConfigure.h>
-#include <cmsys/FStream.hxx>
-#include <sstream>
-#include <utility>
-
 cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
   const std::string& input,
   CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr,
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index d597270..26135df 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -5,14 +5,19 @@
 
 #include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmGeneratorExpression.h"
-
-#include <cm_auto_ptr.hxx>
 #include <map>
 #include <string>
-#include <sys/types.h>
 #include <vector>
 
+#include "cmGeneratorExpression.h"
+#include "cm_auto_ptr.hxx"
+
+#if defined(_MSC_VER)
+typedef unsigned short mode_t;
+#else
+#include <sys/types.h>
+#endif
+
 class cmLocalGenerator;
 
 class cmGeneratorExpressionEvaluationFile
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index ca056c0..882de85 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2,6 +2,17 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGeneratorTarget.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <cmsys/RegularExpression.hxx>
+#include <errno.h>
+#include <iterator>
+#include <queue>
+#include <sstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
 #include "cmCustomCommand.h"
@@ -24,16 +35,7 @@
 #include "cm_unordered_set.hxx"
 #include "cmake.h"
 
-#include <algorithm>
-#include <assert.h>
-#include <cmsys/RegularExpression.hxx>
-#include <errno.h>
-#include <iterator>
-#include <queue>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+class cmMessenger;
 
 template <>
 const char* cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index c92ae21..7962da6 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGetCMakePropertyCommand.h"
 
-#include <algorithm>
 #include <set>
 
 #include "cmAlgorithms.h"
diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx
index a0a33ea..d2372a7 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.cxx
+++ b/Source/cmGlobalBorlandMakefileGenerator.cxx
@@ -2,6 +2,7 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalBorlandMakefileGenerator.h"
 
+#include "cmDocumentationEntry.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmState.h"
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index cf51c6a..2d0767f 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -9,6 +9,16 @@
 
 #include "cmGlobalGenerator.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <cmsys/Directory.hxx>
+#include <cmsys/FStream.hxx>
+#include <iterator>
+#include <sstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include "cmAlgorithms.h"
 #include "cmCPackPropertiesGenerator.h"
 #include "cmComputeTargetDepends.h"
@@ -29,20 +39,11 @@
 #include "cmQtAutoGeneratorInitializer.h"
 #include "cmSourceFile.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
 #include "cmStateTypes.h"
 #include "cmVersion.h"
 #include "cmake.h"
 
-#include <algorithm>
-#include <assert.h>
-#include <cmsys/Directory.hxx>
-#include <cmsys/FStream.hxx>
-#include <iterator>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include <cm_jsoncpp_value.h>
 #include <cm_jsoncpp_writer.h>
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 4bf4bd1..88ef8da 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -5,8 +5,15 @@
 
 #include <cmConfigure.h>
 
+#include <iosfwd>
+#include <map>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cmCustomCommandLines.h"
 #include "cmExportSetMap.h"
-#include "cmStateDirectory.h"
 #include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
@@ -14,26 +21,19 @@
 #include "cm_codecvt.hxx"
 #include "cm_unordered_map.hxx"
 
-#include <iosfwd>
-#include <map>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cmFileLockPool.h"
 #endif
 
-class cmCustomCommandLines;
-class cmSourceFile;
 class cmExportBuildFileGenerator;
 class cmExternalMakefileProjectGenerator;
 class cmGeneratorTarget;
-class cmLocalGenerator;
 class cmLinkLineComputer;
+class cmLocalGenerator;
 class cmMakefile;
 class cmOutputConverter;
+class cmSourceFile;
+class cmStateDirectory;
 class cmake;
 
 /** \class cmGlobalGenerator
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index 528e118..5e948f7 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -5,12 +5,11 @@
 
 #include <cmConfigure.h>
 
-#include <cmConfigure.h>
-
-#include "cmStandardIncludes.h"
+#include <string>
+#include <vector>
 
-class cmake;
 class cmGlobalGenerator;
+class cmake;
 struct cmDocumentationEntry;
 
 /** \class cmGlobalGeneratorFactory
diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx
index 78bf5bd..18c45e0 100644
--- a/Source/cmGlobalJOMMakefileGenerator.cxx
+++ b/Source/cmGlobalJOMMakefileGenerator.cxx
@@ -2,6 +2,7 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalJOMMakefileGenerator.h"
 
+#include "cmDocumentationEntry.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmState.h"
diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx
index f17b915..7e0d0d4 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.cxx
+++ b/Source/cmGlobalMSYSMakefileGenerator.cxx
@@ -2,11 +2,13 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalMSYSMakefileGenerator.h"
 
+#include <cmsys/FStream.hxx>
+
+#include "cmDocumentationEntry.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmState.h"
 #include "cmake.h"
-#include <cmsys/FStream.hxx>
 
 cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator(cmake* cm)
   : cmGlobalUnixMakefileGenerator3(cm)
diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx
index 255c0f5..3c3a5d1d 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.cxx
+++ b/Source/cmGlobalMinGWMakefileGenerator.cxx
@@ -2,6 +2,7 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalMinGWMakefileGenerator.h"
 
+#include "cmDocumentationEntry.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmState.h"
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx
index 06aba73..da683fb 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.cxx
+++ b/Source/cmGlobalNMakeMakefileGenerator.cxx
@@ -2,6 +2,7 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalNMakeMakefileGenerator.h"
 
+#include "cmDocumentationEntry.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmState.h"
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 830ab7f..f62c8ec 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2,6 +2,17 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalNinjaGenerator.h"
 
+#include <algorithm>
+#include <cm_jsoncpp_reader.h>
+#include <cm_jsoncpp_value.h>
+#include <cm_jsoncpp_writer.h>
+#include <cmsys/FStream.hxx>
+#include <ctype.h>
+#include <functional>
+#include <iterator>
+#include <sstream>
+#include <stdio.h>
+
 #include "cmAlgorithms.h"
 #include "cmDocumentationEntry.h"
 #include "cmFortranParser.h"
@@ -13,6 +24,9 @@
 #include "cmMakefile.h"
 #include "cmNinjaLinkLineComputer.h"
 #include "cmOutputConverter.h"
+#include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
@@ -21,15 +35,7 @@
 #include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include "cm_jsoncpp_reader.h"
-#include "cm_jsoncpp_writer.h"
-
-#include <algorithm>
-#include <ctype.h>
-#include <functional>
-#include <iterator>
-#include <sstream>
-#include <stdio.h>
+class cmLinkLineComputer;
 
 const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja";
 const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja";
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 064ff0b..a51e919 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -5,12 +5,6 @@
 
 #include <cmConfigure.h>
 
-#include "cmGlobalCommonGenerator.h"
-#include "cmGlobalGenerator.h"
-#include "cmGlobalGeneratorFactory.h"
-#include "cmNinjaTypes.h"
-#include "cmPolicies.h"
-
 #include <iosfwd>
 #include <map>
 #include <set>
@@ -18,13 +12,23 @@
 #include <utility>
 #include <vector>
 
+#include "cmGlobalCommonGenerator.h"
+#include "cmGlobalGenerator.h"
+#include "cmGlobalGeneratorFactory.h"
+#include "cmNinjaTypes.h"
+#include "cmPolicies.h"
+#include "cm_codecvt.hxx"
+
 class cmCustomCommand;
-class cmMakefile;
-class cmake;
-struct cmDocumentationEntry;
 class cmGeneratedFileStream;
 class cmGeneratorTarget;
+class cmLinkLineComputer;
 class cmLocalGenerator;
+class cmMakefile;
+class cmOutputConverter;
+class cmStateDirectory;
+class cmake;
+struct cmDocumentationEntry;
 
 /**
  * \class cmGlobalNinjaGenerator
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 90caaf9..23b3718 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -2,6 +2,11 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGlobalUnixMakefileGenerator3.h"
 
+#include <algorithm>
+#include <functional>
+#include <sstream>
+#include <utility>
+
 #include "cmAlgorithms.h"
 #include "cmDocumentationEntry.h"
 #include "cmGeneratedFileStream.h"
@@ -14,16 +19,12 @@
 #include "cmOutputConverter.h"
 #include "cmState.h"
 #include "cmStateDirectory.h"
+#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 #include "cmTargetDepend.h"
 #include "cmake.h"
 
-#include <algorithm>
-#include <functional>
-#include <sstream>
-#include <utility>
-
 cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm)
   : cmGlobalCommonGenerator(cm)
 {
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 843e5dc..67d7bc9 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -5,11 +5,6 @@
 
 #include <cmConfigure.h>
 
-#include "cmGeneratorTarget.h"
-#include "cmGlobalCommonGenerator.h"
-#include "cmGlobalGeneratorFactory.h"
-#include "cmStateTypes.h"
-
 #include <iosfwd>
 #include <map>
 #include <set>
@@ -17,6 +12,11 @@
 #include <string>
 #include <vector>
 
+#include "cmGeneratorTarget.h"
+#include "cmGlobalCommonGenerator.h"
+#include "cmGlobalGeneratorFactory.h"
+#include "cmStateSnapshot.h"
+
 class cmGeneratedFileStream;
 class cmLocalGenerator;
 class cmLocalUnixMakefileGenerator3;
diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx
index 0900797..94cdb38 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.cxx
+++ b/Source/cmGlobalWatcomWMakeGenerator.cxx
@@ -5,7 +5,6 @@
 #include "cmDocumentationEntry.h"
 #include "cmMakefile.h"
 #include "cmState.h"
-#include "cmStateTypes.h"
 #include "cmake.h"
 
 cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator(cmake* cm)
diff --git a/Source/cmGraphAdjacencyList.h b/Source/cmGraphAdjacencyList.h
index a154373..e6aec47 100644
--- a/Source/cmGraphAdjacencyList.h
+++ b/Source/cmGraphAdjacencyList.h
@@ -3,9 +3,9 @@
 #ifndef cmGraphAdjacencyList_h
 #define cmGraphAdjacencyList_h
 
-#include <cmConfigure.h>
+#include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmStandardIncludes.h"
+#include <vector>
 
 /**
  * Graph edge representation.  Most use cases just need the
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 6b32f73..0f69aaa 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -2,21 +2,22 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGraphVizWriter.h"
 
+#include <cmConfigure.h>
+#include <iostream>
+#include <sstream>
+#include <utility>
+
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
+#include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 #include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <cmConfigure.h>
-#include <iostream>
-#include <sstream>
-#include <utility>
-
 static const char* getShapeForTarget(const cmGeneratorTarget* target)
 {
   if (!target) {
diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx
index db855d2..d9d6598 100644
--- a/Source/cmHexFileConverter.cxx
+++ b/Source/cmHexFileConverter.cxx
@@ -2,11 +2,12 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmHexFileConverter.h"
 
-#include "cmSystemTools.h"
-
+#include <cmConfigure.h>
 #include <stdio.h>
 #include <string.h>
 
+#include "cmSystemTools.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)
diff --git a/Source/cmHexFileConverter.h b/Source/cmHexFileConverter.h
index cb550bb..1050bc1 100644
--- a/Source/cmHexFileConverter.h
+++ b/Source/cmHexFileConverter.h
@@ -3,10 +3,6 @@
 #ifndef cmHexFileConverter_h
 #define cmHexFileConverter_h
 
-#include <cmConfigure.h>
-
-#include "cmStandardIncludes.h"
-
 /** \class cmHexFileConverter
  * \brief Can detects Intel Hex and Motorola S-record files and convert them
  *        to binary files.
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index bf59e88..fadebb4 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmInstallCommand.h"
 
-#include <algorithm>
 #include <cmsys/Glob.hxx>
 #include <sstream>
 #include <stddef.h>
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index de6919b..6b15468 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -2,6 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmInstallCommandArguments.h"
 
+#include <cmConfigure.h>
+
 #include "cmSystemTools.h"
 
 // Table of valid permissions.
diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h
index 82c2310..c1523b2 100644
--- a/Source/cmInstallCommandArguments.h
+++ b/Source/cmInstallCommandArguments.h
@@ -3,9 +3,10 @@
 #ifndef cmInstallCommandArguments_h
 #define cmInstallCommandArguments_h
 
-#include <cmConfigure.h>
+#include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmStandardIncludes.h"
+#include <string>
+#include <vector>
 
 #include "cmCommandArgumentsHelper.h"
 
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index f1df073..4dfa40f 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -2,6 +2,12 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmInstallTargetGenerator.h"
 
+#include <assert.h>
+#include <map>
+#include <set>
+#include <sstream>
+#include <utility>
+
 #include "cmComputeLinkInformation.h"
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
@@ -12,15 +18,8 @@
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <assert.h>
-#include <map>
-#include <set>
-#include <sstream>
-#include <utility>
-
 cmInstallTargetGenerator::cmInstallTargetGenerator(
   const std::string& targetName, const char* dest, bool implib,
   const char* file_permissions, std::vector<std::string> const& configurations,
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index 74d6774..6fd6f50 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -3,8 +3,16 @@
 #ifndef cmLinkItem_h
 #define cmLinkItem_h
 
+#include <cmConfigure.h>
+
+#include <algorithm>
+#include <map>
+#include <string>
+#include <vector>
+
 #include "cmListFileCache.h"
 #include "cmSystemTools.h"
+#include "cmTargetLinkLibraryType.h"
 
 class cmGeneratorTarget;
 
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx
index c271246..cf0cf88 100644
--- a/Source/cmLinkLineComputer.cxx
+++ b/Source/cmLinkLineComputer.cxx
@@ -2,10 +2,15 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 
 #include "cmLinkLineComputer.h"
+
+#include <sstream>
+#include <vector>
+
 #include "cmComputeLinkInformation.h"
 #include "cmGeneratorTarget.h"
 #include "cmOutputConverter.h"
 #include "cmStateDirectory.h"
+#include "cmStateTypes.h"
 
 cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter,
                                        cmStateDirectory stateDir)
diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h
index 6bbb69e..97a5d1b 100644
--- a/Source/cmLinkLineComputer.h
+++ b/Source/cmLinkLineComputer.h
@@ -4,6 +4,10 @@
 #ifndef cmLinkLineComputer_h
 #define cmLinkLineComputer_h
 
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <string>
+
 #include "cmStateDirectory.h"
 
 class cmComputeLinkInformation;
diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h
index d2c6f33..4f95522 100644
--- a/Source/cmLinkedTree.h
+++ b/Source/cmLinkedTree.h
@@ -5,9 +5,9 @@
 
 #include <cmConfigure.h>
 
-#include "cmStandardIncludes.h"
-
 #include <assert.h>
+#include <iterator>
+#include <vector>
 
 /**
   @brief A adaptor for traversing a tree structure in a vector
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 6b49f1e..d5f9d27 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -2,10 +2,11 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmLocalCommonGenerator.h"
 
+#include <vector>
+
 #include "cmGeneratorTarget.h"
 #include "cmMakefile.h"
-
-#include <vector>
+#include "cmOutputConverter.h"
 
 class cmGlobalGenerator;
 
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index eb5f850..f83f371 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -5,11 +5,10 @@
 
 #include <cmConfigure.h>
 
-#include "cmLocalGenerator.h"
-#include "cmOutputConverter.h"
-
 #include <string>
 
+#include "cmLocalGenerator.h"
+
 class cmGeneratorTarget;
 class cmGlobalGenerator;
 class cmMakefile;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 4aecb1d..7d3a2f0 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -18,6 +18,7 @@
 #include "cmSourceFile.h"
 #include "cmState.h"
 #include "cmStateDirectory.h"
+#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 #include "cmTestGenerator.h"
@@ -32,10 +33,10 @@
 #include <algorithm>
 #include <assert.h>
 #include <cmsys/RegularExpression.hxx>
-#include <ctype.h>
 #include <iterator>
 #include <sstream>
 #include <stdio.h>
+#include <string.h>
 #include <utility>
 
 #if defined(__HAIKU__)
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 6314aff..fdca78a 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -5,29 +5,28 @@
 
 #include <cmConfigure.h>
 
-#include "cmListFileCache.h"
-#include "cmOutputConverter.h"
-#include "cmPolicies.h"
-#include "cmRulePlaceholderExpander.h"
-#include "cmStateTypes.h"
-#include "cmake.h"
-
 #include <cm_kwiml.h>
 #include <iosfwd>
 #include <map>
 #include <set>
-#include <string.h>
 #include <string>
 #include <vector>
 
+#include "cmListFileCache.h"
+#include "cmOutputConverter.h"
+#include "cmPolicies.h"
+#include "cmStateSnapshot.h"
+#include "cmake.h"
+
 class cmComputeLinkInformation;
 class cmCustomCommandGenerator;
 class cmGeneratorTarget;
 class cmGlobalGenerator;
-class cmRulePlaceholderExpander;
+class cmLinkLineComputer;
 class cmMakefile;
+class cmRulePlaceholderExpander;
 class cmSourceFile;
-class cmLinkLineComputer;
+class cmState;
 
 /** \class cmLocalGenerator
  * \brief Create required build files for a directory.
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index c27ab09..c2d9d57 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -2,6 +2,13 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmLocalNinjaGenerator.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <iterator>
+#include <sstream>
+#include <stdio.h>
+#include <utility>
+
 #include "cmCustomCommand.h"
 #include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
@@ -15,15 +22,9 @@
 #include "cmState.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <algorithm>
-#include <assert.h>
-#include <iterator>
-#include <sstream>
-#include <stdio.h>
-#include <utility>
-
 cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
                                              cmMakefile* mf)
   : cmLocalCommonGenerator(gg, mf, mf->GetState()->GetBinaryDirectory())
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index 95d8eb8..1080319 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -5,17 +5,16 @@
 
 #include <cmConfigure.h>
 
-#include "cmLocalCommonGenerator.h"
-#include "cmLocalGenerator.h"
-#include "cmNinjaTypes.h"
-#include "cmOutputConverter.h"
-
 #include <iosfwd>
 #include <map>
 #include <set>
 #include <string>
 #include <vector>
 
+#include "cmLocalCommonGenerator.h"
+#include "cmNinjaTypes.h"
+#include "cmOutputConverter.h"
+
 class cmCustomCommand;
 class cmCustomCommandGenerator;
 class cmGeneratedFileStream;
@@ -23,6 +22,7 @@ class cmGeneratorTarget;
 class cmGlobalGenerator;
 class cmGlobalNinjaGenerator;
 class cmMakefile;
+class cmRulePlaceholderExpander;
 class cmSourceFile;
 class cmake;
 
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 4f81ef1..8bb084a 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2,6 +2,14 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmLocalUnixMakefileGenerator3.h"
 
+#include <algorithm>
+#include <cmsys/FStream.hxx>
+#include <cmsys/Terminal.h>
+#include <functional>
+#include <sstream>
+#include <stdio.h>
+#include <utility>
+
 #include "cmAlgorithms.h"
 #include "cmCustomCommand.h"
 #include "cmCustomCommandGenerator.h"
@@ -18,9 +26,11 @@
 #include "cmSourceFile.h"
 #include "cmState.h"
 #include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmVersion.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
 // Include dependency scanners for supported languages.  Only the
@@ -31,15 +41,6 @@
 #include "cmDependsJava.h"
 #endif
 
-#include <algorithm>
-#include <cm_auto_ptr.hxx>
-#include <cmsys/FStream.hxx>
-#include <cmsys/Terminal.h>
-#include <functional>
-#include <sstream>
-#include <stdio.h>
-#include <utility>
-
 // Escape special characters in Makefile dependency lines
 class cmMakeSafe
 {
diff --git a/Source/cmLocale.h b/Source/cmLocale.h
index f35e528..e8e751d 100644
--- a/Source/cmLocale.h
+++ b/Source/cmLocale.h
@@ -5,8 +5,6 @@
 
 #include <cmConfigure.h>
 
-#include "cmStandardIncludes.h"
-
 #include <locale.h>
 
 class cmLocaleRAII
diff --git a/Source/cmMSVC60LinkLineComputer.cxx b/Source/cmMSVC60LinkLineComputer.cxx
index 9308d91..d761e7b 100644
--- a/Source/cmMSVC60LinkLineComputer.cxx
+++ b/Source/cmMSVC60LinkLineComputer.cxx
@@ -3,7 +3,13 @@
 
 #include "cmMSVC60LinkLineComputer.h"
 
+#include "cmStateDirectory.h"
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include "cmSystemTools.h"
+#endif
+
+class cmOutputConverter;
 
 cmMSVC60LinkLineComputer::cmMSVC60LinkLineComputer(
   cmOutputConverter* outputConverter, cmStateDirectory stateDir)
diff --git a/Source/cmMSVC60LinkLineComputer.h b/Source/cmMSVC60LinkLineComputer.h
index 381b8a2..9a28dca 100644
--- a/Source/cmMSVC60LinkLineComputer.h
+++ b/Source/cmMSVC60LinkLineComputer.h
@@ -4,8 +4,15 @@
 #ifndef cmMSVC60LinkLineComputer_h
 #define cmMSVC60LinkLineComputer_h
 
+#include <cmConfigure.h>
+
+#include <string>
+
 #include "cmLinkLineComputer.h"
 
+class cmOutputConverter;
+class cmStateDirectory;
+
 class cmMSVC60LinkLineComputer : public cmLinkLineComputer
 {
 public:
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index d777bd5..583f801 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmMacroCommand.h"
 
-#include <algorithm>
 #include <sstream>
 #include <stdio.h>
 
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 741ffb8..90182f9 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2,6 +2,16 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmMakefile.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
+#include <ctype.h>
+#include <sstream>
+#include <stdlib.h>
+#include <string.h>
+#include <utility>
+
 #include "cmAlgorithms.h"
 #include "cmCommand.h"
 #include "cmCommandArgumentParserHelper.h"
@@ -14,6 +24,7 @@
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorExpressionEvaluationFile.h"
 #include "cmGlobalGenerator.h"
+#include "cmInstallGenerator.h" // IWYU pragma: keep
 #include "cmListFileCache.h"
 #include "cmSourceFile.h"
 #include "cmSourceFileLocation.h"
@@ -21,28 +32,17 @@
 #include "cmStateDirectory.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
+#include "cmTargetLinkLibraryType.h"
 #include "cmTest.h"
+#include "cmTestGenerator.h" // IWYU pragma: keep
 #include "cmVersion.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include "cmInstallGenerator.h" // IWYU pragma: keep
-#include "cmTestGenerator.h"    // IWYU pragma: keep
-
 #ifdef CMAKE_BUILD_WITH_CMAKE
 #include "cmVariableWatch.h"
 #endif
 
-#include <algorithm>
-#include <assert.h>
-#include <cm_auto_ptr.hxx>
-#include <cmsys/FStream.hxx>
-#include <cmsys/RegularExpression.hxx>
-#include <ctype.h>
-#include <sstream>
-#include <stdlib.h>
-#include <string.h>
-#include <utility>
-
 class cmMessenger;
 
 // default is not to be building executables
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 3067f2c..859b3c8 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -5,13 +5,21 @@
 
 #include <cmConfigure.h>
 
+#include <cmsys/RegularExpression.hxx>
+#include <map>
+#include <set>
+#include <stack>
+#include <string>
+#include <vector>
+
 #include "cmAlgorithms.h"
 #include "cmListFileCache.h"
 #include "cmNewLineStyle.h"
 #include "cmPolicies.h"
 #include "cmStateSnapshot.h"
+#include "cmStateTypes.h"
 #include "cmTarget.h"
-#include "cmTargetLinkLibraryType.h"
+#include "cm_auto_ptr.hxx"
 #include "cm_unordered_map.hxx"
 #include "cmake.h"
 
@@ -19,15 +27,6 @@
 #include "cmSourceGroup.h"
 #endif
 
-#include <cm_auto_ptr.hxx>
-#include <cmsys/RegularExpression.hxx>
-
-#include <map>
-#include <set>
-#include <stack>
-#include <string>
-#include <vector>
-
 class cmCommand;
 class cmCompiledGeneratorExpression;
 class cmCustomCommandLines;
@@ -40,6 +39,7 @@ class cmGlobalGenerator;
 class cmInstallGenerator;
 class cmMessenger;
 class cmSourceFile;
+class cmState;
 class cmTest;
 class cmTestGenerator;
 class cmVariableWatch;
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index cbbd2e6..358804e 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -2,6 +2,10 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmMakefileExecutableTargetGenerator.h"
 
+#include <sstream>
+#include <string>
+#include <vector>
+
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
@@ -13,13 +17,12 @@
 #include "cmOutputConverter.h"
 #include "cmRulePlaceholderExpander.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <sstream>
-#include <string>
-#include <vector>
-
 cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator(
   cmGeneratorTarget* target)
   : cmMakefileTargetGenerator(target)
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index a249efd..c591bb3 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -2,6 +2,11 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmMakefileLibraryTargetGenerator.h"
 
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <sstream>
+#include <vector>
+
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
@@ -13,13 +18,13 @@
 #include "cmOutputConverter.h"
 #include "cmRulePlaceholderExpander.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <sstream>
-#include <vector>
-
 cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
   cmGeneratorTarget* target)
   : cmMakefileTargetGenerator(target)
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 68aabef..5bec2bb 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -2,6 +2,10 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmMakefileTargetGenerator.h"
 
+#include <sstream>
+#include <stdio.h>
+#include <utility>
+
 #include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
 #include "cmCustomCommand.h"
@@ -10,8 +14,6 @@
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
-#include "cmLinkLineComputer.h"
-#include "cmLocalGenerator.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmMakefileExecutableTargetGenerator.h"
@@ -21,17 +23,13 @@
 #include "cmRulePlaceholderExpander.h"
 #include "cmSourceFile.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <algorithm>
-#include <ctype.h>
-#include <sstream>
-#include <stdio.h>
-#include <utility>
-
 #ifndef _WIN32
 #include <unistd.h>
 #endif
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index e44f64a..347f9f2 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -5,22 +5,24 @@
 
 #include <cmConfigure.h>
 
-#include "cmCommonTargetGenerator.h"
-#include "cmLocalUnixMakefileGenerator3.h"
-#include "cmOSXBundleGenerator.h"
-
 #include <iosfwd>
 #include <map>
 #include <set>
 #include <string>
 #include <vector>
 
+#include "cmCommonTargetGenerator.h"
+#include "cmLocalUnixMakefileGenerator3.h"
+#include "cmOSXBundleGenerator.h"
+
 class cmCustomCommandGenerator;
 class cmGeneratedFileStream;
 class cmGeneratorTarget;
 class cmGlobalUnixMakefileGenerator3;
-class cmSourceFile;
 class cmLinkLineComputer;
+class cmOutputConverter;
+class cmSourceFile;
+class cmStateDirectory;
 
 /** \class cmMakefileTargetGenerator
  * \brief Support Routines for writing makefiles
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index ecb29cb..a7c5d27 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -2,17 +2,17 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmMakefileUtilityTargetGenerator.h"
 
+#include <ostream>
+#include <string>
+#include <vector>
+
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmOSXBundleGenerator.h"
-#include "cmOutputConverter.h"
-
-#include <ostream>
-#include <string>
-#include <vector>
+#include "cmSystemTools.h"
 
 cmMakefileUtilityTargetGenerator::cmMakefileUtilityTargetGenerator(
   cmGeneratorTarget* target)
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 2e15720..43fb5f5 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -2,8 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmMessageCommand.h"
 
-#include <algorithm>
-
 #include "cmAlgorithms.h"
 #include "cmMakefile.h"
 #include "cmMessenger.h"
diff --git a/Source/cmNinjaLinkLineComputer.cxx b/Source/cmNinjaLinkLineComputer.cxx
index fa9df6d..2546b55 100644
--- a/Source/cmNinjaLinkLineComputer.cxx
+++ b/Source/cmNinjaLinkLineComputer.cxx
@@ -2,7 +2,11 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 
 #include "cmNinjaLinkLineComputer.h"
+
 #include "cmGlobalNinjaGenerator.h"
+#include "cmStateDirectory.h"
+
+class cmOutputConverter;
 
 cmNinjaLinkLineComputer::cmNinjaLinkLineComputer(
   cmOutputConverter* outputConverter, cmStateDirectory stateDir,
diff --git a/Source/cmNinjaLinkLineComputer.h b/Source/cmNinjaLinkLineComputer.h
index daecea4..ff0771b 100644
--- a/Source/cmNinjaLinkLineComputer.h
+++ b/Source/cmNinjaLinkLineComputer.h
@@ -4,10 +4,15 @@
 #ifndef cmNinjaLinkLineComputer_h
 #define cmNinjaLinkLineComputer_h
 
+#include <cmConfigure.h>
+
+#include <string>
+
 #include "cmLinkLineComputer.h"
-#include "cmState.h"
 
 class cmGlobalNinjaGenerator;
+class cmOutputConverter;
+class cmStateDirectory;
 
 class cmNinjaLinkLineComputer : public cmLinkLineComputer
 {
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index d70bf8e..a23e0ad 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -2,6 +2,15 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmNinjaNormalTargetGenerator.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <iterator>
+#include <limits>
+#include <map>
+#include <set>
+#include <sstream>
+#include <stddef.h>
+
 #include "cmAlgorithms.h"
 #include "cmCustomCommand.h"
 #include "cmCustomCommandGenerator.h"
@@ -18,19 +27,13 @@
 #include "cmRulePlaceholderExpander.h"
 #include "cmSourceFile.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include <algorithm>
-#include <assert.h>
-#include <iterator>
-#include <limits>
-#include <map>
-#include <set>
-#include <sstream>
-#include <stddef.h>
-
 #ifndef _WIN32
 #include <unistd.h>
 #endif
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index cf60892..a220cd8 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -2,10 +2,20 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmNinjaTargetGenerator.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <cm_jsoncpp_value.h>
+#include <cm_jsoncpp_writer.h>
+#include <iterator>
+#include <map>
+#include <sstream>
+#include <string.h>
+
 #include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
 #include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalNinjaGenerator.h"
 #include "cmLocalGenerator.h"
@@ -19,16 +29,9 @@
 #include "cmState.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
+#include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
-#include "cm_jsoncpp_writer.h"
-
-#include <algorithm>
-#include <iterator>
-#include <map>
-#include <sstream>
-#include <string.h>
-
 cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
 {
   switch (target->GetType()) {
diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h
index b4eaa59..3fd536a 100644
--- a/Source/cmNinjaTypes.h
+++ b/Source/cmNinjaTypes.h
@@ -3,9 +3,11 @@
 #ifndef cmNinjaTypes_h
 #define cmNinjaTypes_h
 
-#include <cmConfigure.h>
+#include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmStandardIncludes.h"
+#include <map>
+#include <string>
+#include <vector>
 
 typedef std::vector<std::string> cmNinjaDeps;
 typedef std::map<std::string, std::string> cmNinjaVars;
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index bbd6090..00a2d2b 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -2,8 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmOptionCommand.h"
 
-#include <algorithm>
-
 #include "cmAlgorithms.h"
 #include "cmMakefile.h"
 #include "cmState.h"
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 445ad0b..d6864a6 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -2,16 +2,17 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmOutputConverter.h"
 
-#include "cmAlgorithms.h"
-#include "cmState.h"
-#include "cmStateDirectory.h"
-#include "cmSystemTools.h"
-
 #include <algorithm>
 #include <assert.h>
 #include <ctype.h>
 #include <set>
 #include <sstream>
+#include <vector>
+
+#include "cmAlgorithms.h"
+#include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmSystemTools.h"
 
 cmOutputConverter::cmOutputConverter(cmStateSnapshot snapshot)
   : StateSnapshot(snapshot)
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h
index dabb091..a3da4cd 100644
--- a/Source/cmOutputConverter.h
+++ b/Source/cmOutputConverter.h
@@ -5,10 +5,12 @@
 
 #include <cmConfigure.h> // IWYU pragma: keep
 
+#include <string>
+
 #include "cmStateSnapshot.h"
 
-#include <string>
-#include <vector>
+class cmState;
+class cmStateDirectory;
 
 class cmOutputConverter
 {
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index 0a2dd12..d75ee8e 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmParseArgumentsCommand.h"
 
-#include <algorithm>
 #include <map>
 #include <set>
 #include <sstream>
diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx
index 19e6820..30ba081 100644
--- a/Source/cmPathLabel.cxx
+++ b/Source/cmPathLabel.cxx
@@ -2,6 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmPathLabel.h"
 
+#include <stddef.h>
+
 cmPathLabel::cmPathLabel(const std::string& label)
   : Label(label)
   , Hash(0)
diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h
index 5e9e423..cd9743c 100644
--- a/Source/cmPathLabel.h
+++ b/Source/cmPathLabel.h
@@ -3,9 +3,9 @@
 #ifndef cmPathLabel_h
 #define cmPathLabel_h
 
-#include <cmConfigure.h>
+#include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmStandardIncludes.h"
+#include <string>
 
 /** \class cmPathLabel
  * \brief Helper class for text based labels
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index f0373a1..8afd532 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -13,7 +13,6 @@
 #include "cmSourceFile.h"
 #include "cmSourceFileLocation.h"
 #include "cmState.h"
-#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 #include "cmake.h"
@@ -27,7 +26,6 @@
 #include <cmConfigure.h>
 #include <cmsys/FStream.hxx>
 #include <cmsys/RegularExpression.hxx>
-#include <iostream>
 #include <map>
 #include <set>
 #include <sstream>
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index f56f575..499da3a 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -2,18 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmQtAutoGenerators.h"
 
-#include "cmAlgorithms.h"
-#include "cmFilePathUuid.h"
-#include "cmGlobalGenerator.h"
-#include "cmMakefile.h"
-#include "cmOutputConverter.h"
-#include "cmState.h"
-#include "cmStateDirectory.h"
-#include "cmStateTypes.h"
-#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
-
 #include <algorithm>
 #include <assert.h>
 #include <cmConfigure.h>
@@ -26,6 +14,17 @@
 #include <string.h>
 #include <utility>
 
+#include "cmAlgorithms.h"
+#include "cmFilePathUuid.h"
+#include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
+#include "cmOutputConverter.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmSystemTools.h"
+#include "cm_auto_ptr.hxx"
+#include "cmake.h"
+
 #if defined(__APPLE__)
 #include <unistd.h>
 #endif
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx
index 75ac54d..f190a5c 100644
--- a/Source/cmRulePlaceholderExpander.cxx
+++ b/Source/cmRulePlaceholderExpander.cxx
@@ -2,6 +2,10 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmRulePlaceholderExpander.h"
 
+#include <ctype.h>
+#include <string.h>
+#include <utility>
+
 #include "cmOutputConverter.h"
 #include "cmSystemTools.h"
 
diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h
index 444419c..5223ae9 100644
--- a/Source/cmRulePlaceholderExpander.h
+++ b/Source/cmRulePlaceholderExpander.h
@@ -9,7 +9,6 @@
 #include <map>
 #include <string>
 
-class cmGeneratorTarget;
 class cmOutputConverter;
 
 class cmRulePlaceholderExpander
diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx
index ff0b836..0df6e0c 100644
--- a/Source/cmSearchPath.cxx
+++ b/Source/cmSearchPath.cxx
@@ -2,7 +2,9 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmSearchPath.h"
 
+#include <algorithm>
 #include <cassert>
+#include <utility>
 
 #include "cmAlgorithms.h"
 #include "cmFindCommon.h"
diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h
index 80815ed..9ffa871 100644
--- a/Source/cmSearchPath.h
+++ b/Source/cmSearchPath.h
@@ -5,7 +5,9 @@
 
 #include <cmConfigure.h>
 
-#include "cmStandardIncludes.h"
+#include <set>
+#include <string>
+#include <vector>
 
 class cmFindCommon;
 
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 51a363f..5a71dc0 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -14,6 +14,7 @@
 #include "cm_jsoncpp_value.h"
 #endif
 
+#include <algorithm>
 #include <fstream>
 #include <iostream>
 #include <memory>
diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx
index b4af52b..008052b 100644
--- a/Source/cmServerConnection.cxx
+++ b/Source/cmServerConnection.cxx
@@ -8,6 +8,7 @@
 #include "cmServer.h"
 
 #include <assert.h>
+#include <string.h>
 
 namespace {
 
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index e49f142..820e7f6 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmSetCommand.h"
 
-#include <algorithm>
 #include <string.h>
 
 #include "cmAlgorithms.h"
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 6f29b18..5c4f18b 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -2,17 +2,16 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmSourceFile.h"
 
+#include <sstream>
+
 #include "cmCustomCommand.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmProperty.h"
 #include "cmState.h"
-#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmake.h"
 
-#include <sstream>
-
 cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name)
   : Location(mf, name)
 {
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index db1e542..6e934e2 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -2,24 +2,22 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmState.h"
 
-#include "cmStatePrivate.h"
+#include <algorithm>
+#include <assert.h>
+#include <cmsys/RegularExpression.hxx>
+#include <string.h>
+#include <utility>
 
 #include "cmAlgorithms.h"
 #include "cmCacheManager.h"
 #include "cmCommand.h"
 #include "cmDefinitions.h"
 #include "cmListFileCache.h"
+#include "cmStatePrivate.h"
+#include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
 #include "cmake.h"
 
-#include <algorithm>
-#include <assert.h>
-#include <cmsys/RegularExpression.hxx>
-#include <iterator>
-#include <stdio.h>
-#include <string.h>
-#include <utility>
-
 cmState::cmState()
   : IsInTryCompile(false)
   , WindowsShell(false)
diff --git a/Source/cmState.h b/Source/cmState.h
index 6d74815..41ffcdc 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -5,25 +5,22 @@
 
 #include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmAlgorithms.h"
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
 #include "cmDefinitions.h"
 #include "cmLinkedTree.h"
 #include "cmProperty.h"
 #include "cmPropertyDefinitionMap.h"
 #include "cmPropertyMap.h"
+#include "cmStatePrivate.h"
 #include "cmStateTypes.h"
 
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-
 class cmCacheManager;
 class cmCommand;
-class cmListFileBacktrace;
 class cmPropertyDefinition;
-
-class cmStateDirectory;
 class cmStateSnapshot;
 
 class cmState
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx
index 01e1e7e..46a1858 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -2,8 +2,18 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 
 #include "cmStateDirectory.h"
+
+#include <algorithm>
+#include <assert.h>
+#include <iterator>
+#include <map>
+#include <utility>
+
+#include "cmProperty.h"
+#include "cmPropertyMap.h"
 #include "cmState.h"
 #include "cmStatePrivate.h"
+#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 
 static std::string const kBINARY_DIR = "BINARY_DIR";
diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h
index 17a89d8..8accc8e 100644
--- a/Source/cmStateDirectory.h
+++ b/Source/cmStateDirectory.h
@@ -10,9 +10,10 @@
 #include <vector>
 
 #include "cmAlgorithms.h"
+#include "cmLinkedTree.h"
 #include "cmListFileCache.h"
+#include "cmStatePrivate.h"
 #include "cmStateSnapshot.h"
-#include "cmStateTypes.h"
 
 class cmStateDirectory
 {
diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h
index 8daa3cf..20700f2 100644
--- a/Source/cmStatePrivate.h
+++ b/Source/cmStatePrivate.h
@@ -12,9 +12,16 @@
 #include "cmDefinitions.h"
 #include "cmLinkedTree.h"
 #include "cmListFileCache.h"
+#include "cmPolicies.h"
 #include "cmPropertyMap.h"
+#include "cmStateSnapshot.h"
 #include "cmStateTypes.h"
 
+namespace cmStateDetail {
+struct BuildsystemDirectoryStateType;
+struct PolicyStackEntry;
+} // namespace cmStateDetail
+
 static const std::string cmPropertySentinal = std::string();
 
 struct cmStateDetail::SnapshotDataType
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index 7f86221..c6288a5 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -3,13 +3,25 @@
 
 #include "cmStateSnapshot.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <iterator>
+#include <stdio.h>
+
+#include "cmAlgorithms.h"
+#include "cmDefinitions.h"
+#include "cmListFileCache.h"
+#include "cmPropertyMap.h"
 #include "cmState.h"
 #include "cmStateDirectory.h"
 #include "cmStatePrivate.h"
-#include "cmSystemTools.h"
 #include "cmVersion.h"
 #include "cmake.h"
 
+#if defined(__CYGWIN__)
+#include "cmSystemTools.h"
+#endif
+
 cmStateSnapshot::cmStateSnapshot(cmState* state)
   : State(state)
   , Position()
diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h
index 63b581d..72d0349 100644
--- a/Source/cmStateSnapshot.h
+++ b/Source/cmStateSnapshot.h
@@ -6,10 +6,10 @@
 
 #include <cmConfigure.h> // IWYU pragma: keep
 
-#include <map>
 #include <string>
 #include <vector>
 
+#include "cmLinkedTree.h"
 #include "cmPolicies.h"
 #include "cmStateTypes.h"
 
diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h
index 75f9e60..2c974c1 100644
--- a/Source/cmStateTypes.h
+++ b/Source/cmStateTypes.h
@@ -4,12 +4,12 @@
 #ifndef cmStateTypes_h
 #define cmStateTypes_h
 
+#include <cmConfigure.h> // IWYU pragma: keep
+
 #include "cmLinkedTree.h"
 
 namespace cmStateDetail {
-struct BuildsystemDirectoryStateType;
 struct SnapshotDataType;
-struct PolicyStackEntry;
 typedef cmLinkedTree<cmStateDetail::SnapshotDataType>::iterator PositionType;
 }
 
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 512bc91..f835445 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmStringCommand.h"
 
-#include <algorithm>
 #include <cmsys/RegularExpression.hxx>
 #include <ctype.h>
 #include <sstream>
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 9817a3c..0801f26 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -11,6 +11,12 @@
 #include <string>
 #include <vector>
 
+#if defined(_MSC_VER)
+typedef unsigned short mode_t;
+#else
+#include <sys/types.h>
+#endif
+
 class cmSystemToolsFileTime;
 
 /** \class cmSystemTools
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 25ae339..dabdda5 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2,6 +2,14 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmTarget.h"
 
+#include <algorithm>
+#include <assert.h>
+#include <cmsys/RegularExpression.hxx>
+#include <map>
+#include <set>
+#include <sstream>
+#include <string.h>
+
 #include "cmAlgorithms.h"
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
@@ -14,19 +22,13 @@
 #include "cmSourceFile.h"
 #include "cmSourceFileLocation.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
 #include "cmTargetPropertyComputer.h"
 #include "cm_unordered_set.hxx"
 #include "cmake.h"
 
-#include <algorithm>
-#include <assert.h>
-#include <cmsys/RegularExpression.hxx>
-#include <map>
-#include <set>
-#include <sstream>
-#include <string.h>
-
 template <>
 const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>(
   cmTarget const* tgt)
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 1f035a1..57ef8d2 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -5,6 +5,13 @@
 
 #include <cmConfigure.h> // IWYU pragma: keep
 
+#include <iosfwd>
+#include <map>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
+
 #include "cmAlgorithms.h"
 #include "cmCustomCommand.h"
 #include "cmListFileCache.h"
@@ -14,16 +21,10 @@
 #include "cmTargetLinkLibraryType.h"
 #include "cm_unordered_map.hxx"
 
-#include <iosfwd>
-#include <map>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
+class cmGlobalGenerator;
 class cmMakefile;
+class cmMessenger;
 class cmSourceFile;
-class cmGlobalGenerator;
 class cmTargetInternals;
 
 class cmTargetInternalPointer
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index a1c9b82..1b6c008 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmTargetCompileFeaturesCommand.h"
 
-#include <algorithm>
 #include <sstream>
 
 #include "cmAlgorithms.h"
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
index a4db55b..1b4056d 100644
--- a/Source/cmTargetCompileOptionsCommand.cxx
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmTargetCompileOptionsCommand.h"
 
-#include <algorithm>
 #include <sstream>
 
 #include "cmAlgorithms.h"
diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h
index acea6ea..a953efb 100644
--- a/Source/cmTargetDepend.h
+++ b/Source/cmTargetDepend.h
@@ -3,9 +3,9 @@
 #ifndef cmTargetDepend_h
 #define cmTargetDepend_h
 
-#include <cmConfigure.h>
+#include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmStandardIncludes.h"
+#include <set>
 
 class cmGeneratorTarget;
 
diff --git a/Source/cmTargetExport.h b/Source/cmTargetExport.h
index 634148b..b08ede2 100644
--- a/Source/cmTargetExport.h
+++ b/Source/cmTargetExport.h
@@ -3,13 +3,13 @@
 #ifndef cmTargetExport_h
 #define cmTargetExport_h
 
-#include <cmConfigure.h>
+#include <cmConfigure.h> // IWYU pragma: keep
 
-#include "cmStandardIncludes.h"
+#include <string>
 
 class cmGeneratorTarget;
-class cmInstallTargetGenerator;
 class cmInstallFilesGenerator;
+class cmInstallTargetGenerator;
 
 /** \brief A member of an ExportSet
  *
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 7aba0f8..9a5c1da 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -4,6 +4,9 @@
 
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
+#include "cmStateTypes.h"
+#include "cmTarget.h"
+#include "cmake.h"
 
 bool cmTargetPropCommandBase::HandleArguments(
   std::vector<std::string> const& args, const std::string& prop,
diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h
index 485a7f3..8b49653 100644
--- a/Source/cmTargetPropCommandBase.h
+++ b/Source/cmTargetPropCommandBase.h
@@ -3,6 +3,11 @@
 #ifndef cmTargetPropCommandBase_h
 #define cmTargetPropCommandBase_h
 
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
 #include "cmCommand.h"
 
 class cmTarget;
diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx
index 7cf1fd8..04931af 100644
--- a/Source/cmTargetPropertyComputer.cxx
+++ b/Source/cmTargetPropertyComputer.cxx
@@ -3,14 +3,13 @@
 
 #include "cmTargetPropertyComputer.h"
 
-#include "cmGeneratorTarget.h"
-#include "cmGlobalGenerator.h"
-#include "cmMakefile.h"
+#include <sstream>
+
 #include "cmMessenger.h"
-#include "cmSourceFile.h"
-#include "cmSourceFileLocation.h"
-#include "cmTarget.h"
+#include "cmPolicies.h"
+#include "cmStateSnapshot.h"
 #include "cm_unordered_set.hxx"
+#include "cmake.h"
 
 bool cmTargetPropertyComputer::HandleLocationPropertyPolicy(
   std::string const& tgtName, cmMessenger* messenger,
diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h
index 7989589..45d31be 100644
--- a/Source/cmTargetPropertyComputer.h
+++ b/Source/cmTargetPropertyComputer.h
@@ -5,14 +5,13 @@
 
 #include <cmConfigure.h> // IWYU pragma: keep
 
+#include <string>
+
 #include "cmAlgorithms.h"
 #include "cmListFileCache.h"
+#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 
-#include <map>
-#include <string>
-
-class cmTarget;
 class cmMessenger;
 
 class cmTargetPropertyComputer
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index 13c9a8f..058659a 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmTargetSourcesCommand.h"
 
-#include <algorithm>
 #include <sstream>
 
 #include "cmAlgorithms.h"
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 1c36dc6..4d0cbaa 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -5,7 +5,6 @@
 #include "cmMakefile.h"
 #include "cmProperty.h"
 #include "cmState.h"
-#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 
 cmTest::cmTest(cmMakefile* mf)
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index 843f7b1..4164f3a 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -2,6 +2,10 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmTestGenerator.h"
 
+#include <map>
+#include <ostream>
+#include <utility>
+
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
 #include "cmLocalGenerator.h"
@@ -11,11 +15,6 @@
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmTest.h"
-#include "cm_auto_ptr.hxx"
-
-#include <map>
-#include <ostream>
-#include <utility>
 
 cmTestGenerator::cmTestGenerator(
   cmTest* test, std::vector<std::string> const& configurations)
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 9597e09..589f195 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -2,15 +2,11 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmTimestamp.h"
 
-#include "cmSystemTools.h"
-
-#include <cstdlib>
+#include <cmConfigure.h>
 #include <cstring>
 #include <sstream>
 
-#include <sys/types.h>
-// include sys/stat.h after sys/types.h
-#include <sys/stat.h>
+#include "cmSystemTools.h"
 
 std::string cmTimestamp::CurrentTime(const std::string& formatString,
                                      bool utcFlag)
diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h
index 44e397b..fdee564 100644
--- a/Source/cmTimestamp.h
+++ b/Source/cmTimestamp.h
@@ -3,9 +3,7 @@
 #ifndef cmTimestamp_h
 #define cmTimestamp_h
 
-#include <cmConfigure.h>
-
-#include "cmStandardIncludes.h"
+#include <cmConfigure.h> // IWYU pragma: keep
 
 #include <string>
 #include <time.h>
diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx
index 5f16bd8..fcd9954 100644
--- a/Source/cm_codecvt.hxx
+++ b/Source/cm_codecvt.hxx
@@ -3,10 +3,11 @@
 #ifndef cm_codecvt_hxx
 #define cm_codecvt_hxx
 
-#include <cmConfigure.h> // IWYU pragma: keep
+#include <cmConfigure.h>
 
 #include <locale>
 #include <vector>
+#include <wchar.h>
 
 class codecvt : public std::codecvt<char, char, mbstate_t>
 {
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index eb76ca0..6c066c6 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -17,6 +17,7 @@
 #include "cmMakefile.h"
 #include "cmMessenger.h"
 #include "cmState.h"
+#include "cmStateDirectory.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 #include "cmTargetLinkLibraryType.h"
@@ -25,11 +26,11 @@
 #include "cm_auto_ptr.hxx"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
+#include <cm_jsoncpp_writer.h>
+
 #include "cmGraphVizWriter.h"
 #include "cmVariableWatch.h"
 #include "cm_unordered_map.hxx"
-
-#include <cm_jsoncpp_writer.h>
 #endif
 
 // only build kdevelop generator on non-windows platforms
diff --git a/Source/cmake.h b/Source/cmake.h
index 6e8d9c8..0f1891d 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -5,17 +5,18 @@
 
 #include <cmConfigure.h>
 
-#include "cmInstalledFile.h"
-#include "cmListFileCache.h"
-#include "cmStateSnapshot.h"
-
 #include <map>
 #include <set>
 #include <string>
 #include <vector>
 
+#include "cmInstalledFile.h"
+#include "cmListFileCache.h"
+#include "cmStateSnapshot.h"
+#include "cmStateTypes.h"
+
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cm_jsoncpp_value.h"
+#include <cm_jsoncpp_value.h>
 #endif
 
 class cmExternalMakefileProjectGeneratorFactory;
@@ -24,6 +25,7 @@ class cmGlobalGenerator;
 class cmGlobalGeneratorFactory;
 class cmMakefile;
 class cmMessenger;
+class cmState;
 class cmVariableWatch;
 struct cmDocumentationEntry;
 
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 44af966..a974061 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -12,6 +12,7 @@
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmState.h"
+#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmake.h"
 #include "cmcmd.h"
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index c008791..1db147a 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -8,6 +8,7 @@
 #include "cmMakefile.h"
 #include "cmQtAutoGenerators.h"
 #include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
 #include "cmUtils.hxx"
 #include "cmVersion.h"
-- 
cgit v0.12