ENH: Make the LinkLibraries command contribute dependencies towards AddLibraries.
This commit is contained in:
parent
36f80fe6c8
commit
099436db26
|
@ -33,7 +33,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator s = args.begin();
|
std::vector<std::string>::const_iterator s = args.begin();
|
||||||
|
|
||||||
std::string libname = *s;
|
m_LibName = *s;
|
||||||
|
|
||||||
++s;
|
++s;
|
||||||
|
|
||||||
|
@ -67,8 +67,18 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
|
||||||
++s;
|
++s;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Makefile->AddLibrary(libname.c_str(), shared, srclists);
|
m_Makefile->AddLibrary(m_LibName.c_str(), shared, srclists);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmAddLibraryCommand::FinalPass()
|
||||||
|
{
|
||||||
|
const cmTarget::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
|
||||||
|
|
||||||
|
for( cmTarget::LinkLibraries::const_iterator i = libs.begin();
|
||||||
|
i != libs.end(); ++i )
|
||||||
|
{
|
||||||
|
m_Makefile->AddDependencyToCache( m_LibName.c_str(), i->first );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -43,6 +43,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool InitialPass(std::vector<std::string> const& args);
|
virtual bool InitialPass(std::vector<std::string> const& args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called at the end after all the information specified by
|
||||||
|
* the command is accumulated. This is where we add in the
|
||||||
|
* dependencies that were globally specified.
|
||||||
|
*/
|
||||||
|
virtual void FinalPass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the command as specified in CMakeList.txt.
|
* The name of the command as specified in CMakeList.txt.
|
||||||
*/
|
*/
|
||||||
|
@ -72,6 +79,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmAddLibraryCommand, cmCommand);
|
cmTypeMacro(cmAddLibraryCommand, cmCommand);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_LibName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1362,3 +1362,26 @@ void cmMakefile::EnableLanguage(const char* lang)
|
||||||
{
|
{
|
||||||
m_MakefileGenerator->EnableLanguage(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 );
|
||||||
|
}
|
||||||
|
|
|
@ -155,13 +155,13 @@ public:
|
||||||
const std::vector<std::string> &depends,
|
const std::vector<std::string> &depends,
|
||||||
const std::vector<std::string> &outputs);
|
const std::vector<std::string> &outputs);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Get a list of link libraries in the build.
|
// * Get a list of link libraries in the build.
|
||||||
*/
|
// */
|
||||||
cmTarget::LinkLibraries& GetLinkLibraries()
|
// cmTarget::LinkLibraries& GetLinkLibraries()
|
||||||
{
|
// {
|
||||||
return m_LinkLibraries;
|
// return m_LinkLibraries;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of link libraries in the build.
|
* Get a list of link libraries in the build.
|
||||||
|
@ -519,6 +519,11 @@ public:
|
||||||
|
|
||||||
///! Enable support for the named language, if null then all languages are enabled.
|
///! Enable support for the named language, if null then all languages are enabled.
|
||||||
void EnableLanguage(const char* );
|
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:
|
protected:
|
||||||
std::string m_Prefix;
|
std::string m_Prefix;
|
||||||
|
|
|
@ -90,25 +90,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
|
||||||
{
|
{
|
||||||
m_LinkLibraries.push_back( std::pair<std::string, cmTarget::LinkLibraryType>(lib,llt) );
|
m_LinkLibraries.push_back( std::pair<std::string, cmTarget::LinkLibraryType>(lib,llt) );
|
||||||
|
|
||||||
// Add the explicit dependency information for this target. This is
|
mf.AddDependencyToCache( target, lib );
|
||||||
// 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 cache_name( target );
|
|
||||||
cache_name += "_LIB_DEPENDS";
|
|
||||||
std::string dependencies;
|
|
||||||
const char* old_val = mf.GetDefinition( cache_name.c_str() );
|
|
||||||
if( old_val )
|
|
||||||
{
|
|
||||||
dependencies += old_val;
|
|
||||||
}
|
|
||||||
if( dependencies.find( lib ) == std::string::npos )
|
|
||||||
{
|
|
||||||
dependencies += lib;
|
|
||||||
dependencies += ";";
|
|
||||||
}
|
|
||||||
mf.AddCacheDefinition( cache_name.c_str(), dependencies.c_str(),
|
|
||||||
"Dependencies for the target", cmCacheManager::INTERNAL );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmTarget::HasCxx() const
|
bool cmTarget::HasCxx() const
|
||||||
|
@ -125,6 +107,9 @@ bool cmTarget::HasCxx() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
|
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@ SET( CMAKE_ANALYZE_LIB_DEPENDS "ON" )
|
||||||
# One:
|
# One:
|
||||||
# Two: Three
|
# Two: Three
|
||||||
# Three: One Four
|
# Three: One Four
|
||||||
# Four: One Two A
|
# Four: One Two NoDepA
|
||||||
# Five: Two
|
# Five: Two
|
||||||
# SixA: Two Five
|
# SixA: Two Five
|
||||||
# SixB: Four Five
|
# SixB: Four Five
|
||||||
|
|
Loading…
Reference in New Issue