From 475364ac4846a9624804f1059cc45b5a32d638c2 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Fri, 18 Jan 2002 13:30:51 -0500 Subject: [PATCH] some fixes to recent screwerd up changes --- Source/cmUnixMakefileGenerator.cxx | 102 ++++++++++++++++++++++------- Source/cmUnixMakefileGenerator.h | 4 ++ 2 files changed, 81 insertions(+), 25 deletions(-) diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index ed947b6a6..7733a00cb 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -868,39 +868,66 @@ void cmUnixMakefileGenerator::OutputDependLibs(std::ostream& fout) if(cacheValue && (!this->SamePath(m_Makefile->GetCurrentOutputDirectory(), cacheValue))) { - std::string library = m_LibraryPrefix; - library += *lib; - std::string libpath = cacheValue; // add the correct extension std::string ltname = *lib+"_LIBRARY_TYPE"; const char* libType = m_Makefile->GetDefinition(ltname.c_str()); - if(libType && std::string(libType) == "SHARED") + // if it was a library.. + if (libType) { - library += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX"); + std::string library = m_LibraryPrefix; + library += *lib; + std::string libpath = cacheValue; + if(libType && std::string(libType) == "SHARED") + { + library += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX"); + } + else if(libType && std::string(libType) == "MODULE") + { + library += m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); + } + else if(libType && std::string(libType) == "STATIC") + { + library += m_StaticLibraryExtension; + } + else + { + cmSystemTools::Error("Unknown library type!"); + return; + } + if(m_LibraryOutputPath.size()) + { + libpath = m_LibraryOutputPath; + } + else + { + libpath += "/"; + } + libpath += library; + // put out a rule to build the library if it does not exist + this->OutputBuildLibraryInDir(fout, + cacheValue, + library.c_str(), + libpath.c_str()); } - else if(libType && std::string(libType) == "MODULE") - { - library += m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); - } + // something other than a library... else { - library += m_StaticLibraryExtension; + std::string exepath = cacheValue; + if(m_ExecutableOutputPath.size()) + { + exepath = m_ExecutableOutputPath; + } + else + { + exepath += "/"; + } + exepath += *lib; + this->OutputBuildExecutableInDir(fout, + cacheValue, + lib->c_str(), + exepath.c_str()); } - if(m_LibraryOutputPath.size()) - { - libpath = m_LibraryOutputPath; - } - else - { - libpath += "/"; - } - libpath += library; - // put out a rule to build the library if it does not exist - this->OutputBuildLibraryInDir(fout, - cacheValue, - library.c_str(), - libpath.c_str()); } } } @@ -924,6 +951,25 @@ void cmUnixMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout, << "; $(MAKE) $(MAKESILENT) " << makeTarget << "\n\n"; } +void cmUnixMakefileGenerator::OutputBuildExecutableInDir(std::ostream& fout, + const char* path, + const char* library, + const char* fullpath) +{ + const char* makeTarget = library; + const char* libOutPath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); + if(libOutPath && strcmp( libOutPath, "" ) != 0) + { + makeTarget = fullpath; + } + fout << cmSystemTools::EscapeSpaces(fullpath) + << ":\n\tcd " << cmSystemTools::EscapeSpaces(path) + << "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends" + << "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends" + << "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends" + << "; $(MAKE) $(MAKESILENT) " << makeTarget << "\n\n"; +} + bool cmUnixMakefileGenerator::SamePath(const char* path1, const char* path2) { return strcmp(path1, path2) == 0; @@ -1017,7 +1063,13 @@ void cmUnixMakefileGenerator::OutputExeDepend(std::ostream& fout, // add the correct extension if (m_Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX")) { - exepath += m_Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX"); + std::string replaceVars = + m_Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX"); + if (!strcmp(replaceVars.c_str(),"@CMAKE_EXECUTABLE_SUFFIX@")) + { + replaceVars = ""; + } + exepath += replaceVars; } fout << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(exepath.c_str()).c_str()) << " "; diff --git a/Source/cmUnixMakefileGenerator.h b/Source/cmUnixMakefileGenerator.h index 0e257afe5..f716a33e9 100644 --- a/Source/cmUnixMakefileGenerator.h +++ b/Source/cmUnixMakefileGenerator.h @@ -163,6 +163,10 @@ protected: const char* path, const char* library, const char* fullpath); + virtual void OutputBuildExecutableInDir(std::ostream& fout, + const char* path, + const char* library, + const char* fullpath); ///! return true if the two paths are the same virtual bool SamePath(const char* path1, const char* path2); virtual std::string GetOutputExtension(const char* sourceExtension);