diff options
author | Brad King <brad.king@kitware.com> | 2006-01-14 01:51:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-01-14 01:51:45 (GMT) |
commit | 8340c0d18611d9ff6a8237ffe3d3cd6655a1c518 (patch) | |
tree | 412c5eb73b7b014c665b96511f31047a7616d13c | |
parent | 18477b194ca49a58c253af76bf11504dd51edaef (diff) | |
download | CMake-8340c0d18611d9ff6a8237ffe3d3cd6655a1c518.zip CMake-8340c0d18611d9ff6a8237ffe3d3cd6655a1c518.tar.gz CMake-8340c0d18611d9ff6a8237ffe3d3cd6655a1c518.tar.bz2 |
ENH: Further centralized custom command dependency computation. Custom command dependencies in the source tree may now also be specified relative to the source directory.
-rw-r--r-- | Source/cmLocalGenerator.cxx | 42 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 12 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 56 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.h | 1 |
4 files changed, 41 insertions, 70 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8e91368..1581d59 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1620,8 +1620,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, //---------------------------------------------------------------------------- std::string cmLocalGenerator::GetRealDependency(const char* inName, - const char* config, - bool* inLocal) + const char* config) { // Older CMake code may specify the dependency using the target // output file rather than the target name. Such code would have @@ -1634,22 +1633,8 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName, name = cmSystemTools::GetFilenameWithoutLastExtension(name); } - // Look for a CMake target in the current makefile. - cmTarget* target = m_Makefile->FindTarget(name.c_str()); - - // If no target was found in the current makefile search globally. - bool local = target?true:false; - if(inLocal) - { - *inLocal = local; - } - if(!local) - { - target = m_GlobalGenerator->FindTarget(0, name.c_str()); - } - - // If a target was found then get its real location. - if(target) + // Look for a CMake target with the given name. + if(cmTarget* target = m_GlobalGenerator->FindTarget(0, name.c_str())) { switch (target->GetType()) { @@ -1666,15 +1651,30 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName, } break; case cmTarget::UTILITY: + // Depending on a utility target may not work but just trust + // the user to have given a valid name. + return inName; case cmTarget::INSTALL_FILES: case cmTarget::INSTALL_PROGRAMS: break; } } - // The name was not that of a CMake target. The dependency should - // use the name as given. - return inName; + // The name was not that of a CMake target. It must name a file. + if(cmSystemTools::FileIsFullPath(inName)) + { + // This is a full path. Return it as given. + return inName; + } + else + { + // Treat the name as relative to the source directory in which it + // was given. + name = m_Makefile->GetCurrentDirectory(); + name += "/"; + name += inName; + return name; + } } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index a30217a..f60ad22 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -137,12 +137,12 @@ public: /** Translate a dependency as given in CMake code to the name to appear in a generated build file. If the given name is that of a CMake target it will be transformed to the real output - location of that target for the given configuration. Otherwise - the original name will be returned. If the local argument is - given it is set to indicate whethr the name is of a utility - target available in the same makefile. */ - std::string GetRealDependency(const char* name, const char* config, - bool* local=0); + location of that target for the given configuration. If the + given name is the full path to a file it will be returned. + Otherwise the name is treated as a relative path with respect to + the source directory of this generator. This should only be + used for dependencies of custom commands. */ + std::string GetRealDependency(const char* name, const char* config); ///! for existing files convert to output path and short path if spaces std::string ConvertToOutputForExisting(const char* p); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index e484a3c..c66bdea 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2270,6 +2270,7 @@ cmLocalUnixMakefileGenerator3 ::AppendTargetDepends(std::vector<std::string>& depends, cmTarget& target) { + // Static libraries never depend on anything for linking. if(target.GetType() == cmTarget::STATIC_LIBRARY) { return; @@ -2289,48 +2290,17 @@ cmLocalUnixMakefileGenerator3 // Don't emit the same library twice for this target. if(emitted.insert(lib->first).second) { - // Add this dependency. - this->AppendAnyDepend(depends, lib->first.c_str()); - } - } -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::AppendAnyDepend(std::vector<std::string>& depends, const char* name) -{ - // There are a few cases for the name of the target: - // - CMake target. - // - Full path to a file: depend on it. - // - Other format (like -lm): no file on which to depend, do nothing. - - // Lookup the real name of the dependency in case it is a CMake target. - bool local; - std::string dep = this->GetRealDependency(name, - m_ConfigurationName.c_str(), - &local); - if(dep == name) - { - if(local) - { - // The dependency is on a CMake utility target in the current - // makefile. Just depend on it directly. - depends.push_back(name); - } - else if(cmSystemTools::FileIsFullPath(name)) - { - // This is a path to a file. Just trust the listfile author - // that it will be present or there is a rule to build it. - depends.push_back(cmSystemTools::CollapseFullPath(name)); + // Depend only on other CMake targets. + if(cmTarget* tgt = m_GlobalGenerator->FindTarget(0, lib->first.c_str())) + { + if(const char* location = + tgt->GetLocation(m_ConfigurationName.c_str())) + { + depends.push_back(location); + } + } } } - else - { - // The dependency is on a CMake target and has been transformed to - // the target's location on disk. - depends.push_back(dep); - } } //---------------------------------------------------------------------------- @@ -2370,8 +2340,10 @@ cmLocalUnixMakefileGenerator3 for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin(); d != cc.GetDepends().end(); ++d) { - // Add this dependency. - this->AppendAnyDepend(depends, d->c_str()); + // Lookup the real name of the dependency in case it is a CMake target. + std::string dep = this->GetRealDependency(d->c_str(), + m_ConfigurationName.c_str()); + depends.push_back(dep); } } diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index cf383c3..b7a5b9b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -327,7 +327,6 @@ protected: const char* GetSourceFileLanguage(const cmSourceFile& source); std::string ConvertToQuotedOutputPath(const char* p); - void AppendAnyDepend(std::vector<std::string>& depends, const char* name); void AppendRuleDepend(std::vector<std::string>& depends, const char* ruleFileName); void AppendCustomDepends(std::vector<std::string>& depends, |