diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2002-05-02 19:56:13 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2002-05-02 19:56:13 (GMT) |
commit | a80153b5cb077e99ff81eca947643099430ba391 (patch) | |
tree | eca46cd73aa79466bb7208d3f91a7aa3d2dd14ad /Source | |
parent | 2242006ca1f6834059d23b761dafd4ad7e70661b (diff) | |
download | CMake-a80153b5cb077e99ff81eca947643099430ba391.zip CMake-a80153b5cb077e99ff81eca947643099430ba391.tar.gz CMake-a80153b5cb077e99ff81eca947643099430ba391.tar.bz2 |
make it backwards compatible with old cmake
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefile.cxx | 76 | ||||
-rw-r--r-- | Source/cmMakefile.h | 8 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 25 |
3 files changed, 53 insertions, 56 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 55acc50..f8bd461 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -423,11 +423,20 @@ void cmMakefile::FinalPass() void cmMakefile::GenerateMakefile() { this->FinalPass(); + const char* versionValue + = this->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); + bool oldVersion = (!versionValue || atof(versionValue) < 1.4); // merge libraries + for (cmTargets::iterator l = m_Targets.begin(); l != m_Targets.end(); l++) { l->second.GenerateSourceFilesFromSourceLists(*this); + // pick up any LINK_LIBRARIES that were added after the target + if(oldVersion) + { + this->AddGlobalLinkInformation(l->first.c_str(), l->second); + } l->second.AnalyzeLibDependencies(*this); } // now do the generation @@ -647,6 +656,23 @@ void cmMakefile::SetProjectName(const char* p) m_ProjectName = p; } + +void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) +{ + std::vector<std::string>::iterator j; + for(j = m_LinkDirectories.begin(); + j != m_LinkDirectories.end(); ++j) + { + target.AddLinkDirectory(j->c_str()); + } + cmTarget::LinkLibraries::iterator i; + for(i = m_LinkLibraries.begin(); i != m_LinkLibraries.end(); ++i) + { + this->AddLinkLibraryForTarget(name, i->first.c_str(), i->second); + } +} + + void cmMakefile::AddLibrary(const char* lname, int shared, const std::vector<std::string> &srcs) { @@ -672,25 +698,13 @@ void cmMakefile::AddLibrary(const char* lname, int shared, depname += "_LIB_DEPENDS"; cmCacheManager::GetInstance()-> AddCacheEntry(depname.c_str(), "", - "Dependencies for target", cmCacheManager::INTERNAL); + "Dependencies for target", cmCacheManager::STATIC); target.SetInAll(true); target.GetSourceLists() = srcs; - std::vector<std::string>::iterator j; - for(j = m_LinkDirectories.begin(); - j != m_LinkDirectories.end(); ++j) - { - target.AddLinkDirectory(j->c_str()); - } m_Targets.insert(cmTargets::value_type(lname,target)); - cmTarget::LinkLibraries::iterator i; - for(i = m_LinkLibraries.begin(); i != m_LinkLibraries.end(); ++i) - { - this->AddLinkLibraryForTarget(lname, i->first.c_str(), i->second); - } - - + this->AddGlobalLinkInformation(lname, target); // Add an entry into the cache cmCacheManager::GetInstance()-> @@ -755,18 +769,8 @@ void cmMakefile::AddExecutable(const char *exeName, } target.SetInAll(true); target.GetSourceLists() = srcs; - std::vector<std::string>::iterator j; - for(j = m_LinkDirectories.begin(); - j != m_LinkDirectories.end(); ++j) - { - target.AddLinkDirectory(j->c_str()); - } m_Targets.insert(cmTargets::value_type(exeName,target)); - cmTarget::LinkLibraries::iterator i; - for(i = m_LinkLibraries.begin(); i != m_LinkLibraries.end(); ++i) - { - this->AddLinkLibraryForTarget(exeName, i->first.c_str(), i->second); - } + this->AddGlobalLinkInformation(exeName, target); // Add an entry into the cache cmCacheManager::GetInstance()-> @@ -1402,25 +1406,3 @@ void cmMakefile::EnableLanguage(const char* lang) m_MakefileGenerator->EnableLanguage(lang); } - -void cmMakefile::AddDependencyToCache( std::string target, const std::string& lib ) -{ - // Add the explicit dependency information for this target. This is - // simply a set of libraries separated by ";". There should always - // be a trailing ";". These library names are not canonical, in that - // they may be "-framework x", "-ly", "/path/libz.a", etc. - target += "_LIB_DEPENDS"; - std::string dependencies; - const char* old_val = GetDefinition( target.c_str() ); - if( old_val ) - { - dependencies += old_val; - } - if( dependencies.find( lib ) == std::string::npos ) - { - dependencies += lib; - dependencies += ";"; - } - AddCacheDefinition( target.c_str(), dependencies.c_str(), - "Dependencies for the target", cmCacheManager::INTERNAL ); -} diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1914dc0..a4ea424 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -505,12 +505,10 @@ public: ///! Enable support for the named language, if null then all languages are enabled. void EnableLanguage(const char* ); - /** - * Adds the specified library to the explicit dependency list of target. - */ - void AddDependencyToCache( std::string target, const std::string& lib ); - protected: + // add link libraries and directories to the target + void AddGlobalLinkInformation(const char* name, cmTarget& target); + std::string m_Prefix; std::vector<std::string> m_AuxSourceDirectories; // diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7d3dda7..51a270c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -89,17 +89,34 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, case cmTarget::DEBUG: mf.AddCacheDefinition(linkTypeName.c_str(), "debug", "Library is used for debug links only", - cmCacheManager::INTERNAL); + cmCacheManager::STATIC); break; case cmTarget::OPTIMIZED: mf.AddCacheDefinition(linkTypeName.c_str(), "optimized", "Library is used for debug links only", - cmCacheManager::INTERNAL); + cmCacheManager::STATIC); break; } } - - mf.AddDependencyToCache( target, lib ); + // Add the explicit dependency information for this target. This is + // simply a set of libraries separated by ";". There should always + // be a trailing ";". These library names are not canonical, in that + // they may be "-framework x", "-ly", "/path/libz.a", etc. + std::string targetEntry = target; + targetEntry += "_LIB_DEPENDS"; + std::string dependencies; + const char* old_val = mf.GetDefinition( targetEntry.c_str() ); + if( old_val ) + { + dependencies += old_val; + } + if( dependencies.find( lib ) == std::string::npos ) + { + dependencies += lib; + dependencies += ";"; + } + mf.AddCacheDefinition( targetEntry.c_str(), dependencies.c_str(), + "Dependencies for the target", cmCacheManager::STATIC ); } bool cmTarget::HasCxx() const |