mirror of
https://github.com/reactos/CMake.git
synced 2024-12-15 23:57:44 +00:00
Properly insert all targets, also those which don't link to anything.
Alex
This commit is contained in:
parent
de2b2bf9ef
commit
487bd571d5
129
Source/cmake.cxx
129
Source/cmake.cxx
@ -2835,10 +2835,31 @@ const char* cmake::GetCPackCommand()
|
|||||||
return this->CPackCommand.c_str();
|
return this->CPackCommand.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// for target deps
|
|
||||||
#define DOT_DEP_TARGET 1
|
static const char* getShapeForTarget(const cmTarget* target)
|
||||||
#define DOT_DEP_EXTERNAL 2
|
{
|
||||||
#define DOT_DEP_NONE 0
|
if (!target)
|
||||||
|
{
|
||||||
|
return "ellipse";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( target->GetType() )
|
||||||
|
{
|
||||||
|
case cmTarget::EXECUTABLE:
|
||||||
|
return "house";
|
||||||
|
case cmTarget::STATIC_LIBRARY:
|
||||||
|
return "diamond";
|
||||||
|
case cmTarget::SHARED_LIBRARY:
|
||||||
|
return "polygon";
|
||||||
|
case cmTarget::MODULE_LIBRARY:
|
||||||
|
return "octagon";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "box";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmake::GenerateGraphViz(const char* fileName) const
|
void cmake::GenerateGraphViz(const char* fileName) const
|
||||||
{
|
{
|
||||||
@ -2910,7 +2931,6 @@ void cmake::GenerateGraphViz(const char* fileName) const
|
|||||||
const std::vector<cmLocalGenerator*>& localGenerators =
|
const std::vector<cmLocalGenerator*>& localGenerators =
|
||||||
gg->GetLocalGenerators();
|
gg->GetLocalGenerators();
|
||||||
|
|
||||||
std::map<cmStdString, int> targetDeps;
|
|
||||||
std::map<cmStdString, const cmTarget*> targetPtrs;
|
std::map<cmStdString, const cmTarget*> targetPtrs;
|
||||||
std::map<cmStdString, cmStdString> targetNamesNodes; // maps from the actual strings to node names in dot
|
std::map<cmStdString, cmStdString> targetNamesNodes; // maps from the actual strings to node names in dot
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
@ -2918,64 +2938,20 @@ void cmake::GenerateGraphViz(const char* fileName) const
|
|||||||
graphNodePrefix);
|
graphNodePrefix);
|
||||||
|
|
||||||
cnt += getAllExternalLibs(ignoreTargetsSet, targetNamesNodes, targetPtrs,
|
cnt += getAllExternalLibs(ignoreTargetsSet, targetNamesNodes, targetPtrs,
|
||||||
targetDeps, graphNodePrefix);
|
graphNodePrefix);
|
||||||
|
|
||||||
|
|
||||||
// Write out nodes
|
// Write out nodes
|
||||||
for(std::map<cmStdString, int>::const_iterator depIt = targetDeps.begin();
|
for(std::map<cmStdString, const cmTarget*>::const_iterator tarIt =
|
||||||
depIt != targetDeps.end();
|
targetPtrs.begin(); tarIt != targetPtrs.end(); ++ tarIt )
|
||||||
++ depIt )
|
|
||||||
{
|
{
|
||||||
const char* newTargetName = depIt->first.c_str();
|
const char* newTargetName = tarIt->first.c_str();
|
||||||
std::map<cmStdString, cmStdString>::const_iterator tarIt =
|
std::map<cmStdString, cmStdString>::const_iterator nameIt =
|
||||||
targetNamesNodes.find(newTargetName);
|
targetNamesNodes.find(newTargetName);
|
||||||
if ( tarIt == targetNamesNodes.end() )
|
|
||||||
{
|
|
||||||
// We should not be here.
|
|
||||||
std::cout << __LINE__ << " Cannot find library: " << newTargetName
|
|
||||||
<< " even though it was added in the previous pass"
|
|
||||||
<< std::endl;
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
str << " \"" << tarIt->second.c_str() << "\" [ label=\""
|
str << " \"" << nameIt->second.c_str() << "\" [ label=\""
|
||||||
<< newTargetName << "\" shape=\"";
|
<< newTargetName << "\" shape=\"" << getShapeForTarget(tarIt->second)
|
||||||
if ( depIt->second == DOT_DEP_TARGET )
|
<< "\"];" << std::endl;
|
||||||
{
|
|
||||||
std::map<cmStdString, const cmTarget*>::const_iterator tarTypeIt =
|
|
||||||
targetPtrs.find(newTargetName);
|
|
||||||
if ( tarTypeIt == targetPtrs.end() )
|
|
||||||
{
|
|
||||||
// We should not be here.
|
|
||||||
std::cout << __LINE__ << " Cannot find library: " << newTargetName
|
|
||||||
<< " even though it was added in the previous pass"
|
|
||||||
<< std::endl;
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
const cmTarget* tg = tarTypeIt->second;
|
|
||||||
switch ( tg->GetType() )
|
|
||||||
{
|
|
||||||
case cmTarget::EXECUTABLE:
|
|
||||||
str << "house";
|
|
||||||
break;
|
|
||||||
case cmTarget::STATIC_LIBRARY:
|
|
||||||
str << "diamond";
|
|
||||||
break;
|
|
||||||
case cmTarget::SHARED_LIBRARY:
|
|
||||||
str << "polygon";
|
|
||||||
break;
|
|
||||||
case cmTarget::MODULE_LIBRARY:
|
|
||||||
str << "octagon";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
str << "box";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
str << "ellipse";
|
|
||||||
}
|
|
||||||
str << "\"];" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now generate the connectivity
|
// Now generate the connectivity
|
||||||
@ -2989,13 +2965,13 @@ void cmake::GenerateGraphViz(const char* fileName) const
|
|||||||
tit != targets->end();
|
tit != targets->end();
|
||||||
++ tit )
|
++ tit )
|
||||||
{
|
{
|
||||||
std::map<cmStdString, int>::iterator dependIt
|
std::map<cmStdString, const cmTarget* >::iterator cmakeTarIt
|
||||||
= targetDeps.find(tit->first.c_str());
|
= targetPtrs.find(tit->first.c_str());
|
||||||
if ( dependIt == targetDeps.end() )
|
if ( cmakeTarIt == targetPtrs.end() ) // skip ignored targets
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::map<cmStdString, cmStdString>::iterator cmakeTarIt =
|
std::map<cmStdString, cmStdString>::iterator targetNameIt =
|
||||||
targetNamesNodes.find(tit->first.c_str());
|
targetNamesNodes.find(tit->first.c_str());
|
||||||
const cmTarget::LinkLibraryVectorType* ll =
|
const cmTarget::LinkLibraryVectorType* ll =
|
||||||
&(tit->second.GetOriginalLinkLibraries());
|
&(tit->second.GetOriginalLinkLibraries());
|
||||||
@ -3005,17 +2981,17 @@ void cmake::GenerateGraphViz(const char* fileName) const
|
|||||||
++ llit )
|
++ llit )
|
||||||
{
|
{
|
||||||
const char* libName = llit->first.c_str();
|
const char* libName = llit->first.c_str();
|
||||||
std::map<cmStdString, cmStdString>::const_iterator tarIt =
|
std::map<cmStdString, cmStdString>::const_iterator libNameIt =
|
||||||
targetNamesNodes.find(libName);
|
targetNamesNodes.find(libName);
|
||||||
if ( tarIt == targetNamesNodes.end() )
|
if ( libNameIt == targetNamesNodes.end() )
|
||||||
{
|
{
|
||||||
// We should not be here.
|
// We should not be here.
|
||||||
std::cout << __LINE__ << " Cannot find library: " << libName
|
std::cout << __LINE__ << " Cannot find library: " << libName
|
||||||
<< " even though it was added in the previous pass" << std::endl;
|
<< " even though it was added in the previous pass" << std::endl;
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
str << " \"" << cmakeTarIt->second.c_str() << "\" -> \""
|
str << " \"" << targetNameIt->second.c_str() << "\" -> \""
|
||||||
<< tarIt->second.c_str() << "\"" << std::endl;
|
<< libNameIt->second.c_str() << "\"" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3068,7 +3044,6 @@ int cmake::getAllTargets(const std::set<cmStdString>& ignoreTargetsSet,
|
|||||||
int cmake::getAllExternalLibs(const std::set<cmStdString>& ignoreTargetsSet,
|
int cmake::getAllExternalLibs(const std::set<cmStdString>& ignoreTargetsSet,
|
||||||
std::map<cmStdString, cmStdString>& targetNamesNodes,
|
std::map<cmStdString, cmStdString>& targetNamesNodes,
|
||||||
std::map<cmStdString, const cmTarget*>& targetPtrs,
|
std::map<cmStdString, const cmTarget*>& targetPtrs,
|
||||||
std::map<cmStdString, int>& targetDeps,
|
|
||||||
const char* graphNodePrefix) const
|
const char* graphNodePrefix) const
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
@ -3094,11 +3069,6 @@ int cmake::getAllExternalLibs(const std::set<cmStdString>& ignoreTargetsSet,
|
|||||||
}
|
}
|
||||||
const cmTarget::LinkLibraryVectorType* ll =
|
const cmTarget::LinkLibraryVectorType* ll =
|
||||||
&(tit->second.GetOriginalLinkLibraries());
|
&(tit->second.GetOriginalLinkLibraries());
|
||||||
if ( ll->size() > 0 )
|
|
||||||
{
|
|
||||||
targetDeps[realTargetName] = DOT_DEP_TARGET;
|
|
||||||
fprintf(stderr, " + %s\n", realTargetName);
|
|
||||||
}
|
|
||||||
for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
|
for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
|
||||||
llit != ll->end();
|
llit != ll->end();
|
||||||
++ llit )
|
++ llit )
|
||||||
@ -3110,26 +3080,17 @@ int cmake::getAllExternalLibs(const std::set<cmStdString>& ignoreTargetsSet,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<cmStdString, cmStdString>::const_iterator tarIt =
|
std::map<cmStdString, const cmTarget*>::const_iterator tarIt =
|
||||||
targetNamesNodes.find(libName);
|
targetPtrs.find(libName);
|
||||||
if ( tarIt == targetNamesNodes.end() )
|
if ( tarIt == targetPtrs.end() )
|
||||||
{
|
{
|
||||||
cmOStringStream ostr;
|
cmOStringStream ostr;
|
||||||
ostr << graphNodePrefix << cnt++;
|
ostr << graphNodePrefix << cnt++;
|
||||||
targetDeps[libName] = DOT_DEP_EXTERNAL;
|
|
||||||
targetNamesNodes[libName] = ostr.str();
|
targetNamesNodes[libName] = ostr.str();
|
||||||
|
targetPtrs[libName] = NULL;
|
||||||
//str << " \"" << ostr.c_str() << "\" [ label=\"" << libName
|
//str << " \"" << ostr.c_str() << "\" [ label=\"" << libName
|
||||||
//<< "\" shape=\"ellipse\"];" << std::endl;
|
//<< "\" shape=\"ellipse\"];" << std::endl;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
std::map<cmStdString, int>::const_iterator depIt =
|
|
||||||
targetDeps.find(libName);
|
|
||||||
if ( depIt == targetDeps.end() )
|
|
||||||
{
|
|
||||||
targetDeps[libName] = DOT_DEP_TARGET;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,6 @@ protected:
|
|||||||
int getAllExternalLibs(const std::set<cmStdString>& ignoreTargetsSet,
|
int getAllExternalLibs(const std::set<cmStdString>& ignoreTargetsSet,
|
||||||
std::map<cmStdString, cmStdString>& targetNamesNodes,
|
std::map<cmStdString, cmStdString>& targetNamesNodes,
|
||||||
std::map<cmStdString, const cmTarget*>& targetPtrs,
|
std::map<cmStdString, const cmTarget*>& targetPtrs,
|
||||||
std::map<cmStdString, int>& targetDeps,
|
|
||||||
const char* graphNodePrefix) const;
|
const char* graphNodePrefix) const;
|
||||||
|
|
||||||
///! Find the full path to one of the cmake programs like ctest, cpack, etc.
|
///! Find the full path to one of the cmake programs like ctest, cpack, etc.
|
||||||
|
Loading…
Reference in New Issue
Block a user