cmake/Source/cmComputeTargetDepends.h

93 lines
3.2 KiB
C
Raw Normal View History

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