diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-11-14 23:12:22 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-11-14 23:12:22 (GMT) |
commit | 94f82edd07693f2a47f473ebc4cad7293559a600 (patch) | |
tree | 32e3394d71781c747cac25b0e7bd00327904c7c3 /Source | |
parent | a8d47b722185c97c262f12a3eea29510a7c450aa (diff) | |
download | CMake-94f82edd07693f2a47f473ebc4cad7293559a600.zip CMake-94f82edd07693f2a47f473ebc4cad7293559a600.tar.gz CMake-94f82edd07693f2a47f473ebc4cad7293559a600.tar.bz2 |
Closer to nmake build
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmSystemTools.cxx | 12 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 5 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.cxx | 64 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.h | 5 | ||||
-rw-r--r-- | Source/cmake.cxx | 4 | ||||
-rw-r--r-- | Source/cmaketest.cxx | 46 | ||||
-rw-r--r-- | Source/cmaketest.h.in | 2 |
7 files changed, 94 insertions, 44 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1695dac..c2ff201 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -438,6 +438,18 @@ std::string cmSystemTools::LowerCase(const std::string& s) return n; } +// Return a lower case string +std::string cmSystemTools::UpperCase(const std::string& s) +{ + std::string n; + n.resize(s.size()); + for (size_t i = 0; i < s.size(); i++) + { + n[i] = toupper(s[i]); + } + return n; +} + // convert windows slashes to unix slashes \ with / const char *cmSystemTools::ConvertToUnixSlashes(std::string& path) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index fa6782c..f382493 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -101,6 +101,11 @@ public: static std::string LowerCase(const std::string&); /** + * Return a lower case string + */ + static std::string UpperCase(const std::string&); + + /** * Replace Windows file system slashes with Unix-style slashes. */ static const char *ConvertToUnixSlashes(std::string& path); diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index 1bd39ec..584dba8 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -291,17 +291,20 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) { if(l->second.GetType() == cmTarget::STATIC_LIBRARY) { - fout << " \\\n" << m_LibraryOutputPath << "lib" << l->first.c_str() - << ".a"; + fout << " \\\n" << m_LibraryOutputPath << m_LibraryPrefix + << l->first.c_str() + << m_StaticLibraryExtension; } else if(l->second.GetType() == cmTarget::SHARED_LIBRARY) { - fout << " \\\n" << m_LibraryOutputPath << "lib" << l->first.c_str() + fout << " \\\n" << m_LibraryOutputPath << m_LibraryPrefix + << l->first.c_str() << m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX"); } else if(l->second.GetType() == cmTarget::MODULE_LIBRARY) { - fout << " \\\n" << m_LibraryOutputPath << "lib" << l->first.c_str() + fout << " \\\n" << m_LibraryOutputPath << m_LibraryPrefix + << l->first.c_str() << m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); } } @@ -792,18 +795,19 @@ void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout, if(m_LibraryOutputPath.size()) { libpath = m_LibraryOutputPath; - libpath += "lib"; + libpath += m_LibraryPrefix; } else { - libpath += "/lib"; + libpath += "/"; + libpath += m_LibraryPrefix; } } else { // library is in current Makefile so use lib as a prefix libpath = m_LibraryOutputPath; - libpath += "lib"; + libpath += m_LibraryPrefix; } // add the library name libpath += name; @@ -821,7 +825,7 @@ void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout, } else { - libpath += ".a"; + libpath += m_StaticLibraryExtension; } fout << libpath << " "; } @@ -1043,16 +1047,22 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) // with no outputs if(commandFiles.m_Outputs.size() == 0) { - fout << source.c_str() << ": "; - // Write out all the dependencies for this rule. - for(std::set<std::string>::const_iterator d = - commandFiles.m_Depends.begin(); - d != commandFiles.m_Depends.end(); ++d) - { - std::string dep = cmSystemTools::EscapeSpaces(d->c_str()); - fout << " " << dep.c_str(); - } - fout << "\n\t" << command.c_str() << "\n\n"; + std::string depends; + // collect out all the dependencies for this rule. + for(std::set<std::string>::const_iterator d = + commandFiles.m_Depends.begin(); + d != commandFiles.m_Depends.end(); ++d) + { + std::string dep = cmSystemTools::EscapeSpaces(d->c_str()); + depends += " "; + depends += dep; + } + // output rule + this->OutputMakeRule(fout, + "Custom command", + source.c_str(), + depends.c_str(), + command.c_str()); } // Write a rule for every output generated by this command. for(std::set<std::string>::const_iterator output = @@ -1060,16 +1070,23 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) output != commandFiles.m_Outputs.end(); ++output) { std::string src = cmSystemTools::EscapeSpaces(source.c_str()); - fout << output->c_str() << ": " << src.c_str(); - // Write out all the dependencies for this rule. + std::string depends; + depends += src; + // Collect out all the dependencies for this rule. for(std::set<std::string>::const_iterator d = commandFiles.m_Depends.begin(); d != commandFiles.m_Depends.end(); ++d) { std::string dep = cmSystemTools::EscapeSpaces(d->c_str()); - fout << " " << dep.c_str(); - } - fout << "\n\t" << command.c_str() << "\n\n"; + depends += " "; + depends += dep; + } + // output rule + this->OutputMakeRule(fout, + "Custom command", + output->c_str(), + depends.c_str(), + command.c_str()); } } } @@ -1510,6 +1527,7 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout) sourceName = source->GetFullPath(); shortName = cmSystemTools::GetFilenameName(source->GetSourceName()); } + shortName += source->GetSourceExtension(); // Only output a rule for each .o once. if(rules.find(shortName) == rules.end()) { diff --git a/Source/cmUnixMakefileGenerator.h b/Source/cmUnixMakefileGenerator.h index 737b4ac..2b0bc29 100644 --- a/Source/cmUnixMakefileGenerator.h +++ b/Source/cmUnixMakefileGenerator.h @@ -156,11 +156,12 @@ protected: void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;} void SetSharedLibraryExtension(const char* e) {m_SharedLibraryExtension = e;} void SetLibraryPrefix(const char* e) { m_LibraryPrefix = e;} +protected: + std::string m_ExecutableOutputPath; + std::string m_LibraryOutputPath; 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; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ff99837..1716c04 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(_WIN32) && !defined(__CYGWIN__) #include "cmMSProjectGenerator.h" #include "cmBorlandMakefileGenerator.h" +#include "cmNMakeMakefileGenerator.h" #else #include "cmUnixMakefileGenerator.h" #endif @@ -54,6 +55,7 @@ cmake::cmake() m_Verbose = false; #if defined(_WIN32) && !defined(__CYGWIN__) cmMakefileGenerator::RegisterGenerator(new cmMSProjectGenerator); +// cmMakefileGenerator::RegisterGenerator(new cmNMakeMakefileGenerator); cmMakefileGenerator::RegisterGenerator(new cmBorlandMakefileGenerator); #else cmMakefileGenerator::RegisterGenerator(new cmUnixMakefileGenerator); @@ -72,7 +74,7 @@ void cmake::Usage(const char* program) for(std::vector<std::string>::iterator i =names.begin(); i != names.end(); ++i) { - std::cerr << i->c_str() << " "; + std::cerr << "\"" << i->c_str() << "\" "; } std::cerr << ")\n"; } diff --git a/Source/cmaketest.cxx b/Source/cmaketest.cxx index 571e2f7..b3c250c 100644 --- a/Source/cmaketest.cxx +++ b/Source/cmaketest.cxx @@ -40,6 +40,7 @@ int main (int argc, char *argv[]) cmSystemTools::ChangeDirectory(binaryDirectory); cmake cm; std::vector<std::string> args; + // make sure the same generator is used // use this program as the cmake to be run, it should not // be run that way but the cmake object requires a vailid path std::string cmakeCommand = CMAKE_COMMAND; @@ -53,6 +54,10 @@ int main (int argc, char *argv[]) } args.push_back(cmakeCommand.c_str()); args.push_back(sourceDirectory); + std::string generator = "-G"; + generator += CMAKE_GENERATOR; + args.push_back(generator); + if (cm.Generate(args) != 0) { std::cerr << "Error: cmake execution failed\n"; @@ -63,26 +68,33 @@ int main (int argc, char *argv[]) cmListFileCache::GetInstance()->ClearCache(); // now build the test std::string makeCommand = MAKEPROGRAM; -#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) - // if there are spaces in the makeCommand, assume a full path - // and convert it to a path with no spaces in it as the - // RunCommand does not like spaces - if(makeCommand.find(' ') != std::string::npos) - { - char *buffer = new char[makeCommand.size()+1]; - if(GetShortPathName(makeCommand.c_str(), buffer, - makeCommand.size()+1) != 0) + std::string lowerCaseCommand = makeCommand; + cmSystemTools::LowerCase(lowerCaseCommand); + // if msdev is the make program then do the following + if(lowerCaseCommand.find("msdev") != std::string::npos) + { + // if there are spaces in the makeCommand, assume a full path + // and convert it to a path with no spaces in it as the + // RunCommand does not like spaces + if(makeCommand.find(' ') != std::string::npos) { - makeCommand = buffer; - delete [] buffer; + char *buffer = new char[makeCommand.size()+1]; + if(GetShortPathName(makeCommand.c_str(), buffer, + makeCommand.size()+1) != 0) + { + makeCommand = buffer; + delete [] buffer; + } } + makeCommand += " "; + makeCommand += executableName; + makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD"; + } + else + { + // assume a make sytle program + makeCommand += " all"; } - makeCommand += " "; - makeCommand += executableName; - makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD"; -#else - makeCommand += " all"; -#endif if (!cmSystemTools::RunCommand(makeCommand.c_str(), output)) { std::cerr << "Error: " << makeCommand.c_str() << " execution failed\n"; diff --git a/Source/cmaketest.h.in b/Source/cmaketest.h.in index 6178036..939ea08 100644 --- a/Source/cmaketest.h.in +++ b/Source/cmaketest.h.in @@ -1,3 +1,3 @@ #define CMAKE_COMMAND "${CMAKE_COMMAND}" #define MAKEPROGRAM "${MAKEPROGRAM}" - +#define CMAKE_GENERATOR "${CMAKE_GENERATOR}" |