2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2008-02-06 07:10:41 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2008-02-06 07:10:41 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2008-02-06 07:10:41 +03:00
|
|
|
#ifndef cmComputeTargetDepends_h
|
|
|
|
#define cmComputeTargetDepends_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
|
|
|
|
2008-02-08 00:14:05 +03:00
|
|
|
#include "cmGraphAdjacencyList.h"
|
|
|
|
|
2008-02-06 07:10:41 +03:00
|
|
|
#include <stack>
|
|
|
|
|
2008-02-08 00:14:05 +03:00
|
|
|
class cmComputeComponentGraph;
|
2008-02-06 07:10:41 +03:00
|
|
|
class cmGlobalGenerator;
|
2014-06-16 19:49:10 +04:00
|
|
|
class cmLinkItem;
|
2015-06-06 14:08:17 +03:00
|
|
|
class cmGeneratorTarget;
|
2010-08-25 18:07:25 +04:00
|
|
|
class cmTargetDependSet;
|
2008-02-06 07:10:41 +03:00
|
|
|
|
|
|
|
/** \class cmComputeTargetDepends
|
|
|
|
* \brief Compute global interdependencies among targets.
|
|
|
|
*
|
|
|
|
* Static libraries may form cycles in the target dependency graph.
|
|
|
|
* This class evaluates target dependencies globally and adjusts them
|
|
|
|
* to remove cycles while preserving a safe build order.
|
|
|
|
*/
|
|
|
|
class cmComputeTargetDepends
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmComputeTargetDepends(cmGlobalGenerator* gg);
|
|
|
|
~cmComputeTargetDepends();
|
|
|
|
|
|
|
|
bool Compute();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmGeneratorTarget const*> const& GetTargets() const
|
|
|
|
{
|
|
|
|
return this->Targets;
|
|
|
|
}
|
2015-06-06 14:08:17 +03:00
|
|
|
void GetTargetDirectDepends(cmGeneratorTarget const* t,
|
|
|
|
cmTargetDependSet& deps);
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2008-02-06 07:10:41 +03:00
|
|
|
private:
|
|
|
|
void CollectTargets();
|
|
|
|
void CollectDepends();
|
|
|
|
void CollectTargetDepends(int depender_index);
|
2016-05-16 17:34:04 +03:00
|
|
|
void AddTargetDepend(int depender_index, cmLinkItem const& dependee_name,
|
2008-08-07 01:48:53 +04:00
|
|
|
bool linking);
|
2015-06-06 14:08:17 +03:00
|
|
|
void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee,
|
2013-12-10 18:16:23 +04:00
|
|
|
bool linking);
|
2010-08-25 18:14:31 +04:00
|
|
|
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
|
2016-05-16 17:34:04 +03:00
|
|
|
void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name,
|
|
|
|
std::set<std::string>& emitted);
|
2015-06-06 14:08:17 +03:00
|
|
|
void AddInterfaceDepends(int depender_index,
|
|
|
|
cmGeneratorTarget const* dependee,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::set<std::string>& emitted);
|
2008-02-06 07:10:41 +03:00
|
|
|
cmGlobalGenerator* GlobalGenerator;
|
|
|
|
bool DebugMode;
|
2009-08-24 17:54:27 +04:00
|
|
|
bool NoCycles;
|
2008-02-06 07:10:41 +03:00
|
|
|
|
|
|
|
// Collect all targets.
|
2015-06-06 14:08:17 +03:00
|
|
|
std::vector<cmGeneratorTarget const*> Targets;
|
|
|
|
std::map<cmGeneratorTarget const*, int> TargetIndex;
|
2008-02-06 07:10:41 +03:00
|
|
|
|
|
|
|
// Represent the target dependency graph. The entry at each
|
|
|
|
// top-level index corresponds to a depender whose dependencies are
|
|
|
|
// listed.
|
2008-02-08 00:14:05 +03:00
|
|
|
typedef cmGraphNodeList NodeList;
|
2010-08-20 22:11:18 +04:00
|
|
|
typedef cmGraphEdgeList EdgeList;
|
2008-02-08 00:14:05 +03:00
|
|
|
typedef cmGraphAdjacencyList Graph;
|
|
|
|
Graph InitialGraph;
|
|
|
|
Graph FinalGraph;
|
2014-02-07 02:31:47 +04:00
|
|
|
void DisplayGraph(Graph const& graph, const std::string& name);
|
2008-02-08 00:14:05 +03:00
|
|
|
|
|
|
|
// Deal with connected components.
|
|
|
|
void DisplayComponents(cmComputeComponentGraph const& ccg);
|
|
|
|
bool CheckComponents(cmComputeComponentGraph const& ccg);
|
2010-08-25 18:14:31 +04:00
|
|
|
void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c,
|
|
|
|
bool strong = false);
|
|
|
|
|
|
|
|
std::vector<int> ComponentHead;
|
|
|
|
std::vector<int> ComponentTail;
|
|
|
|
bool IntraComponent(std::vector<int> const& cmap, int c, int i, int* head,
|
|
|
|
std::set<int>& emitted, std::set<int>& visited);
|
2008-02-06 07:10:41 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|