diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-11-14 15:21:59 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-11-14 15:21:59 (GMT) |
commit | f978b6f7ea62b54c4190e0f20633c2823c21beea (patch) | |
tree | efd5683ae5149a0f2acd1a86ee7bdac373672db1 | |
parent | 7ac4e783166ddc2bbbd6c58fa472e2317668d292 (diff) | |
download | CMake-f978b6f7ea62b54c4190e0f20633c2823c21beea.zip CMake-f978b6f7ea62b54c4190e0f20633c2823c21beea.tar.gz CMake-f978b6f7ea62b54c4190e0f20633c2823c21beea.tar.bz2 |
nmake support
-rw-r--r-- | Source/cmNMakeMakefileGenerator.cxx | 161 | ||||
-rw-r--r-- | Source/cmNMakeMakefileGenerator.h | 24 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.cxx | 18 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.h | 10 | ||||
-rw-r--r-- | Templates/CMakeNMakeWindowsSystemConfig.cmake | 21 |
5 files changed, 228 insertions, 6 deletions
diff --git a/Source/cmNMakeMakefileGenerator.cxx b/Source/cmNMakeMakefileGenerator.cxx index 8a25dde..782cc8b 100644 --- a/Source/cmNMakeMakefileGenerator.cxx +++ b/Source/cmNMakeMakefileGenerator.cxx @@ -49,6 +49,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cmNMakeMakefileGenerator::cmNMakeMakefileGenerator() { + this->SetObjectFileExtension(".obj"); + this->SetExecutableExtension(".exe"); } cmNMakeMakefileGenerator::~cmNMakeMakefileGenerator() @@ -57,6 +59,17 @@ cmNMakeMakefileGenerator::~cmNMakeMakefileGenerator() void cmNMakeMakefileGenerator::ComputeSystemInfo() { + // now load the settings + if(!m_Makefile->GetDefinition("CMAKE_ROOT")) + { + cmSystemTools::Error( + "CMAKE_ROOT has not been defined, bad GUI or driver program"); + return; + } + std::string fpath = + m_Makefile->GetDefinition("CMAKE_ROOT"); + fpath += "/Templates/CMakeNMakeWindowsSystemConfig.cmake"; + m_Makefile->ReadListFile(NULL,fpath.c_str()); } void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout) @@ -66,7 +79,11 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout) "# general varibles used in the makefile\n" "\n" "# Path to cmake\n" - "CMAKE_COMMAND = ${CMAKE_COMMAND}\n"; + "CMAKE_COMMAND = ${CMAKE_COMMAND}\n" + "CMAKE_C_COMPILER = @CMAKE_C_COMPILER@\n" + "CMAKE_CFLAGS = @CMAKE_C_FLAGS@\n" + "CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n" + "CMAKE_CXXFLAGS = @CMAKE_CXX_FLAGS@\n"; std::string replaceVars = variables; m_Makefile->ExpandVariablesInString(replaceVars); fout << replaceVars.c_str(); @@ -115,3 +132,145 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout, fout << "\t$(MAKE) -$(MAKEFLAGS) " << target2 << "\n"; } } + +// This needs to be overriden because nmake requires commands to be quoted +// if the are full paths to the executable???? + +void cmNMakeMakefileGenerator::OutputMakeRule(std::ostream& fout, + const char* comment, + const char* target, + const char* depends, + const char* command, + const char* command2, + const char* command3, + const char* command4) +{ + if(!target) + { + cmSystemTools::Error("no target for OutputMakeRule"); + return; + } + + std::string replace; + if(comment) + { + replace = comment; + m_Makefile->ExpandVariablesInString(replace); + fout << "#---------------------------------------------------------\n"; + fout << "# " << comment; + fout << "\n#\n"; + } + fout << "\n"; + replace = target; + m_Makefile->ExpandVariablesInString(replace); + fout << replace.c_str() << ": "; + if(depends) + { + replace = depends; + m_Makefile->ExpandVariablesInString(replace); + fout << replace.c_str(); + } + fout << "\n"; + if(command) + { + replace = command; + m_Makefile->ExpandVariablesInString(replace); + fout << "\t\"" << replace.c_str() << "\"\n"; + } + if(command2) + { + replace = command2; + m_Makefile->ExpandVariablesInString(replace); + fout << "\t\"" << replace.c_str() << "\"\n"; + } + if(command3) + { + replace = command3; + m_Makefile->ExpandVariablesInString(replace); + fout << "\t\"" << replace.c_str() << "\"\n"; + } + if(command4) + { + replace = command4; + m_Makefile->ExpandVariablesInString(replace); + fout << "\t\"" << replace.c_str() << "\"\n"; + } + fout << "\n"; +} + +void +cmNMakeMakefileGenerator:: +OutputBuildObjectFromSource(std::ostream& fout, + const char* shortName, + const cmSourceFile& source, + const char* extraCompileFlags, + bool shared) +{ + std::string comment = "Build "; + std::string objectFile = std::string(shortName) + ".obj"; + comment += objectFile + " From "; + comment += source.GetFullPath(); + std::string compileCommand; + std::string ext = source.GetSourceExtension(); + if(ext == "c" ) + { + compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) "; + compileCommand += extraCompileFlags; + if(shared) + { + compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; + } + compileCommand += "$(INCLUDE_FLAGS) -c "; + compileCommand += source.GetFullPath(); + compileCommand += " /Fo"; + compileCommand += objectFile; + } + else + { + compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXXFLAGS) "; + compileCommand += extraCompileFlags; + if(shared) + { + compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; + } + compileCommand += "$(INCLUDE_FLAGS) -c "; + compileCommand += source.GetFullPath(); + compileCommand += " /Fo"; + compileCommand += objectFile; + } + this->OutputMakeRule(fout, + comment.c_str(), + objectFile.c_str(), + source.GetFullPath().c_str(), + compileCommand.c_str()); +} + +void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout, + const char* name, + const cmTarget &target) +{ + cmUnixMakefileGenerator::OutputSharedLibraryRule(fout, name, target); +} + +void cmNMakeMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout, + const char* name, + const cmTarget &target) +{ + cmUnixMakefileGenerator::OutputModuleLibraryRule(fout, name, target); +} + +void cmNMakeMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout, + const char* name, + const cmTarget &target) +{ + cmUnixMakefileGenerator::OutputStaticLibraryRule(fout, name, target); +} + +void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout, + const char* name, + const cmTarget &target) +{ + cmUnixMakefileGenerator::OutputExecutableRule(fout, name, target); +} + + diff --git a/Source/cmNMakeMakefileGenerator.h b/Source/cmNMakeMakefileGenerator.h index 1c92eb9..911cea1 100644 --- a/Source/cmNMakeMakefileGenerator.h +++ b/Source/cmNMakeMakefileGenerator.h @@ -72,6 +72,30 @@ protected: const char* directory, const char* target1, const char* target2); + void OutputMakeRule(std::ostream& fout, + const char* comment, + const char* target, + const char* depends, + const char* command, + const char* command2=0, + const char* command3=0, + const char* command4=0); + + + virtual void OutputBuildObjectFromSource(std::ostream& fout, + const char* shortName, + const cmSourceFile& source, + const char* extraCompileFlags, + bool sharedTarget); + virtual void OutputSharedLibraryRule(std::ostream&, const char* name, + const cmTarget &); + virtual void OutputModuleLibraryRule(std::ostream&, const char* name, + const cmTarget &); + virtual void OutputStaticLibraryRule(std::ostream&, const char* name, + const cmTarget &); + virtual void OutputExecutableRule(std::ostream&, const char* name, + const cmTarget &); + }; #endif diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index 6149035..1bd39ec 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -48,6 +48,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "cmGeneratedFileStream.h" cmUnixMakefileGenerator::cmUnixMakefileGenerator() + :m_ObjectFileExtension(".o"), + m_ExecutableExtension(""), + m_StaticLibraryExtension(".a"), + m_SharedLibraryExtension("$(SHLIB_SUFFIX)"), + m_LibraryPrefix("lib") { m_CacheOnly = false; m_Recurse = false; @@ -309,7 +314,8 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) l->second.GetType() == cmTarget::WIN32_EXECUTABLE) && l->second.IsInAll()) { - fout << " \\\n" << m_ExecutableOutputPath << l->first.c_str(); + fout << " \\\n" << m_ExecutableOutputPath << l->first.c_str() + << m_ExecutableExtension; } } // list utilities last @@ -336,7 +342,8 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) { if(!i->IsAHeaderFileOnly()) { - fout << "\\\n" << i->GetSourceName() << ".o "; + fout << "\\\n" << i->GetSourceName() + << m_ObjectFileExtension << " "; } } fout << "\n\n"; @@ -964,7 +971,7 @@ void cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout) { if(!source->GetDepends().empty()) { - fout << source->GetSourceName() << ".o :"; + fout << source->GetSourceName() << m_ObjectFileExtension << " :"; // Iterate through all the dependencies for this source. for(std::vector<std::string>::const_iterator dep = source->GetDepends().begin(); @@ -1407,7 +1414,7 @@ OutputBuildObjectFromSource(std::ostream& fout, { std::string comment = "Build "; - std::string objectFile = std::string(shortName) + ".o"; + std::string objectFile = std::string(shortName) + m_ObjectFileExtension; comment += objectFile + " From "; comment += source.GetFullPath(); std::string compileCommand; @@ -1449,7 +1456,8 @@ OutputBuildObjectFromSource(std::ostream& fout, void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout) { - fout << "# Rules to build .o files from their sources:\n"; + fout << "# Rules to build " << m_ObjectFileExtension + << " files from their sources:\n"; std::set<std::string> rules; diff --git a/Source/cmUnixMakefileGenerator.h b/Source/cmUnixMakefileGenerator.h index 00fb976..737b4ac 100644 --- a/Source/cmUnixMakefileGenerator.h +++ b/Source/cmUnixMakefileGenerator.h @@ -151,11 +151,21 @@ protected: const char* command2 = 0, const char* command3 = 0, const char* command4 = 0); + void SetObjectFileExtension(const char* e) { m_ObjectFileExtension = e;} + void SetExecutableExtension(const char* e) { m_ExecutableExtension = e;} + void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;} + void SetSharedLibraryExtension(const char* e) {m_SharedLibraryExtension = e;} + void SetLibraryPrefix(const char* e) { m_LibraryPrefix = e;} private: bool m_CacheOnly; bool m_Recurse; std::string m_ExecutableOutputPath; std::string m_LibraryOutputPath; + std::string m_ObjectFileExtension; + std::string m_ExecutableExtension; + std::string m_StaticLibraryExtension; + std::string m_SharedLibraryExtension; + std::string m_LibraryPrefix; }; #endif diff --git a/Templates/CMakeNMakeWindowsSystemConfig.cmake b/Templates/CMakeNMakeWindowsSystemConfig.cmake new file mode 100644 index 0000000..ce82fb9 --- /dev/null +++ b/Templates/CMakeNMakeWindowsSystemConfig.cmake @@ -0,0 +1,21 @@ +# microsoft specific config file +SET (WORDS_BIGENDIAN ) +SET (HAVE_LIMITS_H 1) +SET (HAVE_UNISTD_H 1) +SET (CMAKE_CXX_COMPILER cl CACHE FILEPATH + "Name of C++ compiler used.") +SET (CMAKE_C_COMPILER cl CACHE FILEPATH + "Name of C compiler used.") +SET (CMAKE_CFLAGS cl CACHE FILEPATH + "Flags for C compiler.") +SET (CMAKE_CXX_FLAGS_RELEASE "/MD /O2" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files)") +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /O2" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds") +SET (CMAKE_CXX_FLAGS_MINSIZEREL "/MD /O1" CACHE STRING + "Flags used by the compiler during release minsize builds") +SET (CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Od /GZ" CACHE STRING + "Flags used by the compiler during debug builds") +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") |