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:
parent
a6f5f8395c
commit
407afb906c
|
@ -24,15 +24,9 @@ IF(BUILD_TESTING)
|
|||
# the project must have a DartConfig.cmake file
|
||||
INCLUDE(${PROJECT_SOURCE_DIR}/DartConfig.cmake)
|
||||
|
||||
# find programs used by testing
|
||||
# look for the make program
|
||||
IF( BCB_BIN_PATH )
|
||||
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 )
|
||||
# make program just needs to use CMAKE_MAKE_PROGRAM which is required
|
||||
# to be defined by cmake
|
||||
SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
|
||||
FIND_PROGRAM(CVSCOMMAND cvs )
|
||||
FIND_PROGRAM(COMPRESSIONCOMMAND NAMES gzip compress zip )
|
||||
FIND_PROGRAM(GUNZIPCOMMAND gunzip )
|
||||
|
|
|
@ -58,6 +58,7 @@ bool cmBuildCommand::InitialPass(std::vector<std::string> const& args)
|
|||
std::string makecommand;
|
||||
std::string makeprogram = args[1];
|
||||
m_Makefile->ExpandVariablesInString(makeprogram);
|
||||
std::string compiler = m_Makefile->GetDefinition("CMAKE_CXX_COMPILER");
|
||||
if(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 ||
|
||||
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 += " -K";
|
||||
makecommand += " -i";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -137,7 +137,7 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
|
|||
cmSystemTools::ConvertToWindowsSlashes(dir);
|
||||
fout << "\tif not exist " << dir.c_str() << " "
|
||||
<< "$(MAKE) rebuild_cache\n"
|
||||
<< "\tcd \".\\" << directory << "\"\n"
|
||||
<< "\tcd .\\" << directory << "\n"
|
||||
<< "\t$(MAKE) -$(MAKEFLAGS) " << target1 << "\n";
|
||||
}
|
||||
if(target2)
|
||||
|
@ -146,7 +146,7 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
|
|||
}
|
||||
std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
|
||||
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
|
||||
|
@ -235,11 +235,15 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
|||
bool shared)
|
||||
{
|
||||
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 += source.GetFullPath();
|
||||
std::string compileCommand;
|
||||
std::string ext = source.GetSourceExtension();
|
||||
std::cerr << "ext " << ext.c_str() << "\n";
|
||||
if(ext == "c" )
|
||||
{
|
||||
compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) ";
|
||||
|
@ -255,12 +259,23 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
|||
}
|
||||
else if (ext == "rc")
|
||||
{
|
||||
std::cerr << "rc file " << source.GetFullPath() << "\n";
|
||||
compileCommand = "$(RC) /fo\"";
|
||||
compileCommand += objectFile;
|
||||
compileCommand += "\" ";
|
||||
compileCommand += source.GetFullPath();
|
||||
}
|
||||
else if (ext == "def")
|
||||
{
|
||||
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
|
||||
else
|
||||
{
|
||||
|
@ -348,6 +363,11 @@ void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
|
|||
command += "$(" + std::string(name) + "_SRC_OBJS) ";
|
||||
command += " /Fe" + m_ExecutableOutputPath + name;
|
||||
command += ".exe /link ";
|
||||
if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
|
||||
{
|
||||
command += " /subsystem:windows ";
|
||||
}
|
||||
|
||||
std::strstream linklibs;
|
||||
this->OutputLinkLibraries(linklibs, 0, t);
|
||||
linklibs << std::ends;
|
||||
|
@ -412,3 +432,26 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
|
|||
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";
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ protected:
|
|||
virtual void OutputLinkLibraries(std::ostream& fout,
|
||||
const char* targetLibrary,
|
||||
const cmTarget &tgt);
|
||||
virtual std::string GetOutputExtension(const char* sourceExtension);
|
||||
virtual void OutputIncludeMakefile(std::ostream&, const char* file);
|
||||
private:
|
||||
bool m_QuoteNextCommand; // if this is true, OutputMakeRule
|
||||
// will not quote the next commands
|
||||
|
|
|
@ -271,10 +271,23 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file)
|
|||
// only add the depend include if the depend file exists
|
||||
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
|
||||
|
@ -345,9 +358,13 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
|||
{
|
||||
if(!i->IsAHeaderFileOnly())
|
||||
{
|
||||
fout << "\\\n" << i->GetSourceName()
|
||||
<< m_ObjectFileExtension << " ";
|
||||
}
|
||||
std::string outExt(this->GetOutputExtension(i->GetSourceExtension().c_str()));
|
||||
if(outExt.size())
|
||||
{
|
||||
fout << "\\\n" << i->GetSourceName()
|
||||
<< outExt.c_str() << " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
fout << "\n\n";
|
||||
}
|
||||
|
|
|
@ -151,6 +151,8 @@ protected:
|
|||
const char* command2 = 0,
|
||||
const char* command3 = 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 SetExecutableExtension(const char* e) { m_ExecutableExtension = e;}
|
||||
void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;}
|
||||
|
|
|
@ -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_SHLIB_SUFFIX ".dll" CACHE STRING "Shared 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.")
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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_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.")
|
||||
FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES gmake make )
|
||||
|
||||
|
|
|
@ -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")
|
||||
ENDIF (NOT DEFS_SYS)
|
||||
|
||||
FIND_PROGRAM(CMAKE_MAKE_PROGRAM make ${BCB_BIN_PATH} )
|
||||
|
|
|
@ -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
|
||||
"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_MAKE_PROGRAM "msdev" CACHE STRING "Program used to build from dsp files.")
|
Loading…
Reference in New Issue