diff options
author | Brad King <brad.king@kitware.com> | 2014-07-15 20:12:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-07-16 17:31:29 (GMT) |
commit | 535fd6ce6d514deebc8c95424df83f73989f55a5 (patch) | |
tree | 568a68aef2720e3f58fbfa862b8b0318dc5a2f0b /Source/cmTarget.h | |
parent | 6e7e881c57e8ff7295a1007d329708143b54baad (diff) | |
download | CMake-535fd6ce6d514deebc8c95424df83f73989f55a5.zip CMake-535fd6ce6d514deebc8c95424df83f73989f55a5.tar.gz CMake-535fd6ce6d514deebc8c95424df83f73989f55a5.tar.bz2 |
cmTarget: Make GetLink*Libraries methods safer to use
Split the library lists out of LinkImplementation and LinkInterface into
LinkImplementationLibraries and LinkInterfaceLibraries parent classes,
respectively. Return these from GetLinkImplementationLibraries and
GetLinkInterfaceLibraries, respectively, so that callers cannot access
parts of the structures that have not been populated.
Diffstat (limited to 'Source/cmTarget.h')
-rw-r--r-- | Source/cmTarget.h | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4005443..8e21d4f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -262,13 +262,15 @@ public: /** The link interface specifies transitive library dependencies and other information needed by targets that link to this target. */ - struct LinkInterface + struct LinkInterfaceLibraries { - // Languages whose runtime libraries must be linked. - std::vector<std::string> Languages; - // Libraries listed in the interface. std::vector<cmLinkItem> Libraries; + }; + struct LinkInterface: public LinkInterfaceLibraries + { + // Languages whose runtime libraries must be linked. + std::vector<std::string> Languages; // Shared library dependencies needed for linking on some platforms. std::vector<cmLinkItem> SharedDeps; @@ -290,22 +292,21 @@ public: if the target cannot be linked. */ LinkInterface const* GetLinkInterface(const std::string& config, cmTarget const* headTarget) const; - LinkInterface const* GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget, - bool usage_requirements_only) const; + LinkInterfaceLibraries const* + GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget, + bool usage_requirements_only) const; void GetTransitivePropertyTargets(const std::string& config, cmTarget const* headTarget, std::vector<cmTarget const*> &libs) const; + std::vector<cmTarget const*> const& GetLinkImplementationClosure(const std::string& config) const; /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ - struct LinkImplementation + struct LinkImplementationLibraries { - // Languages whose runtime libraries must be linked. - std::vector<std::string> Languages; - // Libraries linked directly in this configuration. std::vector<cmLinkImplItem> Libraries; @@ -313,10 +314,15 @@ public: // Needed only for OLD behavior of CMP0003. std::vector<cmLinkItem> WrongConfigLibraries; }; + struct LinkImplementation: public LinkImplementationLibraries + { + // Languages whose runtime libraries must be linked. + std::vector<std::string> Languages; + }; LinkImplementation const* GetLinkImplementation(const std::string& config) const; - LinkImplementation const* + LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; /** Link information from the transitive closure of the link @@ -778,12 +784,12 @@ private: GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; - LinkImplementation const* + LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkImplementation(const std::string& config, - LinkImplementation& impl, - cmTarget const* head) const; + void ComputeLinkImplementationLibraries(const std::string& config, + LinkImplementation& impl, + cmTarget const* head) const; void ComputeLinkImplementationLanguages(const std::string& config, LinkImplementation& impl) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; |