1
0
Эх сурвалжийг харах

ENH: add the unix makefile generator as an option from the windows GUI, this builds with mingw, cygwin, and combinations of make cl, bcc32

Bill Hoffman 22 жил өмнө
parent
commit
a413160fec

+ 10 - 0
Modules/CMakeCCompiler.cmake.in

@@ -3,4 +3,14 @@ SET(CMAKE_AR "@CMAKE_AR@")
 SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
 SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
 SET(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@)
 SET(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@)
 SET(CMAKE_C_COMPILER_LOADED 1)
 SET(CMAKE_C_COMPILER_LOADED 1)
+SET(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@)
+SET(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@)
+IF(CMAKE_COMPILER_IS_CYGWIN)
+  SET(CYGWIN 1)
+  SET(UNIX 1)
+ENDIF(CMAKE_COMPILER_IS_CYGWIN)
+
+IF(CMAKE_COMPILER_IS_MINGW)
+  SET(MINGW 1)
+ENDIF(CMAKE_COMPILER_IS_MINGW)
 
 

+ 7 - 0
Modules/CMakeDetermineCCompiler.cmake

@@ -59,6 +59,13 @@ IF(NOT CMAKE_COMPILER_RETURN)
       "Determining if the C compiler is GNU failed with "
       "Determining if the C compiler is GNU failed with "
       "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
       "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
   ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
   ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
+  IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" )
+    SET(CMAKE_COMPILER_IS_MINGW 1)
+  ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" )
+  IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" )
+    SET(CMAKE_COMPILER_IS_CYGWIN 1)
+  ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" )
+
 ENDIF(NOT CMAKE_COMPILER_RETURN)
 ENDIF(NOT CMAKE_COMPILER_RETURN)
 
 
 
 

+ 2 - 2
Modules/CMakeSystemSpecificInformation.cmake

@@ -57,9 +57,9 @@ ENDIF(EXISTS ${CMAKE_SYSTEM_INFO_FILE})
 IF(CMAKE_C_COMPILER)
 IF(CMAKE_C_COMPILER)
   GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_C_COMPILER} NAME_WE)
   GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_C_COMPILER} NAME_WE)
   # since the gnu compiler has several names force gcc
   # since the gnu compiler has several names force gcc
-  IF(CMAKE_COMPILER_IS_GNUGCC)
+  IF(CMAKE_COMPILER_IS_GNUCC)
      SET(CMAKE_BASE_NAME gcc)
      SET(CMAKE_BASE_NAME gcc)
-  ENDIF(CMAKE_COMPILER_IS_GNUGCC)
+  ENDIF(CMAKE_COMPILER_IS_GNUCC)
   SET(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE 
   SET(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE 
       ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
       ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
   INCLUDE(${CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE} OPTIONAL)
   INCLUDE(${CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE} OPTIONAL)

+ 1 - 1
Modules/CMakeTestCCompiler.cmake

@@ -1,6 +1,6 @@
 # This file is used by EnableLanguage in cmGlobalGenerator to
 # This file is used by EnableLanguage in cmGlobalGenerator to
 # determine that that selected C compiler can actually compile
 # determine that that selected C compiler can actually compile
-# and like the most basic of programs.   If not, a fatel error
+# and link the most basic of programs.   If not, a fatel error
 # is set and cmake stops processing commands and will not generate
 # is set and cmake stops processing commands and will not generate
 # any makefiles or projects.
 # any makefiles or projects.
 IF(NOT CMAKE_C_COMPILER_WORKS)
 IF(NOT CMAKE_C_COMPILER_WORKS)

+ 1 - 1
Modules/CMakeTestCXXCompiler.cmake

@@ -1,6 +1,6 @@
 # This file is used by EnableLanguage in cmGlobalGenerator to
 # This file is used by EnableLanguage in cmGlobalGenerator to
 # determine that that selected C++ compiler can actually compile
 # determine that that selected C++ compiler can actually compile
-# and like the most basic of programs.   If not, a fatel error
+# and link the most basic of programs.   If not, a fatel error
 # is set and cmake stops processing commands and will not generate
 # is set and cmake stops processing commands and will not generate
 # any makefiles or projects.
 # any makefiles or projects.
 IF(NOT CMAKE_CXX_COMPILER_WORKS)
 IF(NOT CMAKE_CXX_COMPILER_WORKS)

+ 6 - 0
Modules/CMakeTestGNU.c

@@ -1,3 +1,9 @@
 #ifdef __GNUC__
 #ifdef __GNUC__
 void THIS_IS_GNU();
 void THIS_IS_GNU();
 #endif
 #endif
+#ifdef __MINGW32__
+void THIS_IS_MINGW();
+#endif
+#ifdef __CYGWIN__
+void THIS_IS_CYGWIN();
+#endif

+ 1 - 2
Modules/Platform/Windows-bcc32.cmake

@@ -14,9 +14,8 @@ SET(CMAKE_LIBRARY_PATH_FLAG "-L")
 SET(CMAKE_LINK_LIBRARY_FLAG "")
 SET(CMAKE_LINK_LIBRARY_FLAG "")
 SET(CMAKE_SHARED_BUILD_CXX_FLAGS "-tWR")
 SET(CMAKE_SHARED_BUILD_CXX_FLAGS "-tWR")
 SET(CMAKE_SHARED_BUILD_C_FLAGS "-tWR")
 SET(CMAKE_SHARED_BUILD_C_FLAGS "-tWR")
+SET(BORLAND 1)
 
 
-SET(CMAKE_START_TEMP_FILE "@&&|\n")
-SET(CMAKE_END_TEMP_FILE "\n|")
 # uncomment these out to debug makefiles
 # uncomment these out to debug makefiles
 #SET(CMAKE_START_TEMP_FILE "")
 #SET(CMAKE_START_TEMP_FILE "")
 #SET(CMAKE_END_TEMP_FILE "")
 #SET(CMAKE_END_TEMP_FILE "")

+ 1 - 8
Modules/Platform/Windows-cl.cmake

@@ -1,13 +1,6 @@
 SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:")
 SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:")
 SET(CMAKE_LINK_LIBRARY_FLAG "")
 SET(CMAKE_LINK_LIBRARY_FLAG "")
-
-SET(CMAKE_START_TEMP_FILE "@<<\n")
-SET(CMAKE_END_TEMP_FILE "\n<<")
-# uncomment these out to debug makefiles
-#SET(CMAKE_START_TEMP_FILE "")
-#SET(CMAKE_END_TEMP_FILE "")
-#SET(CMAKE_VERBOSE_MAKEFILE 1)
-
+SET(WIN32 1)
 # create a shared C++ library
 # create a shared C++ library
 SET(CMAKE_CXX_CREATE_SHARED_LIBRARY 
 SET(CMAKE_CXX_CREATE_SHARED_LIBRARY 
  "link /nologo ${CMAKE_START_TEMP_FILE}  /out:<TARGET> /dll  <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
  "link /nologo ${CMAKE_START_TEMP_FILE}  /out:<TARGET> /dll  <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")

+ 22 - 0
Modules/Platform/Windows.cmake

@@ -4,3 +4,25 @@ SET(CMAKE_SHARED_LIBRARY_PREFIX "")          # lib
 SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")          # .so
 SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")          # .so
 SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib")
 SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib")
 SET(CMAKE_DL_LIBS "")
 SET(CMAKE_DL_LIBS "")
+
+# for borland make long command lines are redirected to a file
+# with the following syntax, see Windows-bcc32.cmake for use
+IF(CMAKE_GENERATOR MATCHES "Borland")
+  SET(CMAKE_START_TEMP_FILE "@&&|\n")
+  SET(CMAKE_END_TEMP_FILE "\n|")
+ENDIF(CMAKE_GENERATOR MATCHES "Borland")
+
+# for nmake make long command lines are redirected to a file
+# with the following syntax, see Windows-bcc32.cmake for use
+IF(CMAKE_GENERATOR MATCHES "NMake")
+  SET(CMAKE_START_TEMP_FILE "@<<\n")
+  SET(CMAKE_END_TEMP_FILE "\n<<")
+ENDIF(CMAKE_GENERATOR MATCHES "NMake")
+
+# uncomment these out to debug nmake and borland makefiles
+#SET(CMAKE_START_TEMP_FILE "")
+#SET(CMAKE_END_TEMP_FILE "")
+#SET(CMAKE_VERBOSE_MAKEFILE 1)
+
+  
+

+ 25 - 20
Source/CMakeLists.txt

@@ -65,22 +65,25 @@ ENDIF (APPLE)
 IF (WIN32)
 IF (WIN32)
   IF(NOT UNIX)
   IF(NOT UNIX)
     SET(SRCS ${SRCS}
     SET(SRCS ${SRCS}
-                    cmGlobalBorlandMakefileGenerator.cxx
-                    cmGlobalNMakeMakefileGenerator.cxx
-                    cmGlobalVisualStudio6Generator.cxx
-                    cmLocalVisualStudio6Generator.cxx
-                    cmGlobalVisualStudio71Generator.cxx
-                    cmGlobalVisualStudio7Generator.cxx
-                    cmLocalVisualStudio7Generator.cxx
-                    cmGlobalBorlandMakefileGenerator.h
-                    cmGlobalNMakeMakefileGenerator.h
-                    cmGlobalVisualStudio6Generator.h
-                    cmLocalVisualStudio6Generator.h
-                    cmGlobalVisualStudio7Generator.h
-                    cmLocalVisualStudio7Generator.h
-		    cmWin32ProcessExecution.cxx
-		    cmWin32ProcessExecution.h
-                    )
+      cmGlobalBorlandMakefileGenerator.cxx
+      cmGlobalNMakeMakefileGenerator.cxx
+      cmGlobalVisualStudio6Generator.cxx
+      cmLocalVisualStudio6Generator.cxx
+      cmGlobalBorlandMakefileGenerator.h
+      cmGlobalNMakeMakefileGenerator.h
+      cmGlobalVisualStudio6Generator.h
+      cmLocalVisualStudio6Generator.h
+      cmWin32ProcessExecution.cxx
+      cmWin32ProcessExecution.h
+      )
+    IF(NOT MINGW)
+      SET(SRCS ${SRCS}
+        cmGlobalVisualStudio7Generator.h
+        cmLocalVisualStudio7Generator.h
+        cmGlobalVisualStudio71Generator.cxx
+        cmGlobalVisualStudio7Generator.cxx
+        cmLocalVisualStudio7Generator.cxx)
+    ENDIF(NOT MINGW)
   ENDIF(NOT UNIX)
   ENDIF(NOT UNIX)
 ENDIF (WIN32)
 ENDIF (WIN32)
 
 
@@ -95,10 +98,12 @@ LINK_DIRECTORIES(${CMake_BINARY_DIR}/Source)
 IF (WIN32)
 IF (WIN32)
   IF(NOT UNIX)
   IF(NOT UNIX)
     IF( NOT BORLAND )
     IF( NOT BORLAND )
-      LINK_LIBRARIES( rpcrt4.lib )
-      ADD_EXECUTABLE(cmw9xcom cmw9xcom.cxx)
-      TARGET_LINK_LIBRARIES(cmw9xcom CMakeLib)
-      SUBDIRS(MFCDialog)
+      IF(NOT MINGW )
+        LINK_LIBRARIES( rpcrt4.lib )
+        ADD_EXECUTABLE(cmw9xcom cmw9xcom.cxx)
+        TARGET_LINK_LIBRARIES(cmw9xcom CMakeLib)
+        SUBDIRS(MFCDialog)
+      ENDIF(NOT MINGW )
     ENDIF( NOT BORLAND )
     ENDIF( NOT BORLAND )
   ENDIF(NOT UNIX)
   ENDIF(NOT UNIX)
 ENDIF (WIN32)
 ENDIF (WIN32)

+ 1 - 1
Source/CTest/Curl/telnet.c

@@ -1105,7 +1105,7 @@ CURLcode Curl_telnet(struct connectdata *conn)
         ssize_t bytes_written;
         ssize_t bytes_written;
         char *buffer = buf;
         char *buffer = buf;
               
               
-        if(!ReadFile(stdin_handle, buf, 255, &(DWORD)nread, NULL)) {
+        if(!ReadFile(stdin_handle, buf, 255, ((DWORD*)&nread), NULL)) {
           keepon = FALSE;
           keepon = FALSE;
           break;
           break;
         }
         }

+ 1 - 1
Source/cmDynamicLoader.cxx

@@ -266,7 +266,7 @@ cmDynamicLoader::GetSymbolAddress(cmLibHandle lib, const char* sym)
   delete [] wsym;
   delete [] wsym;
   void* result = ret;
   void* result = ret;
 #else
 #else
-  void* result = GetProcAddress(lib, sym);
+  void* result = (void*)GetProcAddress(lib, sym);
 #endif
 #endif
   // Hack to cast pointer-to-data to pointer-to-function.
   // Hack to cast pointer-to-data to pointer-to-function.
   return *reinterpret_cast<cmDynamicLoaderFunction*>(&result);
   return *reinterpret_cast<cmDynamicLoaderFunction*>(&result);

+ 1 - 0
Source/cmGlobalBorlandMakefileGenerator.cxx

@@ -21,6 +21,7 @@
 cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator()
 cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator()
 {
 {
   m_FindMakeProgramFile = "CMakeBorlandFindMake.cmake";
   m_FindMakeProgramFile = "CMakeBorlandFindMake.cmake";
+  m_ForceUnixPaths = false;
 }
 }
 
 
 void cmGlobalBorlandMakefileGenerator::EnableLanguage(const char* l,
 void cmGlobalBorlandMakefileGenerator::EnableLanguage(const char* l,

+ 2 - 1
Source/cmGlobalGenerator.cxx

@@ -28,7 +28,8 @@ int cmGlobalGenerator::s_TryCompileTimeout = 0;
 
 
 cmGlobalGenerator::cmGlobalGenerator()
 cmGlobalGenerator::cmGlobalGenerator()
 {
 {
-// do nothing duh
+  // by default use the native paths
+  m_ForceUnixPaths = false;
 }
 }
 
 
 cmGlobalGenerator::~cmGlobalGenerator()
 cmGlobalGenerator::~cmGlobalGenerator()

+ 2 - 0
Source/cmGlobalGenerator.h

@@ -104,7 +104,9 @@ public:
   void GetLocalGenerators(std::vector<cmLocalGenerator *>&g) { g = m_LocalGenerators;}
   void GetLocalGenerators(std::vector<cmLocalGenerator *>&g) { g = m_LocalGenerators;}
   static int s_TryCompileTimeout;
   static int s_TryCompileTimeout;
   
   
+  bool GetForceUnixPaths() {return m_ForceUnixPaths;}
 protected:
 protected:
+  bool m_ForceUnixPaths;
   cmStdString m_FindMakeProgramFile;
   cmStdString m_FindMakeProgramFile;
   cmStdString m_ConfiguredFilesPath;
   cmStdString m_ConfiguredFilesPath;
   cmake *m_CMakeInstance;
   cmake *m_CMakeInstance;

+ 1 - 0
Source/cmGlobalNMakeMakefileGenerator.cxx

@@ -22,6 +22,7 @@
 cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator()
 cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator()
 {
 {
   m_FindMakeProgramFile = "CMakeNMakeFindMake.cmake";
   m_FindMakeProgramFile = "CMakeNMakeFindMake.cmake";
+  m_ForceUnixPaths = false;
 }
 }
 
 
 void cmGlobalNMakeMakefileGenerator::EnableLanguage(const char* l,
 void cmGlobalNMakeMakefileGenerator::EnableLanguage(const char* l,

+ 2 - 0
Source/cmGlobalUnixMakefileGenerator.cxx

@@ -22,6 +22,8 @@
 
 
 cmGlobalUnixMakefileGenerator::cmGlobalUnixMakefileGenerator()
 cmGlobalUnixMakefileGenerator::cmGlobalUnixMakefileGenerator()
 {
 {
+  // This type of makefile always requires unix style paths
+  m_ForceUnixPaths = true;
   m_FindMakeProgramFile = "CMakeUnixFindMake.cmake";
   m_FindMakeProgramFile = "CMakeUnixFindMake.cmake";
 }
 }
 
 

+ 1 - 1
Source/cmLocalUnixMakefileGenerator.cxx

@@ -2117,7 +2117,7 @@ cmLocalUnixMakefileGenerator::ConvertToOutputForExisting(const char* p)
       {
       {
       if(!cmSystemTools::GetShortPath(ret.c_str(), ret))
       if(!cmSystemTools::GetShortPath(ret.c_str(), ret))
         {
         {
-        ret = p;
+        ret = cmSystemTools::ConvertToOutputPath(p);
         }
         }
       }
       }
     }
     }

+ 15 - 0
Source/cmSystemTools.cxx

@@ -48,6 +48,7 @@ bool cmSystemTools::s_DisableRunCommandOutput = false;
 bool cmSystemTools::s_ErrorOccured = false;
 bool cmSystemTools::s_ErrorOccured = false;
 bool cmSystemTools::s_FatalErrorOccured = false;
 bool cmSystemTools::s_FatalErrorOccured = false;
 bool cmSystemTools::s_DisableMessages = false;
 bool cmSystemTools::s_DisableMessages = false;
+bool cmSystemTools::s_ForceUnixPaths = false;
 
 
 std::string cmSystemTools::s_Windows9xComspecSubstitute = "command.com";
 std::string cmSystemTools::s_Windows9xComspecSubstitute = "command.com";
 void cmSystemTools::SetWindows9xComspecSubstitute(const char* str)
 void cmSystemTools::SetWindows9xComspecSubstitute(const char* str)
@@ -1032,3 +1033,17 @@ bool cmSystemTools::Split(const char* s, std::vector<cmStdString>& l)
     }
     }
   return true;
   return true;
 }
 }
+
+std::string cmSystemTools::ConvertToOutputPath(const char* path)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+  if(s_ForceUnixPaths)
+    {
+    return cmSystemTools::ConvertToUnixOutputPath(path);
+    }
+  return cmSystemTools::ConvertToWindowsOutputPath(path);
+#else
+  return cmSystemTools::ConvertToUnixOutputPath(path);
+#endif
+}
+

+ 7 - 1
Source/cmSystemTools.h

@@ -235,8 +235,14 @@ public:
   /** Split a string on its newlines into multiple lines.  Returns
   /** Split a string on its newlines into multiple lines.  Returns
       false only if the last line stored had no newline.  */
       false only if the last line stored had no newline.  */
   static bool Split(const char* s, std::vector<cmStdString>& l);  
   static bool Split(const char* s, std::vector<cmStdString>& l);  
-
+  static void SetForceUnixPaths(bool v)
+    {
+      s_ForceUnixPaths = v;
+    }
+  static std::string ConvertToOutputPath(const char* path);
+  
 private:
 private:
+  static bool s_ForceUnixPaths;
   static bool s_RunCommandHideConsole;
   static bool s_RunCommandHideConsole;
   static bool s_ErrorOccured;
   static bool s_ErrorOccured;
   static bool s_FatalErrorOccured;
   static bool s_FatalErrorOccured;

+ 19 - 7
Source/cmWin32ProcessExecution.cxx

@@ -291,16 +291,17 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
 {
 {
   PROCESS_INFORMATION piProcInfo;
   PROCESS_INFORMATION piProcInfo;
   STARTUPINFO siStartInfo;
   STARTUPINFO siStartInfo;
-  char *s1,*s2, *s3 = " /c ";
+  char *s1=0,*s2=0, *s3 = " /c ";
   int i;
   int i;
   int x;
   int x;
   if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) 
   if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) 
     {
     {
     char *comshell;
     char *comshell;
 
 
-    s1 = (char *)_alloca(i);
+    s1 = (char *)malloc(i);
     if (!(x = GetEnvironmentVariable("COMSPEC", s1, i)))
     if (!(x = GetEnvironmentVariable("COMSPEC", s1, i)))
       {
       {
+      free(s1);
       return x;
       return x;
       }
       }
 
 
@@ -317,7 +318,7 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
       {
       {
       /* NT/2000 and not using command.com. */
       /* NT/2000 and not using command.com. */
       x = i + (int)strlen(s3) + (int)strlen(cmdstring) + 1;
       x = i + (int)strlen(s3) + (int)strlen(cmdstring) + 1;
-      s2 = (char *)_alloca(x);
+      s2 = (char *)malloc(x);
       ZeroMemory(s2, x);
       ZeroMemory(s2, x);
       //sprintf(s2, "%s%s%s", s1, s3, cmdstring);
       //sprintf(s2, "%s%s%s", s1, s3, cmdstring);
       sprintf(s2, "%s", cmdstring);
       sprintf(s2, "%s", cmdstring);
@@ -366,15 +367,20 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
             << "Can not locate '" << modulepath
             << "Can not locate '" << modulepath
             << "' which is needed "
             << "' which is needed "
             "for popen to work with your shell "
             "for popen to work with your shell "
-            "or platform." << std::endl;
+            "or platform." << std::endl;    
+          free(s1);
+          free(s2);
           return FALSE;
           return FALSE;
           }
           }
         }
         }
       x = i + (int)strlen(s3) + (int)strlen(cmdstring) + 1 +
       x = i + (int)strlen(s3) + (int)strlen(cmdstring) + 1 +
         (int)strlen(modulepath) + 
         (int)strlen(modulepath) + 
         (int)strlen(szConsoleSpawn) + 1;
         (int)strlen(szConsoleSpawn) + 1;
-
-      s2 = (char *)_alloca(x);
+      if(s2)
+        {
+        free(s2);
+        }
+      s2 = (char *)malloc(x);
       ZeroMemory(s2, x);
       ZeroMemory(s2, x);
       sprintf(
       sprintf(
         s2,
         s2,
@@ -396,7 +402,9 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
   else 
   else 
     {
     {
     std::cout << "Cannot locate a COMSPEC environment variable to "
     std::cout << "Cannot locate a COMSPEC environment variable to "
-              << "use as the shell" << std::endl;
+              << "use as the shell" << std::endl; 
+    free(s2);
+    free(s1);
     return FALSE;
     return FALSE;
     }
     }
   
   
@@ -429,11 +437,15 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
     /* Return process handle */
     /* Return process handle */
     *hProcess = piProcInfo.hProcess;
     *hProcess = piProcInfo.hProcess;
     //std::cout << "Process created..." << std::endl;
     //std::cout << "Process created..." << std::endl;
+    free(s2);
+    free(s1);
     return TRUE;
     return TRUE;
     }
     }
   output += "CreateProcessError ";
   output += "CreateProcessError ";
   output += s2;
   output += s2;
   output += "\n";
   output += "\n";
+  free(s2);
+  free(s1);
   return FALSE;
   return FALSE;
 }
 }
 
 

+ 18 - 1
Source/cmake.cxx

@@ -26,10 +26,13 @@
 // include the generator
 // include the generator
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include "cmGlobalVisualStudio6Generator.h"
 #include "cmGlobalVisualStudio6Generator.h"
+#if !defined(__MINGW32__)
 #include "cmGlobalVisualStudio7Generator.h"
 #include "cmGlobalVisualStudio7Generator.h"
 #include "cmGlobalVisualStudio71Generator.h"
 #include "cmGlobalVisualStudio71Generator.h"
+#endif
 #include "cmGlobalBorlandMakefileGenerator.h"
 #include "cmGlobalBorlandMakefileGenerator.h"
 #include "cmGlobalNMakeMakefileGenerator.h"
 #include "cmGlobalNMakeMakefileGenerator.h"
+#include "cmGlobalUnixMakefileGenerator.h"
 #include "cmWin32ProcessExecution.h"
 #include "cmWin32ProcessExecution.h"
 #else
 #else
 #include "cmGlobalUnixMakefileGenerator.h"
 #include "cmGlobalUnixMakefileGenerator.h"
@@ -795,6 +798,10 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
 
 
   // set the new
   // set the new
   m_GlobalGenerator = gg;
   m_GlobalGenerator = gg;
+  // set the global flag for unix style paths on cmSystemTools as 
+  // soon as the generator is set.  This allows gmake to be used
+  // on windows.
+  cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths());
   // Save the environment variables CXX and CC
   // Save the environment variables CXX and CC
   m_CXXEnvironment = getenv("CXX");
   m_CXXEnvironment = getenv("CXX");
   m_CCEnvironment = getenv("CC");    
   m_CCEnvironment = getenv("CC");    
@@ -877,6 +884,10 @@ int cmake::Configure()
     if(genName)
     if(genName)
       {
       {
       m_GlobalGenerator = this->CreateGlobalGenerator(genName);
       m_GlobalGenerator = this->CreateGlobalGenerator(genName);
+      // set the global flag for unix style paths on cmSystemTools as 
+      // soon as the generator is set.  This allows gmake to be used
+      // on windows.
+      cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths());
       }
       }
     else
     else
       {
       {
@@ -1065,6 +1076,10 @@ int cmake::LocalGenerate()
   if(genName)
   if(genName)
     {
     {
     m_GlobalGenerator = this->CreateGlobalGenerator(genName);
     m_GlobalGenerator = this->CreateGlobalGenerator(genName);
+    // set the global flag for unix style paths on cmSystemTools as 
+    // soon as the generator is set.  This allows gmake to be used
+    // on windows.
+    cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths());
     }
     }
   else
   else
     {
     {
@@ -1151,10 +1166,12 @@ void cmake::AddDefaultGenerators()
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #if defined(_WIN32) && !defined(__CYGWIN__)
   m_Generators[cmGlobalVisualStudio6Generator::GetActualName()] =
   m_Generators[cmGlobalVisualStudio6Generator::GetActualName()] =
     &cmGlobalVisualStudio6Generator::New;
     &cmGlobalVisualStudio6Generator::New;
+#if !defined(__MINGW32__)
   m_Generators[cmGlobalVisualStudio7Generator::GetActualName()] =
   m_Generators[cmGlobalVisualStudio7Generator::GetActualName()] =
     &cmGlobalVisualStudio7Generator::New;
     &cmGlobalVisualStudio7Generator::New;
   m_Generators[cmGlobalVisualStudio71Generator::GetActualName()] =
   m_Generators[cmGlobalVisualStudio71Generator::GetActualName()] =
     &cmGlobalVisualStudio71Generator::New;
     &cmGlobalVisualStudio71Generator::New;
+#endif
   m_Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] =
   m_Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] =
     &cmGlobalBorlandMakefileGenerator::New;
     &cmGlobalBorlandMakefileGenerator::New;
   m_Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] =
   m_Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] =
@@ -1164,9 +1181,9 @@ void cmake::AddDefaultGenerators()
   m_Generators[cmGlobalCodeWarriorGenerator::GetActualName()] =
   m_Generators[cmGlobalCodeWarriorGenerator::GetActualName()] =
     &cmGlobalCodeWarriorGenerator::New;
     &cmGlobalCodeWarriorGenerator::New;
 # endif
 # endif
+#endif
   m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] =
   m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] =
     &cmGlobalUnixMakefileGenerator::New;
     &cmGlobalUnixMakefileGenerator::New;
-#endif
 }
 }
 
 
 int cmake::LoadCache()
 int cmake::LoadCache()

+ 1 - 1
Source/kwsys/SystemTools.cxx

@@ -38,7 +38,7 @@
 #include <sys/wait.h>
 #include <sys/wait.h>
 #endif
 #endif
 
 
-#if defined(_WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__))
+#if defined(_WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__))
 #include <string.h>
 #include <string.h>
 #include <windows.h>
 #include <windows.h>
 #include <direct.h>
 #include <direct.h>