Explorar el Código

fix include order of windows.h

Comments that indicate a special include order is necessary because
GetCurrentDirectory might get redefined are outdated.  Remove those
outdated comments and use the normal ordering of includes.
Daniel Pfeifer hace 8 años
padre
commit
4b49c9a245

+ 0 - 1
Source/cmExportCommand.cxx

@@ -279,7 +279,6 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include <windows.h>
 
-#undef GetCurrentDirectory
 void cmExportCommand::ReportRegistryError(std::string const& msg,
                                           std::string const& key, long err)
 {

+ 0 - 1
Source/cmFindPackageCommand.cxx

@@ -1173,7 +1173,6 @@ void cmFindPackageCommand::FillPrefixesSystemRegistry()
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include <windows.h>
-#undef GetCurrentDirectory
 // http://msdn.microsoft.com/en-us/library/aa384253%28v=vs.85%29.aspx
 #if !defined(KEY_WOW64_32KEY)
 #define KEY_WOW64_32KEY 0x0200

+ 8 - 7
Source/cmGlobalGenerator.cxx

@@ -1,12 +1,5 @@
 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
    file Copyright.txt or https://cmake.org/licensing for details.  */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include "windows.h" // this must be first to define GetCurrentDirectory
-#if defined(_MSC_VER) && _MSC_VER >= 1800
-#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#endif
-#endif
-
 #include "cmGlobalGenerator.h"
 
 #include <algorithm>
@@ -19,6 +12,10 @@
 #include <stdlib.h>
 #include <string.h>
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <windows.h>
+#endif
+
 #include "cmAlgorithms.h"
 #include "cmCPackPropertiesGenerator.h"
 #include "cmComputeTargetDepends.h"
@@ -51,6 +48,10 @@
 #include <cm_jsoncpp_writer.h>
 #endif
 
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+#endif
+
 const std::string kCMAKE_PLATFORM_INFO_INITIALIZED =
   "CMAKE_PLATFORM_INFO_INITIALIZED";
 

+ 1 - 2
Source/cmGlobalVisualStudio7Generator.cxx

@@ -1,7 +1,5 @@
 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
    file Copyright.txt or https://cmake.org/licensing for details.  */
-#include "windows.h" // this must be first to define GetCurrentDirectory
-
 #include "cmGlobalVisualStudio7Generator.h"
 
 #include "cmGeneratedFileStream.h"
@@ -14,6 +12,7 @@
 #include <cmsys/Encoding.hxx>
 
 #include <assert.h>
+#include <windows.h>
 
 static cmVS7FlagTable cmVS7ExtraFlagTable[] = {
   // Precompiled header and related options.  Note that the

+ 1 - 2
Source/cmGlobalVisualStudioGenerator.cxx

@@ -5,6 +5,7 @@
 
 #include <cmsys/Encoding.hxx>
 #include <iostream>
+#include <windows.h>
 
 #include "cmAlgorithms.h"
 #include "cmCallVisualStudioMacro.h"
@@ -441,8 +442,6 @@ std::string cmGlobalVisualStudioGenerator::GetStartupProjectName(
   return this->GetAllTargetName();
 }
 
-#include <windows.h>
-
 bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
                                         const std::string& regKeyBase,
                                         std::string& nextAvailableSubKeyName)

+ 1 - 1
Source/cmLocalVisualStudio7Generator.cxx

@@ -16,6 +16,7 @@
 #include "cmGeneratedFileStream.h"
 
 #include <ctype.h> // for isspace
+#include <windows.h>
 
 static bool cmLVS7G_IsFAT(const char* dir);
 
@@ -2115,7 +2116,6 @@ std::string cmLocalVisualStudio7Generator::GetTargetDirectory(
   return dir;
 }
 
-#include <windows.h>
 static bool cmLVS7G_IsFAT(const char* dir)
 {
   if (dir[0] && dir[1] == ':') {

+ 6 - 7
Source/cmakemain.cxx

@@ -1,11 +1,6 @@
 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
    file Copyright.txt or https://cmake.org/licensing for details.  */
-// include these first, otherwise there will be problems on Windows
-// with GetCurrentDirectory() being redefined
-#ifdef CMAKE_BUILD_WITH_CMAKE
-#include "cmDocumentation.h"
-#include "cmDynamicLoader.h"
-#endif
+#include <cmConfigure.h>
 
 #include "cmAlgorithms.h"
 #include "cmDocumentationEntry.h"
@@ -17,7 +12,11 @@
 #include "cmake.h"
 #include "cmcmd.h"
 
-#include <cmConfigure.h>
+#ifdef CMAKE_BUILD_WITH_CMAKE
+#include "cmDocumentation.h"
+#include "cmDynamicLoader.h"
+#endif
+
 #include <cmsys/Encoding.hxx>
 #if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
 #include <cmsys/ConsoleBuf.hxx>