closer to nmake working, added CMAKE_MAKE_COMMAND instead of MAKECOMMAND used by Dart, nmake makefiles work with borland make and nmake

This commit is contained in:
Bill Hoffman 2001-11-15 17:11:26 -05:00
parent a6f5f8395c
commit 407afb906c
10 changed files with 84 additions and 19 deletions

View File

@ -24,15 +24,9 @@ IF(BUILD_TESTING)
# the project must have a DartConfig.cmake file # the project must have a DartConfig.cmake file
INCLUDE(${PROJECT_SOURCE_DIR}/DartConfig.cmake) INCLUDE(${PROJECT_SOURCE_DIR}/DartConfig.cmake)
# find programs used by testing # make program just needs to use CMAKE_MAKE_PROGRAM which is required
# look for the make program # to be defined by cmake
IF( BCB_BIN_PATH ) SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
FIND_PROGRAM(MAKEPROGRAM make ${BCB_BIN_PATH} )
ENDIF( BCB_BIN_PATH )
IF(NOT UNIX)
FIND_PROGRAM(MAKEPROGRAM msdev )
ENDIF(NOT UNIX)
FIND_PROGRAM(MAKEPROGRAM NAMES gmake make )
FIND_PROGRAM(CVSCOMMAND cvs ) FIND_PROGRAM(CVSCOMMAND cvs )
FIND_PROGRAM(COMPRESSIONCOMMAND NAMES gzip compress zip ) FIND_PROGRAM(COMPRESSIONCOMMAND NAMES gzip compress zip )
FIND_PROGRAM(GUNZIPCOMMAND gunzip ) FIND_PROGRAM(GUNZIPCOMMAND gunzip )

View File

@ -58,6 +58,7 @@ bool cmBuildCommand::InitialPass(std::vector<std::string> const& args)
std::string makecommand; std::string makecommand;
std::string makeprogram = args[1]; std::string makeprogram = args[1];
m_Makefile->ExpandVariablesInString(makeprogram); m_Makefile->ExpandVariablesInString(makeprogram);
std::string compiler = m_Makefile->GetDefinition("CMAKE_CXX_COMPILER");
if(makeprogram.find("msdev") != std::string::npos || if(makeprogram.find("msdev") != std::string::npos ||
makeprogram.find("MSDEV") != std::string::npos ) makeprogram.find("MSDEV") != std::string::npos )
{ {
@ -70,10 +71,11 @@ bool cmBuildCommand::InitialPass(std::vector<std::string> const& args)
} }
else if(makeprogram.find("Borland") != std::string::npos || else if(makeprogram.find("Borland") != std::string::npos ||
makeprogram.find("BORLAND") != std::string::npos || makeprogram.find("BORLAND") != std::string::npos ||
makeprogram.find("borland") != std::string::npos) makeprogram.find("borland") != std::string::npos ||
compiler.find("Borland") != std::string::npos)
{ {
makecommand = makeprogram; makecommand = makeprogram;
makecommand += " -K"; makecommand += " -i";
} }
else else
{ {

View File

@ -137,7 +137,7 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
cmSystemTools::ConvertToWindowsSlashes(dir); cmSystemTools::ConvertToWindowsSlashes(dir);
fout << "\tif not exist " << dir.c_str() << " " fout << "\tif not exist " << dir.c_str() << " "
<< "$(MAKE) rebuild_cache\n" << "$(MAKE) rebuild_cache\n"
<< "\tcd \".\\" << directory << "\"\n" << "\tcd .\\" << directory << "\n"
<< "\t$(MAKE) -$(MAKEFLAGS) " << target1 << "\n"; << "\t$(MAKE) -$(MAKEFLAGS) " << target1 << "\n";
} }
if(target2) if(target2)
@ -146,7 +146,7 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
} }
std::string currentDir = m_Makefile->GetCurrentOutputDirectory(); std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
cmSystemTools::ConvertToWindowsSlashes(currentDir); cmSystemTools::ConvertToWindowsSlashes(currentDir);
fout << "\tcd \"" << currentDir.c_str() << "\"\n"; fout << "\tcd " << currentDir.c_str() << "\n";
} }
// This needs to be overriden because nmake requires commands to be quoted // This needs to be overriden because nmake requires commands to be quoted
@ -235,11 +235,15 @@ OutputBuildObjectFromSource(std::ostream& fout,
bool shared) bool shared)
{ {
std::string comment = "Build "; std::string comment = "Build ";
std::string objectFile = std::string(shortName) + ".obj"; std::string objectFile = std::string(shortName) +
this->GetOutputExtension(source.GetSourceExtension().c_str());
std::cerr << "short name objectfile " << objectFile.c_str() << " " << shortName << "\n";
comment += objectFile + " From "; comment += objectFile + " From ";
comment += source.GetFullPath(); comment += source.GetFullPath();
std::string compileCommand; std::string compileCommand;
std::string ext = source.GetSourceExtension(); std::string ext = source.GetSourceExtension();
std::cerr << "ext " << ext.c_str() << "\n";
if(ext == "c" ) if(ext == "c" )
{ {
compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) "; compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) ";
@ -255,12 +259,23 @@ OutputBuildObjectFromSource(std::ostream& fout,
} }
else if (ext == "rc") else if (ext == "rc")
{ {
std::cerr << "rc file " << source.GetFullPath() << "\n"; compileCommand = "$(RC) /fo\"";
compileCommand += objectFile;
compileCommand += "\" ";
compileCommand += source.GetFullPath();
} }
else if (ext == "def") else if (ext == "def")
{ {
std::cerr << "def file " << source.GetFullPath() << "\n"; std::cerr << "def file " << source.GetFullPath() << "\n";
} }
else if (ext == "ico")
{
std::cerr << "ico file " << source.GetFullPath() << "\n";
}
else if (ext == "rc2")
{
std::cerr << "rc2 file " << source.GetFullPath() << "\n";
}
// assume c++ if not c rc or def // assume c++ if not c rc or def
else else
{ {
@ -348,6 +363,11 @@ void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
command += "$(" + std::string(name) + "_SRC_OBJS) "; command += "$(" + std::string(name) + "_SRC_OBJS) ";
command += " /Fe" + m_ExecutableOutputPath + name; command += " /Fe" + m_ExecutableOutputPath + name;
command += ".exe /link "; command += ".exe /link ";
if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
{
command += " /subsystem:windows ";
}
std::strstream linklibs; std::strstream linklibs;
this->OutputLinkLibraries(linklibs, 0, t); this->OutputLinkLibraries(linklibs, 0, t);
linklibs << std::ends; linklibs << std::ends;
@ -412,3 +432,26 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
fout << linkLibs << "$(CMAKE_STANDARD_WINDOWS_LIBRARIES) "; fout << linkLibs << "$(CMAKE_STANDARD_WINDOWS_LIBRARIES) ";
} }
} }
std::string cmNMakeMakefileGenerator::GetOutputExtension(const char* s)
{
std::string sourceExtension = s;
if(sourceExtension == "def" || sourceExtension == "ico" || sourceExtension == "rc2")
{
return "";
}
if(sourceExtension == "rc")
{
return ".res";
}
return ".obj";
}
void cmNMakeMakefileGenerator::OutputIncludeMakefile(std::ostream& fout,
const char* file)
{
fout << "!include " << file << "\n";
}

View File

@ -98,6 +98,8 @@ protected:
virtual void OutputLinkLibraries(std::ostream& fout, virtual void OutputLinkLibraries(std::ostream& fout,
const char* targetLibrary, const char* targetLibrary,
const cmTarget &tgt); const cmTarget &tgt);
virtual std::string GetOutputExtension(const char* sourceExtension);
virtual void OutputIncludeMakefile(std::ostream&, const char* file);
private: private:
bool m_QuoteNextCommand; // if this is true, OutputMakeRule bool m_QuoteNextCommand; // if this is true, OutputMakeRule
// will not quote the next commands // will not quote the next commands

View File

@ -271,10 +271,23 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file)
// only add the depend include if the depend file exists // only add the depend include if the depend file exists
if(cmSystemTools::FileExists(dependName.c_str())) if(cmSystemTools::FileExists(dependName.c_str()))
{ {
fout << "include cmake.depends\n"; this->OutputIncludeMakefile(fout, "cmake.depends");
} }
} }
void cmUnixMakefileGenerator::OutputIncludeMakefile(std::ostream& fout,
const char* file)
{
fout << "include " << file << "\n";
}
std::string
cmUnixMakefileGenerator::GetOutputExtension(const char* sourceExtension)
{
return m_ObjectFileExtension;
}
// Output the rules for any targets // Output the rules for any targets
@ -345,9 +358,13 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
{ {
if(!i->IsAHeaderFileOnly()) if(!i->IsAHeaderFileOnly())
{ {
fout << "\\\n" << i->GetSourceName() std::string outExt(this->GetOutputExtension(i->GetSourceExtension().c_str()));
<< m_ObjectFileExtension << " "; if(outExt.size())
} {
fout << "\\\n" << i->GetSourceName()
<< outExt.c_str() << " ";
}
}
} }
fout << "\n\n"; fout << "\n\n";
} }

View File

@ -151,6 +151,8 @@ protected:
const char* command2 = 0, const char* command2 = 0,
const char* command3 = 0, const char* command3 = 0,
const char* command4 = 0); const char* command4 = 0);
virtual std::string GetOutputExtension(const char* sourceExtension);
virtual void OutputIncludeMakefile(std::ostream&, const char* file);
void SetObjectFileExtension(const char* e) { m_ObjectFileExtension = e;} void SetObjectFileExtension(const char* e) { m_ObjectFileExtension = e;}
void SetExecutableExtension(const char* e) { m_ExecutableExtension = e;} void SetExecutableExtension(const char* e) { m_ExecutableExtension = e;}
void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;} void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;}

View File

@ -24,6 +24,8 @@ SET (CMAKE_USE_WIN32_THREADS 1 CACHE BOOL "Use the win32 thread library")
SET (CMAKE_STANDARD_WINDOWS_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING "Libraries linked by defalut with all applications") SET (CMAKE_STANDARD_WINDOWS_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING "Libraries linked by defalut with all applications")
SET (CMAKE_SHLIB_SUFFIX ".dll" CACHE STRING "Shared library suffix") SET (CMAKE_SHLIB_SUFFIX ".dll" CACHE STRING "Shared library suffix")
SET (CMAKE_MODULE_SUFFIX ".dll" CACHE STRING "Module library suffix") SET (CMAKE_MODULE_SUFFIX ".dll" CACHE STRING "Module library suffix")
SET (CMAKE_MAKE_PROGRAM "nmake" CACHE STRING "Program used to build from makefiles.")

View File

@ -63,4 +63,5 @@ SET (CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@ CACHE INTERNAL "Is
SET (CMAKE_ANSI_CFLAGS @CMAKE_ANSI_CFLAGS@ CACHE INTERNAL "What flags are required by the c++ compiler to make it ansi.") SET (CMAKE_ANSI_CFLAGS @CMAKE_ANSI_CFLAGS@ CACHE INTERNAL "What flags are required by the c++ compiler to make it ansi.")
SET (CMAKE_ANSI_CXXFLAGS @CMAKE_ANSI_CXXFLAGS@ CACHE INTERNAL "What flags are required by the c++ compiler to make it ansi.") SET (CMAKE_ANSI_CXXFLAGS @CMAKE_ANSI_CXXFLAGS@ CACHE INTERNAL "What flags are required by the c++ compiler to make it ansi.")
SET (CMAKE_NO_EXPLICIT_TEMPLATE_INSTANTIATION @CMAKE_NO_EXPLICIT_TEMPLATE_INSTANTIATION@ CACHE INTERNAL "does the compiler not support explicit template instantiation.") SET (CMAKE_NO_EXPLICIT_TEMPLATE_INSTANTIATION @CMAKE_NO_EXPLICIT_TEMPLATE_INSTANTIATION@ CACHE INTERNAL "does the compiler not support explicit template instantiation.")
FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES gmake make )

View File

@ -94,3 +94,4 @@ IF (NOT DEFS_SYS)
SET (DEFS_SYS "-DWIN32;WIN32_LEAN_AND_MEAN;STRICT;_RTLDLL;USEPACKAGES" CACHE STRING "Compiler conditional defines required for correct compilation") SET (DEFS_SYS "-DWIN32;WIN32_LEAN_AND_MEAN;STRICT;_RTLDLL;USEPACKAGES" CACHE STRING "Compiler conditional defines required for correct compilation")
ENDIF (NOT DEFS_SYS) ENDIF (NOT DEFS_SYS)
FIND_PROGRAM(CMAKE_MAKE_PROGRAM make ${BCB_BIN_PATH} )

View File

@ -15,3 +15,4 @@ SET (CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Od /GZ" CACHE STRING
SET (CMAKE_CXX_FLAGS "/W3 /Zm1000 /GX /GR" CACHE STRING SET (CMAKE_CXX_FLAGS "/W3 /Zm1000 /GX /GR" CACHE STRING
"Flags used by the compiler during all build types, /GX /GR are for exceptions and rtti in VC++, /Zm1000 increases the compiler's memory allocation to support ANSI C++/stdlib") "Flags used by the compiler during all build types, /GX /GR are for exceptions and rtti in VC++, /Zm1000 increases the compiler's memory allocation to support ANSI C++/stdlib")
SET (CMAKE_USE_WIN32_THREADS 1 CACHE BOOL "Use the win32 thread library") SET (CMAKE_USE_WIN32_THREADS 1 CACHE BOOL "Use the win32 thread library")
SET (CMAKE_MAKE_PROGRAM "msdev" CACHE STRING "Program used to build from dsp files.")