summaryrefslogtreecommitdiffstats
path: root/Source/cmComputeTargetDepends.h
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-07-29 18:19:56 (GMT)
committerBrad King <brad.king@kitware.com>2020-08-12 15:31:07 (GMT)
commit2e42651dff43c4e962f03fc24281cbf446880ded (patch)
tree5a1fa6f2098d9cb5bdc04c7f9285dc454c3a5ebf /Source/cmComputeTargetDepends.h
parent0cd3b5d0ca8d541fc3769f467db71a07a95be7f6 (diff)
downloadCMake-2e42651dff43c4e962f03fc24281cbf446880ded.zip
CMake-2e42651dff43c4e962f03fc24281cbf446880ded.tar.gz
CMake-2e42651dff43c4e962f03fc24281cbf446880ded.tar.bz2
Add option to optimize link dependencies for static libraries
Add an `OPTIMIZE_DEPENDENCIES` target property and supporting `CMAKE_OPTIMIZE_DEPENDENCIES` variable to optionally enable pruning and flattening of outgoing dependencies from static libraries. Since they do not actually link, they only depend on side effects of their dependencies. Therefore we can drop dependencies that contribute no side effects.
Diffstat (limited to 'Source/cmComputeTargetDepends.h')
-rw-r--r--Source/cmComputeTargetDepends.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index e0d625f..277521d 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -42,6 +42,13 @@ public:
cmTargetDependSet& deps);
private:
+ struct TargetSideEffects
+ {
+ std::set<cmGeneratorTarget const*> CustomCommandSideEffects;
+ std::map<std::string, std::set<cmGeneratorTarget const*>>
+ LanguageSideEffects;
+ };
+
void CollectTargets();
void CollectDepends();
void CollectTargetDepends(int depender_index);
@@ -50,6 +57,12 @@ private:
void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee,
cmListFileBacktrace const& dependee_backtrace,
bool linking, bool cross);
+ void CollectSideEffects();
+ void CollectSideEffectsForTarget(std::set<int>& visited, int depender_index);
+ void ComputeIntermediateGraph();
+ void OptimizeLinkDependencies(cmGeneratorTarget const* gt,
+ cmGraphEdgeList& outputEdges,
+ cmGraphEdgeList const& inputEdges);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name,
const std::string& config,
@@ -74,11 +87,15 @@ private:
using EdgeList = cmGraphEdgeList;
using Graph = cmGraphAdjacencyList;
Graph InitialGraph;
+ Graph IntermediateGraph;
Graph FinalGraph;
+ std::vector<TargetSideEffects> SideEffects;
void DisplayGraph(Graph const& graph, const std::string& name);
+ void DisplaySideEffects();
// Deal with connected components.
- void DisplayComponents(cmComputeComponentGraph const& ccg);
+ void DisplayComponents(cmComputeComponentGraph const& ccg,
+ const std::string& name);
bool CheckComponents(cmComputeComponentGraph const& ccg);
void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c,
bool strong = false);