BUG: The library paths should stay with the libraries during dependency analysis.
This commit is contained in:
parent
27fe57b716
commit
4fe8947bcc
|
@ -103,11 +103,15 @@ bool cmTarget::HasCxx() const
|
||||||
void
|
void
|
||||||
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
|
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
|
||||||
{
|
{
|
||||||
typedef std::map< std::string, std::pair<std::string,LinkLibraryType> > LibMap;
|
|
||||||
typedef std::vector< std::string > LinkLine;
|
typedef std::vector< std::string > LinkLine;
|
||||||
|
|
||||||
// Maps the canonical names to the full objects of m_LinkLibraries.
|
// Maps the canonical names to the full objects of m_LinkLibraries.
|
||||||
LibMap lib_map;
|
LibTypeMap lib_map;
|
||||||
|
|
||||||
|
// The unique list of libraries on the orginal link line. They
|
||||||
|
// correspond to lib_map keys. However, lib_map will also get
|
||||||
|
// further populated by the dependency analysis.
|
||||||
|
LinkLine orig_libs;
|
||||||
|
|
||||||
// The list canonical names in the order they were orginally
|
// The list canonical names in the order they were orginally
|
||||||
// specified on the link line (m_LinkLibraries).
|
// specified on the link line (m_LinkLibraries).
|
||||||
|
@ -124,15 +128,19 @@ cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
|
||||||
if (lib->first.size() == 0) continue;
|
if (lib->first.size() == 0) continue;
|
||||||
|
|
||||||
std::string cname = CanonicalLibraryName(lib->first);
|
std::string cname = CanonicalLibraryName(lib->first);
|
||||||
lib_map[ cname ] = *lib;
|
|
||||||
lib_order.push_back( cname );
|
lib_order.push_back( cname );
|
||||||
|
if( lib_map.end() == lib_map.find( cname ) )
|
||||||
|
{
|
||||||
|
lib_map[ cname ] = *lib;
|
||||||
|
orig_libs.push_back( cname );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, get the explicit dependencies for those libraries that
|
// First, get the explicit dependencies for those libraries that
|
||||||
// have specified them
|
// have specified them
|
||||||
for( LibMap::iterator i = lib_map.begin(); i != lib_map.end(); ++i )
|
for( LinkLine::iterator i = orig_libs.begin(); i != orig_libs.end(); ++i )
|
||||||
{
|
{
|
||||||
GatherDependencies( mf, i->first, dep_map );
|
GatherDependencies( mf, *i, dep_map, lib_map );
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the rest, get implicit dependencies. A library x depends
|
// For the rest, get implicit dependencies. A library x depends
|
||||||
|
@ -146,20 +154,20 @@ cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
|
||||||
// [*1] This prevents external libraries from depending on libraries
|
// [*1] This prevents external libraries from depending on libraries
|
||||||
// generated by this project.
|
// generated by this project.
|
||||||
|
|
||||||
for( LibMap::iterator i = lib_map.begin(); i != lib_map.end(); ++i )
|
for( LinkLine::iterator i = orig_libs.begin(); i != orig_libs.end(); ++i )
|
||||||
{
|
{
|
||||||
if( dep_map.find( i->first ) == dep_map.end() )
|
if( dep_map.find( *i ) == dep_map.end() )
|
||||||
{
|
{
|
||||||
LinkLine::iterator pos = std::find( lib_order.begin(), lib_order.end(), i->first );
|
LinkLine::iterator pos = std::find( lib_order.begin(), lib_order.end(), *i );
|
||||||
for( ; pos != lib_order.end(); ++pos )
|
for( ; pos != lib_order.end(); ++pos )
|
||||||
{
|
{
|
||||||
std::set<std::string> visited;
|
std::set<std::string> visited;
|
||||||
if( !DependsOn( *pos, i->first, dep_map, visited ) )
|
if( !DependsOn( *pos, *i, dep_map, visited ) )
|
||||||
{
|
{
|
||||||
dep_map_implicit[ i->first ].insert( *pos );
|
dep_map_implicit[ *i ].insert( *pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dep_map_implicit[ i->first ].erase( i->first ); // cannot depend on itself
|
dep_map_implicit[ *i ].erase( *i ); // cannot depend on itself
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +183,9 @@ cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
|
||||||
// Create a new link line order.
|
// Create a new link line order.
|
||||||
std::set<std::string> done, visited;
|
std::set<std::string> done, visited;
|
||||||
std::vector<std::string> link_line;
|
std::vector<std::string> link_line;
|
||||||
for( LibMap::iterator i = lib_map.begin(); i != lib_map.end(); ++i )
|
for( LinkLine::iterator i = orig_libs.begin(); i != orig_libs.end(); ++i )
|
||||||
{
|
{
|
||||||
Emit( i->first, dep_map, done, visited, link_line );
|
Emit( *i, dep_map, done, visited, link_line );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,7 +303,8 @@ void cmTarget::Emit( const std::string& lib,
|
||||||
|
|
||||||
void cmTarget::GatherDependencies( const cmMakefile& mf,
|
void cmTarget::GatherDependencies( const cmMakefile& mf,
|
||||||
const std::string& lib,
|
const std::string& lib,
|
||||||
DependencyMap& dep_map ) const
|
DependencyMap& dep_map,
|
||||||
|
LibTypeMap& lib_map ) const
|
||||||
{
|
{
|
||||||
// If the library is already in the dependency map, then it has
|
// If the library is already in the dependency map, then it has
|
||||||
// already been fully processed.
|
// already been fully processed.
|
||||||
|
@ -322,8 +331,9 @@ void cmTarget::GatherDependencies( const cmMakefile& mf,
|
||||||
if( l.size() != 0 )
|
if( l.size() != 0 )
|
||||||
{
|
{
|
||||||
const std::string cname = CanonicalLibraryName(l);
|
const std::string cname = CanonicalLibraryName(l);
|
||||||
|
lib_map[ cname ] = std::make_pair(l,GENERAL); // ** FIXME: we need to store the correct type here
|
||||||
dep_map[ lib ].insert( cname );
|
dep_map[ lib ].insert( cname );
|
||||||
GatherDependencies( mf, cname, dep_map );
|
GatherDependencies( mf, cname, dep_map, lib_map );
|
||||||
}
|
}
|
||||||
start = end+1; // skip the ;
|
start = end+1; // skip the ;
|
||||||
end = depline.find( ";", start );
|
end = depline.find( ";", start );
|
||||||
|
|
|
@ -120,6 +120,11 @@ private:
|
||||||
*/
|
*/
|
||||||
typedef std::map< std::string, std::set< std::string > > DependencyMap;
|
typedef std::map< std::string, std::set< std::string > > DependencyMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a canonical library name to it's proper type
|
||||||
|
*/
|
||||||
|
typedef std::map< std::string, std::pair<std::string,LinkLibraryType> > LibTypeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For each library in the link line, return a canonical name. The
|
* For each library in the link line, return a canonical name. The
|
||||||
* orginal library names have complicated forms, such as "x",
|
* orginal library names have complicated forms, such as "x",
|
||||||
|
@ -146,7 +151,8 @@ private:
|
||||||
* specified, and inserts them into \param dep_map.
|
* specified, and inserts them into \param dep_map.
|
||||||
*/
|
*/
|
||||||
void GatherDependencies( const cmMakefile& mf, const std::string& lib,
|
void GatherDependencies( const cmMakefile& mf, const std::string& lib,
|
||||||
DependencyMap& dep_map ) const;
|
DependencyMap& dep_map,
|
||||||
|
LibTypeMap& lib_map ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if lib1 depends on lib2 according to \param
|
* Returns true if lib1 depends on lib2 according to \param
|
||||||
|
|
Loading…
Reference in New Issue