diff options
author | Brad King <brad.king@kitware.com> | 2020-07-14 19:54:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-07-27 14:26:07 (GMT) |
commit | ef796cc74322ff423da1ddef5e4dd52855dac8c7 (patch) | |
tree | 6a464a453ad1ea6a17027f9849cb359d9fd17d57 | |
parent | 45158b2afef1dd3b4bd4accfcea07849921ba7df (diff) | |
download | CMake-ef796cc74322ff423da1ddef5e4dd52855dac8c7.zip CMake-ef796cc74322ff423da1ddef5e4dd52855dac8c7.tar.gz CMake-ef796cc74322ff423da1ddef5e4dd52855dac8c7.tar.bz2 |
cmGeneratorTarget: Skip computing link implementation for custom targets
Targets created by `add_custom_target` cannot be used with
`target_link_libraries` and so have no link implementation.
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 30af139..64d4ec4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2467,6 +2467,12 @@ private: cmGeneratorTarget::LinkClosure const* cmGeneratorTarget::GetLinkClosure( const std::string& config) const { + // There is no link implementation for targets that cannot compile sources. + if (!this->CanCompileSources()) { + static LinkClosure const empty = { {}, {} }; + return ∅ + } + std::string key(cmSystemTools::UpperCase(config)); auto i = this->LinkClosureMap.find(key); if (i == this->LinkClosureMap.end()) { @@ -2783,6 +2789,12 @@ const std::vector<const cmGeneratorTarget*>& cmGeneratorTarget::GetLinkImplementationClosure( const std::string& config) const { + // There is no link implementation for targets that cannot compile sources. + if (!this->CanCompileSources()) { + static std::vector<const cmGeneratorTarget*> const empty; + return empty; + } + LinkImplClosure& tgts = this->LinkImplClosureMap[config]; if (!tgts.Done) { tgts.Done = true; @@ -6856,8 +6868,8 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( const std::string& config, bool secondPass) const { - // There is no link implementation for imported targets. - if (this->IsImported()) { + // There is no link implementation for targets that cannot compile sources. + if (!this->CanCompileSources()) { return nullptr; } @@ -7120,8 +7132,8 @@ cmLinkImplementationLibraries const* cmGeneratorTarget::GetLinkImplementationLibrariesInternal( const std::string& config, cmGeneratorTarget const* head) const { - // There is no link implementation for imported targets. - if (this->IsImported()) { + // There is no link implementation for targets that cannot compile sources. + if (!this->CanCompileSources()) { return nullptr; } |