diff options
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 298 |
1 files changed, 0 insertions, 298 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1986e5f..576189f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -55,9 +55,6 @@ public: cmTarget::cmTarget() { this->Makefile = 0; -#if defined(_WIN32) && !defined(__CYGWIN__) - this->LinkLibrariesForVS6Analyzed = false; -#endif this->HaveInstallRule = false; this->DLLPlatform = false; this->IsAndroid = false; @@ -699,9 +696,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, cmTarget::LibraryID tmp; tmp.first = lib; tmp.second = llt; -#if defined(_WIN32) && !defined(__CYGWIN__) - this->LinkLibrariesForVS6.push_back( tmp ); -#endif this->OriginalLinkLibraries.push_back(tmp); // Add the explicit dependency information for this target. This is @@ -811,298 +805,6 @@ cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces); } -#if defined(_WIN32) && !defined(__CYGWIN__) -//---------------------------------------------------------------------------- -void -cmTarget::AnalyzeLibDependenciesForVS6( const cmMakefile& mf ) -{ - // There are two key parts of the dependency analysis: (1) - // determining the libraries in the link line, and (2) constructing - // the dependency graph for those libraries. - // - // The latter is done using the cache entries that record the - // dependencies of each library. - // - // The former is a more thorny issue, since it is not clear how to - // determine if two libraries listed on the link line refer to the a - // single library or not. For example, consider the link "libraries" - // /usr/lib/libtiff.so -ltiff - // Is this one library or two? The solution implemented here is the - // simplest (and probably the only practical) one: two libraries are - // the same if their "link strings" are identical. Thus, the two - // libraries above are considered distinct. This also means that for - // dependency analysis to be effective, the CMake user must specify - // libraries build by his project without using any linker flags or - // file extensions. That is, - // LINK_LIBRARIES( One Two ) - // instead of - // LINK_LIBRARIES( -lOne ${binarypath}/libTwo.a ) - // The former is probably what most users would do, but it never - // hurts to document the assumptions. :-) Therefore, in the analysis - // code, the "canonical name" of a library is simply its name as - // given to a LINK_LIBRARIES command. - // - // Also, we will leave the original link line intact; we will just add any - // dependencies that were missing. - // - // There is a problem with recursive external libraries - // (i.e. libraries with no dependency information that are - // recursively dependent). We must make sure that the we emit one of - // the libraries twice to satisfy the recursion, but we shouldn't - // emit it more times than necessary. In particular, we must make - // sure that handling this improbable case doesn't cost us when - // dealing with the common case of non-recursive libraries. The - // solution is to assume that the recursion is satisfied at one node - // of the dependency tree. To illustrate, assume libA and libB are - // extrenal and mutually dependent. Suppose libX depends on - // libA, and libY on libA and libX. Then - // TARGET_LINK_LIBRARIES( Y X A B A ) - // TARGET_LINK_LIBRARIES( X A B A ) - // TARGET_LINK_LIBRARIES( Exec Y ) - // would result in "-lY -lX -lA -lB -lA". This is the correct way to - // specify the dependencies, since the mutual dependency of A and B - // is resolved *every time libA is specified*. - // - // Something like - // TARGET_LINK_LIBRARIES( Y X A B A ) - // TARGET_LINK_LIBRARIES( X A B ) - // TARGET_LINK_LIBRARIES( Exec Y ) - // would result in "-lY -lX -lA -lB", and the mutual dependency - // information is lost. This is because in some case (Y), the mutual - // dependency of A and B is listed, while in another other case (X), - // it is not. Depending on which line actually emits A, the mutual - // dependency may or may not be on the final link line. We can't - // handle this pathalogical case cleanly without emitting extra - // libraries for the normal cases. Besides, the dependency - // information for X is wrong anyway: if we build an executable - // depending on X alone, we would not have the mutual dependency on - // A and B resolved. - // - // IMPROVEMENTS: - // -- The current algorithm will not always pick the "optimal" link line - // when recursive dependencies are present. It will instead break the - // cycles at an aribtrary point. The majority of projects won't have - // cyclic dependencies, so this is probably not a big deal. Note that - // the link line is always correct, just not necessary optimal. - - { - // Expand variables in link library names. This is for backwards - // compatibility with very early CMake versions and should - // eventually be removed. This code was moved here from the end of - // old source list processing code which was called just before this - // method. - for(LinkLibraryVectorType::iterator p = this->LinkLibrariesForVS6.begin(); - p != this->LinkLibrariesForVS6.end(); ++p) - { - this->Makefile->ExpandVariablesInString(p->first, true, true); - } - } - - // The dependency map. - DependencyMap dep_map; - - // 1. Build the dependency graph - // - for(LinkLibraryVectorType::reverse_iterator lib - = this->LinkLibrariesForVS6.rbegin(); - lib != this->LinkLibrariesForVS6.rend(); ++lib) - { - this->GatherDependenciesForVS6( mf, *lib, dep_map); - } - - // 2. Remove any dependencies that are already satisfied in the original - // link line. - // - for(LinkLibraryVectorType::iterator lib = this->LinkLibrariesForVS6.begin(); - lib != this->LinkLibrariesForVS6.end(); ++lib) - { - for( LinkLibraryVectorType::iterator lib2 = lib; - lib2 != this->LinkLibrariesForVS6.end(); ++lib2) - { - this->DeleteDependencyForVS6( dep_map, *lib, *lib2); - } - } - - - // 3. Create the new link line by simply emitting any dependencies that are - // missing. Start from the back and keep adding. - // - std::set<DependencyMap::key_type> done, visited; - std::vector<DependencyMap::key_type> newLinkLibrariesForVS6; - for(LinkLibraryVectorType::reverse_iterator lib = - this->LinkLibrariesForVS6.rbegin(); - lib != this->LinkLibrariesForVS6.rend(); ++lib) - { - // skip zero size library entries, this may happen - // if a variable expands to nothing. - if (!lib->first.empty()) - { - this->EmitForVS6( *lib, dep_map, done, visited, newLinkLibrariesForVS6 ); - } - } - - // 4. Add the new libraries to the link line. - // - for( std::vector<DependencyMap::key_type>::reverse_iterator k = - newLinkLibrariesForVS6.rbegin(); - k != newLinkLibrariesForVS6.rend(); ++k ) - { - // get the llt from the dep_map - this->LinkLibrariesForVS6.push_back( std::make_pair(k->first,k->second) ); - } - this->LinkLibrariesForVS6Analyzed = true; -} - -//---------------------------------------------------------------------------- -void cmTarget::InsertDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep) -{ - depMap[lib].push_back(dep); -} - -//---------------------------------------------------------------------------- -void cmTarget::DeleteDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep) -{ - // Make sure there is an entry in the map for lib. If so, delete all - // dependencies to dep. There may be repeated entries because of - // external libraries that are specified multiple times. - DependencyMap::iterator map_itr = depMap.find( lib ); - if( map_itr != depMap.end() ) - { - DependencyList& depList = map_itr->second; - DependencyList::iterator begin = - std::remove(depList.begin(), depList.end(), dep); - depList.erase(begin, depList.end()); - } -} - -//---------------------------------------------------------------------------- -void cmTarget::EmitForVS6(const LibraryID lib, - const DependencyMap& dep_map, - std::set<LibraryID>& emitted, - std::set<LibraryID>& visited, - DependencyList& link_line ) -{ - // It's already been emitted - if( emitted.find(lib) != emitted.end() ) - { - return; - } - - // Emit the dependencies only if this library node hasn't been - // visited before. If it has, then we have a cycle. The recursion - // that got us here should take care of everything. - - if( visited.insert(lib).second ) - { - if( dep_map.find(lib) != dep_map.end() ) // does it have dependencies? - { - const DependencyList& dep_on = dep_map.find( lib )->second; - DependencyList::const_reverse_iterator i; - - // To cater for recursive external libraries, we must emit - // duplicates on this link line *unless* they were emitted by - // some other node, in which case we assume that the recursion - // was resolved then. We making the simplifying assumption that - // any duplicates on a single link line are on purpose, and must - // be preserved. - - // This variable will keep track of the libraries that were - // emitted directly from the current node, and not from a - // recursive call. This way, if we come across a library that - // has already been emitted, we repeat it iff it has been - // emitted here. - std::set<DependencyMap::key_type> emitted_here; - for( i = dep_on.rbegin(); i != dep_on.rend(); ++i ) - { - if( emitted_here.find(*i) != emitted_here.end() ) - { - // a repeat. Must emit. - emitted.insert(*i); - link_line.push_back( *i ); - } - else - { - // Emit only if no-one else has - if( emitted.find(*i) == emitted.end() ) - { - // emit dependencies - this->EmitForVS6( *i, dep_map, emitted, visited, link_line ); - // emit self - emitted.insert(*i); - emitted_here.insert(*i); - link_line.push_back( *i ); - } - } - } - } - } -} - -//---------------------------------------------------------------------------- -void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf, - const LibraryID& lib, - DependencyMap& dep_map) -{ - // If the library is already in the dependency map, then it has - // already been fully processed. - if( dep_map.find(lib) != dep_map.end() ) - { - return; - } - - const char* deps = mf.GetDefinition( lib.first+"_LIB_DEPENDS" ); - if( deps && strcmp(deps,"") != 0 ) - { - // Make sure this library is in the map, even if it has an empty - // set of dependencies. This distinguishes the case of explicitly - // no dependencies with that of unspecified dependencies. - dep_map[lib]; - - // Parse the dependency information, which is a set of - // type, library pairs separated by ";". There is always a trailing ";". - cmTargetLinkLibraryType llt = GENERAL_LibraryType; - std::string depline = deps; - std::string::size_type start = 0; - std::string::size_type end; - end = depline.find( ";", start ); - while( end != std::string::npos ) - { - std::string l = depline.substr( start, end-start ); - if(!l.empty()) - { - if (l == "debug") - { - llt = DEBUG_LibraryType; - } - else if (l == "optimized") - { - llt = OPTIMIZED_LibraryType; - } - else if (l == "general") - { - llt = GENERAL_LibraryType; - } - else - { - LibraryID lib2(l,llt); - this->InsertDependencyForVS6( dep_map, lib, lib2); - this->GatherDependenciesForVS6( mf, lib2, dep_map); - llt = GENERAL_LibraryType; - } - } - start = end+1; // skip the ; - end = depline.find( ";", start ); - } - // cannot depend on itself - this->DeleteDependencyForVS6( dep_map, lib, lib); - } -} -#endif - //---------------------------------------------------------------------------- static bool whiteListedInterfaceProperty(const std::string& prop) { |