2016-09-27 15:01:08 -04:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2008-02-05 23:10:41 -05:00
|
|
|
#ifndef cmComputeTargetDepends_h
|
|
|
|
#define cmComputeTargetDepends_h
|
|
|
|
|
2017-04-11 22:00:21 +02:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2008-02-05 23:10:41 -05:00
|
|
|
|
2008-02-07 16:14:05 -05:00
|
|
|
#include "cmGraphAdjacencyList.h"
|
|
|
|
|
2016-08-18 00:24:24 +02:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2008-02-05 23:10:41 -05:00
|
|
|
|
2008-02-07 16:14:05 -05:00
|
|
|
class cmComputeComponentGraph;
|
2016-08-18 00:24:24 +02:00
|
|
|
class cmGeneratorTarget;
|
2008-02-05 23:10:41 -05:00
|
|
|
class cmGlobalGenerator;
|
2014-06-16 11:49:10 -04:00
|
|
|
class cmLinkItem;
|
2010-08-25 10:07:25 -04:00
|
|
|
class cmTargetDependSet;
|
2008-02-05 23:10:41 -05: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 10:34:04 -04:00
|
|
|
std::vector<cmGeneratorTarget const*> const& GetTargets() const
|
|
|
|
{
|
|
|
|
return this->Targets;
|
|
|
|
}
|
2015-06-06 13:08:17 +02:00
|
|
|
void GetTargetDirectDepends(cmGeneratorTarget const* t,
|
|
|
|
cmTargetDependSet& deps);
|
2016-05-16 10:34:04 -04:00
|
|
|
|
2008-02-05 23:10:41 -05:00
|
|
|
private:
|
|
|
|
void CollectTargets();
|
|
|
|
void CollectDepends();
|
|
|
|
void CollectTargetDepends(int depender_index);
|
2016-05-16 10:34:04 -04:00
|
|
|
void AddTargetDepend(int depender_index, cmLinkItem const& dependee_name,
|
2008-08-06 17:48:53 -04:00
|
|
|
bool linking);
|
2015-06-06 13:08:17 +02:00
|
|
|
void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee,
|
2013-12-10 15:16:23 +01:00
|
|
|
bool linking);
|
2010-08-25 10:14:31 -04:00
|
|
|
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
|
2016-05-16 10:34:04 -04:00
|
|
|
void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name,
|
2017-05-17 13:29:37 -04:00
|
|
|
const std::string& config,
|
2016-05-16 10:34:04 -04:00
|
|
|
std::set<std::string>& emitted);
|
2015-06-06 13:08:17 +02:00
|
|
|
void AddInterfaceDepends(int depender_index,
|
|
|
|
cmGeneratorTarget const* dependee,
|
2014-02-09 22:48:34 -05:00
|
|
|
const std::string& config,
|
2016-05-16 10:34:04 -04:00
|
|
|
std::set<std::string>& emitted);
|
2008-02-05 23:10:41 -05:00
|
|
|
cmGlobalGenerator* GlobalGenerator;
|
|
|
|
bool DebugMode;
|
2009-08-24 09:54:27 -04:00
|
|
|
bool NoCycles;
|
2008-02-05 23:10:41 -05:00
|
|
|
|
|
|
|
// Collect all targets.
|
2015-06-06 13:08:17 +02:00
|
|
|
std::vector<cmGeneratorTarget const*> Targets;
|
|
|
|
std::map<cmGeneratorTarget const*, int> TargetIndex;
|
2008-02-05 23:10:41 -05:00
|
|
|
|
|
|
|
// Represent the target dependency graph. The entry at each
|
|
|
|
// top-level index corresponds to a depender whose dependencies are
|
|
|
|
// listed.
|
2008-02-07 16:14:05 -05:00
|
|
|
typedef cmGraphNodeList NodeList;
|
2010-08-20 14:11:18 -04:00
|
|
|
typedef cmGraphEdgeList EdgeList;
|
2008-02-07 16:14:05 -05:00
|
|
|
typedef cmGraphAdjacencyList Graph;
|
|
|
|
Graph InitialGraph;
|
|
|
|
Graph FinalGraph;
|
2014-02-06 17:31:47 -05:00
|
|
|
void DisplayGraph(Graph const& graph, const std::string& name);
|
2008-02-07 16:14:05 -05:00
|
|
|
|
|
|
|
// Deal with connected components.
|
|
|
|
void DisplayComponents(cmComputeComponentGraph const& ccg);
|
|
|
|
bool CheckComponents(cmComputeComponentGraph const& ccg);
|
2010-08-25 10: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-05 23:10:41 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|