make it backwards compatible with old cmake
This commit is contained in:
parent
2242006ca1
commit
a80153b5cb
|
@ -423,11 +423,20 @@ void cmMakefile::FinalPass()
|
||||||
void cmMakefile::GenerateMakefile()
|
void cmMakefile::GenerateMakefile()
|
||||||
{
|
{
|
||||||
this->FinalPass();
|
this->FinalPass();
|
||||||
|
const char* versionValue
|
||||||
|
= this->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
|
||||||
|
bool oldVersion = (!versionValue || atof(versionValue) < 1.4);
|
||||||
// merge libraries
|
// merge libraries
|
||||||
|
|
||||||
for (cmTargets::iterator l = m_Targets.begin();
|
for (cmTargets::iterator l = m_Targets.begin();
|
||||||
l != m_Targets.end(); l++)
|
l != m_Targets.end(); l++)
|
||||||
{
|
{
|
||||||
l->second.GenerateSourceFilesFromSourceLists(*this);
|
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);
|
l->second.AnalyzeLibDependencies(*this);
|
||||||
}
|
}
|
||||||
// now do the generation
|
// now do the generation
|
||||||
|
@ -647,6 +656,23 @@ void cmMakefile::SetProjectName(const char* p)
|
||||||
m_ProjectName = 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,
|
void cmMakefile::AddLibrary(const char* lname, int shared,
|
||||||
const std::vector<std::string> &srcs)
|
const std::vector<std::string> &srcs)
|
||||||
{
|
{
|
||||||
|
@ -672,25 +698,13 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
|
||||||
depname += "_LIB_DEPENDS";
|
depname += "_LIB_DEPENDS";
|
||||||
cmCacheManager::GetInstance()->
|
cmCacheManager::GetInstance()->
|
||||||
AddCacheEntry(depname.c_str(), "",
|
AddCacheEntry(depname.c_str(), "",
|
||||||
"Dependencies for target", cmCacheManager::INTERNAL);
|
"Dependencies for target", cmCacheManager::STATIC);
|
||||||
|
|
||||||
|
|
||||||
target.SetInAll(true);
|
target.SetInAll(true);
|
||||||
target.GetSourceLists() = srcs;
|
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));
|
m_Targets.insert(cmTargets::value_type(lname,target));
|
||||||
cmTarget::LinkLibraries::iterator i;
|
this->AddGlobalLinkInformation(lname, target);
|
||||||
for(i = m_LinkLibraries.begin(); i != m_LinkLibraries.end(); ++i)
|
|
||||||
{
|
|
||||||
this->AddLinkLibraryForTarget(lname, i->first.c_str(), i->second);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add an entry into the cache
|
// Add an entry into the cache
|
||||||
cmCacheManager::GetInstance()->
|
cmCacheManager::GetInstance()->
|
||||||
|
@ -755,18 +769,8 @@ void cmMakefile::AddExecutable(const char *exeName,
|
||||||
}
|
}
|
||||||
target.SetInAll(true);
|
target.SetInAll(true);
|
||||||
target.GetSourceLists() = srcs;
|
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));
|
m_Targets.insert(cmTargets::value_type(exeName,target));
|
||||||
cmTarget::LinkLibraries::iterator i;
|
this->AddGlobalLinkInformation(exeName, target);
|
||||||
for(i = m_LinkLibraries.begin(); i != m_LinkLibraries.end(); ++i)
|
|
||||||
{
|
|
||||||
this->AddLinkLibraryForTarget(exeName, i->first.c_str(), i->second);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add an entry into the cache
|
// Add an entry into the cache
|
||||||
cmCacheManager::GetInstance()->
|
cmCacheManager::GetInstance()->
|
||||||
|
@ -1402,25 +1406,3 @@ 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 );
|
|
||||||
}
|
|
||||||
|
|
|
@ -505,12 +505,10 @@ 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:
|
||||||
|
// add link libraries and directories to the target
|
||||||
|
void AddGlobalLinkInformation(const char* name, cmTarget& target);
|
||||||
|
|
||||||
std::string m_Prefix;
|
std::string m_Prefix;
|
||||||
std::vector<std::string> m_AuxSourceDirectories; //
|
std::vector<std::string> m_AuxSourceDirectories; //
|
||||||
|
|
||||||
|
|
|
@ -89,17 +89,34 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
|
||||||
case cmTarget::DEBUG:
|
case cmTarget::DEBUG:
|
||||||
mf.AddCacheDefinition(linkTypeName.c_str(),
|
mf.AddCacheDefinition(linkTypeName.c_str(),
|
||||||
"debug", "Library is used for debug links only",
|
"debug", "Library is used for debug links only",
|
||||||
cmCacheManager::INTERNAL);
|
cmCacheManager::STATIC);
|
||||||
break;
|
break;
|
||||||
case cmTarget::OPTIMIZED:
|
case cmTarget::OPTIMIZED:
|
||||||
mf.AddCacheDefinition(linkTypeName.c_str(),
|
mf.AddCacheDefinition(linkTypeName.c_str(),
|
||||||
"optimized", "Library is used for debug links only",
|
"optimized", "Library is used for debug links only",
|
||||||
cmCacheManager::INTERNAL);
|
cmCacheManager::STATIC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 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 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
|
bool cmTarget::HasCxx() const
|
||||||
|
|
Loading…
Reference in New Issue