From b0f4a4cb39927bf5490a5c6e3c0584ca277277c3 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 6 Dec 2002 15:35:22 -0500 Subject: [PATCH] ENH: fix IntDir jump and build problem --- Source/cmGlobalUnixMakefileGenerator.cxx | 1 + Source/cmGlobalVisualStudio6Generator.cxx | 1 + Source/cmGlobalVisualStudio7Generator.cxx | 1 + Source/cmLocalUnixMakefileGenerator.cxx | 68 ++++++++++++++--------- Source/cmMakefile.cxx | 5 -- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator.cxx b/Source/cmGlobalUnixMakefileGenerator.cxx index 7f68d2163..35bf3bf97 100644 --- a/Source/cmGlobalUnixMakefileGenerator.cxx +++ b/Source/cmGlobalUnixMakefileGenerator.cxx @@ -28,6 +28,7 @@ cmGlobalUnixMakefileGenerator::cmGlobalUnixMakefileGenerator() void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang, cmMakefile *mf) { + mf->AddDefinition("CMAKE_CFG_INTDIR","."); this->cmGlobalGenerator::EnableLanguage(lang, mf); } diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index ea3245ac6..c19ba046e 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -27,6 +27,7 @@ cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() void cmGlobalVisualStudio6Generator::EnableLanguage(const char* lang, cmMakefile *mf) { + mf->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)"); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); this->cmGlobalGenerator::EnableLanguage(lang, mf); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 8b61c0855..a583a0e51 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -30,6 +30,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator() void cmGlobalVisualStudio7Generator::EnableLanguage(const char* lang, cmMakefile *mf) { + mf->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)"); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); this->cmGlobalGenerator::EnableLanguage(lang, mf); diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index 8f5cb6865..bab9dfdf5 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -1096,6 +1096,7 @@ void cmLocalUnixMakefileGenerator::OutputDependLibs(std::ostream& fout) // for each target const cmTargets &tgts = m_Makefile->GetTargets(); + for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); l++) { @@ -1103,6 +1104,7 @@ void cmLocalUnixMakefileGenerator::OutputDependLibs(std::ostream& fout) std::set emitted; if ((l->second.GetType() == cmTarget::SHARED_LIBRARY) || (l->second.GetType() == cmTarget::MODULE_LIBRARY) + || (l->second.GetType() == cmTarget::STATIC_LIBRARY) || (l->second.GetType() == cmTarget::EXECUTABLE) || (l->second.GetType() == cmTarget::WIN32_EXECUTABLE)) { @@ -1110,28 +1112,31 @@ void cmLocalUnixMakefileGenerator::OutputDependLibs(std::ostream& fout) // A library should not depend on itself! emitted.insert(l->first); - - // Now, look at all link libraries specific to this target. - const cmTarget::LinkLibraries& tlibs = l->second.GetLinkLibraries(); - for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin(); - lib != tlibs.end(); ++lib) + // for static libraries do not depend on other libraries + if(l->second.GetType() != cmTarget::STATIC_LIBRARY) { - // Record that this library was used. - used.insert(lib->first); - - // Don't emit the same library twice for this target. - if(emitted.insert(lib->first).second) + // Now, look at all link libraries specific to this target. + const cmTarget::LinkLibraries& tlibs = l->second.GetLinkLibraries(); + for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin(); + lib != tlibs.end(); ++lib) { - // Output this dependency. - this->OutputLibDepend(fout, lib->first.c_str()); + // Record that this library was used. + used.insert(lib->first); + + // Don't emit the same library twice for this target. + if(emitted.insert(lib->first).second) + { + // Output this dependency. + this->OutputLibDepend(fout, lib->first.c_str()); + } } } - + // for all targets depend on utilities // Now, look at all utilities specific to this target. const std::set& tutils = l->second.GetUtilities(); for(std::set::const_iterator util = tutils.begin(); util != tutils.end(); ++util) - { + { // Record that this utility was used. used.insert(*util); @@ -1142,7 +1147,6 @@ void cmLocalUnixMakefileGenerator::OutputDependLibs(std::ostream& fout) this->OutputExeDepend(fout, util->c_str()); } } - fout << "\n"; } } @@ -1161,6 +1165,7 @@ void cmLocalUnixMakefileGenerator::OutputDependLibs(std::ostream& fout) // be stored in the cache std::string libPath = *lib + "_CMAKE_PATH"; const char* cacheValue = m_Makefile->GetDefinition(libPath.c_str()); + // if cache and not the current directory add a rule, to // jump into the directory and build for the first time if(cacheValue && @@ -1228,14 +1233,16 @@ void cmLocalUnixMakefileGenerator::OutputDependLibs(std::ostream& fout) { exepath += "/"; } - exepath += *lib; + std::string fullName = lib->c_str(); + fullName += cmSystemTools::GetExecutableExtension(); + exepath += fullName; this->OutputBuildTargetInDir(fout, - cacheValue, - lib->c_str(), - exepath.c_str(), - m_Makefile-> + cacheValue, + fullName.c_str(), + exepath.c_str(), + m_Makefile-> GetDefinition("EXECUTABLE_OUTPUT_PATH") - ); + ); } } } @@ -1761,8 +1768,9 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) { // escape spaces and convert to native slashes path for // the command - std::string command = - cmSystemTools::ConvertToOutputPath(c->second.m_Command.c_str()); + std::string command = c->second.m_Command; + cmSystemTools::ReplaceString(command, "/./", "/"); + command = cmSystemTools::ConvertToOutputPath(command.c_str()); command += " "; // now add the arguments command += c->second.m_Arguments; @@ -1776,9 +1784,12 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) for(std::set::const_iterator d = commandFiles.m_Depends.begin(); d != commandFiles.m_Depends.end(); ++d) - { - std::string dep = cmSystemTools::ConvertToOutputPath(d->c_str()); - depends += " "; + { + std::string dep = *d; + cmSystemTools::ReplaceString(dep, "/./", "/"); + cmSystemTools::ReplaceString(dep, "/$(IntDir)/", "/"); + dep = cmSystemTools::ConvertToOutputPath(dep.c_str()); + depends += " "; depends += dep; } // output rule @@ -1801,7 +1812,10 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) commandFiles.m_Depends.begin(); d != commandFiles.m_Depends.end(); ++d) { - std::string dep = cmSystemTools::ConvertToOutputPath(d->c_str()); + std::string dep = *d; + cmSystemTools::ReplaceString(dep, "/./", "/"); + cmSystemTools::ReplaceString(dep, "/$(IntDir)/", "/"); + dep = cmSystemTools::ConvertToOutputPath(dep.c_str()); depends += " "; depends += dep; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c5350b96a..0fec989a8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1118,11 +1118,6 @@ void cmMakefile::AddDefaultDefinitions() this->AddDefinition("APPLE", "1"); #endif -#if defined(_WIN32) && !defined(__CYGWIN__) - this->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)"); -#else - this->AddDefinition("CMAKE_CFG_INTDIR","."); -#endif char temp[1024]; sprintf(temp, "%d", cmMakefile::GetMinorVersion()); this->AddDefinition("CMAKE_MINOR_VERSION", temp);