* Tests if targetDepend is a STATIC_LIBRARY and if any of its * recursive STATIC_LIBRARY dependencies depends on targetOrigin * (STATIC_LIBRARY cycle). */
| 100 | * (STATIC_LIBRARY cycle). |
| 101 | */ |
| 102 | bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin, |
| 103 | cmGeneratorTarget const* targetDepend, |
| 104 | std::string const& config) |
| 105 | { |
| 106 | bool cycle = false; |
| 107 | if ((targetOrigin->GetType() == cmStateEnums::STATIC_LIBRARY) && |
| 108 | (targetDepend->GetType() == cmStateEnums::STATIC_LIBRARY)) { |
| 109 | std::set<cmGeneratorTarget const*> knownLibs; |
| 110 | std::deque<cmGeneratorTarget const*> testLibs; |
| 111 | |
| 112 | // Insert initial static_library dependency |
| 113 | knownLibs.insert(targetDepend); |
| 114 | testLibs.push_back(targetDepend); |
| 115 | |
| 116 | while (!testLibs.empty()) { |
| 117 | cmGeneratorTarget const* testTarget = testLibs.front(); |
| 118 | testLibs.pop_front(); |
| 119 | // Check if the test target is the origin target (cycle) |
| 120 | if (testTarget == targetOrigin) { |
| 121 | cycle = true; |
| 122 | break; |
| 123 | } |
| 124 | // Collect all static_library dependencies from the test target |
| 125 | cmLinkImplementationLibraries const* libs = |
| 126 | testTarget->GetLinkImplementationLibraries( |
| 127 | config, cmGeneratorTarget::UseTo::Link); |
| 128 | if (libs) { |
| 129 | for (cmLinkItem const& item : libs->Libraries) { |
| 130 | cmGeneratorTarget const* depTarget = item.Target; |
| 131 | if (depTarget && |
| 132 | (depTarget->GetType() == cmStateEnums::STATIC_LIBRARY) && |
| 133 | knownLibs.insert(depTarget).second) { |
| 134 | testLibs.push_back(depTarget); |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | return cycle; |
| 141 | } |
| 142 | |
| 143 | /** Sanitizes file search paths. */ |
| 144 | class SearchPathSanitizer |
no test coverage detected
searching dependent graphs…