Skip to content

Commit

Permalink
ENH: add the unix makefile generator as an option from the windows GU…
Browse files Browse the repository at this point in the history
…I, this builds with mingw, cygwin, and combinations of make cl, bcc32
  • Loading branch information
billhoffman committed Aug 21, 2003
1 parent 0270b60 commit a413160
Show file tree
Hide file tree
Showing 23 changed files with 147 additions and 48 deletions.
10 changes: 10 additions & 0 deletions Modules/CMakeCCompiler.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,14 @@ SET(CMAKE_AR "@CMAKE_AR@")
SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
SET(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@)
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 changes: 7 additions & 0 deletions Modules/CMakeDetermineCCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ IF(NOT CMAKE_COMPILER_RETURN)
"Determining if the C compiler is GNU failed with "
"the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
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)


Expand Down
4 changes: 2 additions & 2 deletions Modules/CMakeSystemSpecificInformation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ ENDIF(EXISTS ${CMAKE_SYSTEM_INFO_FILE})
IF(CMAKE_C_COMPILER)
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_C_COMPILER} NAME_WE)
# since the gnu compiler has several names force gcc
IF(CMAKE_COMPILER_IS_GNUGCC)
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_BASE_NAME gcc)
ENDIF(CMAKE_COMPILER_IS_GNUGCC)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
INCLUDE(${CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE} OPTIONAL)
Expand Down
2 changes: 1 addition & 1 deletion Modules/CMakeTestCCompiler.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is used by EnableLanguage in cmGlobalGenerator to
# 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
# any makefiles or projects.
IF(NOT CMAKE_C_COMPILER_WORKS)
Expand Down
2 changes: 1 addition & 1 deletion Modules/CMakeTestCXXCompiler.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is used by EnableLanguage in cmGlobalGenerator to
# 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
# any makefiles or projects.
IF(NOT CMAKE_CXX_COMPILER_WORKS)
Expand Down
6 changes: 6 additions & 0 deletions Modules/CMakeTestGNU.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#ifdef __GNUC__
void THIS_IS_GNU();
#endif
#ifdef __MINGW32__
void THIS_IS_MINGW();
#endif
#ifdef __CYGWIN__
void THIS_IS_CYGWIN();
#endif
3 changes: 1 addition & 2 deletions Modules/Platform/Windows-bcc32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ SET(CMAKE_LIBRARY_PATH_FLAG "-L")
SET(CMAKE_LINK_LIBRARY_FLAG "")
SET(CMAKE_SHARED_BUILD_CXX_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
#SET(CMAKE_START_TEMP_FILE "")
#SET(CMAKE_END_TEMP_FILE "")
Expand Down
9 changes: 1 addition & 8 deletions Modules/Platform/Windows-cl.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:")
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
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
"link /nologo ${CMAKE_START_TEMP_FILE} /out:<TARGET> /dll <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
Expand Down
22 changes: 22 additions & 0 deletions Modules/Platform/Windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,25 @@ SET(CMAKE_SHARED_LIBRARY_PREFIX "") # lib
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so
SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib")
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)



45 changes: 25 additions & 20 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,25 @@ ENDIF (APPLE)
IF (WIN32)
IF(NOT UNIX)
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 (WIN32)

Expand All @@ -95,10 +98,12 @@ LINK_DIRECTORIES(${CMake_BINARY_DIR}/Source)
IF (WIN32)
IF(NOT UNIX)
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 UNIX)
ENDIF (WIN32)
Expand Down
2 changes: 1 addition & 1 deletion Source/CTest/Curl/telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ CURLcode Curl_telnet(struct connectdata *conn)
ssize_t bytes_written;
char *buffer = buf;

if(!ReadFile(stdin_handle, buf, 255, &(DWORD)nread, NULL)) {
if(!ReadFile(stdin_handle, buf, 255, ((DWORD*)&nread), NULL)) {
keepon = FALSE;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/cmDynamicLoader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ cmDynamicLoader::GetSymbolAddress(cmLibHandle lib, const char* sym)
delete [] wsym;
void* result = ret;
#else
void* result = GetProcAddress(lib, sym);
void* result = (void*)GetProcAddress(lib, sym);
#endif
// Hack to cast pointer-to-data to pointer-to-function.
return *reinterpret_cast<cmDynamicLoaderFunction*>(&result);
Expand Down
1 change: 1 addition & 0 deletions Source/cmGlobalBorlandMakefileGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator()
{
m_FindMakeProgramFile = "CMakeBorlandFindMake.cmake";
m_ForceUnixPaths = false;
}

void cmGlobalBorlandMakefileGenerator::EnableLanguage(const char* l,
Expand Down
3 changes: 2 additions & 1 deletion Source/cmGlobalGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ int cmGlobalGenerator::s_TryCompileTimeout = 0;

cmGlobalGenerator::cmGlobalGenerator()
{
// do nothing duh
// by default use the native paths
m_ForceUnixPaths = false;
}

cmGlobalGenerator::~cmGlobalGenerator()
Expand Down
2 changes: 2 additions & 0 deletions Source/cmGlobalGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ class cmGlobalGenerator
void GetLocalGenerators(std::vector<cmLocalGenerator *>&g) { g = m_LocalGenerators;}
static int s_TryCompileTimeout;

bool GetForceUnixPaths() {return m_ForceUnixPaths;}
protected:
bool m_ForceUnixPaths;
cmStdString m_FindMakeProgramFile;
cmStdString m_ConfiguredFilesPath;
cmake *m_CMakeInstance;
Expand Down
1 change: 1 addition & 0 deletions Source/cmGlobalNMakeMakefileGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator()
{
m_FindMakeProgramFile = "CMakeNMakeFindMake.cmake";
m_ForceUnixPaths = false;
}

void cmGlobalNMakeMakefileGenerator::EnableLanguage(const char* l,
Expand Down
2 changes: 2 additions & 0 deletions Source/cmGlobalUnixMakefileGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

cmGlobalUnixMakefileGenerator::cmGlobalUnixMakefileGenerator()
{
// This type of makefile always requires unix style paths
m_ForceUnixPaths = true;
m_FindMakeProgramFile = "CMakeUnixFindMake.cmake";
}

Expand Down
2 changes: 1 addition & 1 deletion Source/cmLocalUnixMakefileGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,7 @@ cmLocalUnixMakefileGenerator::ConvertToOutputForExisting(const char* p)
{
if(!cmSystemTools::GetShortPath(ret.c_str(), ret))
{
ret = p;
ret = cmSystemTools::ConvertToOutputPath(p);
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions Source/cmSystemTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ bool cmSystemTools::s_DisableRunCommandOutput = false;
bool cmSystemTools::s_ErrorOccured = false;
bool cmSystemTools::s_FatalErrorOccured = false;
bool cmSystemTools::s_DisableMessages = false;
bool cmSystemTools::s_ForceUnixPaths = false;

std::string cmSystemTools::s_Windows9xComspecSubstitute = "command.com";
void cmSystemTools::SetWindows9xComspecSubstitute(const char* str)
Expand Down Expand Up @@ -1032,3 +1033,17 @@ bool cmSystemTools::Split(const char* s, std::vector<cmStdString>& l)
}
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
}

8 changes: 7 additions & 1 deletion Source/cmSystemTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,14 @@ class cmSystemTools: public cmsys::SystemTools
/** Split a string on its newlines into multiple lines. Returns
false only if the last line stored had no newline. */
static bool Split(const char* s, std::vector<cmStdString>& l);

static void SetForceUnixPaths(bool v)
{
s_ForceUnixPaths = v;
}
static std::string ConvertToOutputPath(const char* path);

private:
static bool s_ForceUnixPaths;
static bool s_RunCommandHideConsole;
static bool s_ErrorOccured;
static bool s_FatalErrorOccured;
Expand Down
26 changes: 19 additions & 7 deletions Source/cmWin32ProcessExecution.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,17 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
{
PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;
char *s1,*s2, *s3 = " /c ";
char *s1=0,*s2=0, *s3 = " /c ";
int i;
int x;
if (i = GetEnvironmentVariable("COMSPEC",NULL,0))
{
char *comshell;

s1 = (char *)_alloca(i);
s1 = (char *)malloc(i);
if (!(x = GetEnvironmentVariable("COMSPEC", s1, i)))
{
free(s1);
return x;
}

Expand All @@ -317,7 +318,7 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
{
/* NT/2000 and not using command.com. */
x = i + (int)strlen(s3) + (int)strlen(cmdstring) + 1;
s2 = (char *)_alloca(x);
s2 = (char *)malloc(x);
ZeroMemory(s2, x);
//sprintf(s2, "%s%s%s", s1, s3, cmdstring);
sprintf(s2, "%s", cmdstring);
Expand Down Expand Up @@ -366,15 +367,20 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
<< "Can not locate '" << modulepath
<< "' which is needed "
"for popen to work with your shell "
"or platform." << std::endl;
"or platform." << std::endl;
free(s1);
free(s2);
return FALSE;
}
}
x = i + (int)strlen(s3) + (int)strlen(cmdstring) + 1 +
(int)strlen(modulepath) +
(int)strlen(szConsoleSpawn) + 1;

s2 = (char *)_alloca(x);
if(s2)
{
free(s2);
}
s2 = (char *)malloc(x);
ZeroMemory(s2, x);
sprintf(
s2,
Expand All @@ -396,7 +402,9 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
else
{
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;
}

Expand Down Expand Up @@ -429,11 +437,15 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
/* Return process handle */
*hProcess = piProcInfo.hProcess;
//std::cout << "Process created..." << std::endl;
free(s2);
free(s1);
return TRUE;
}
output += "CreateProcessError ";
output += s2;
output += "\n";
free(s2);
free(s1);
return FALSE;
}

Expand Down
Loading

0 comments on commit a413160

Please sign in to comment.