2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2008-01-22 14:13:04 +00:00
|
|
|
#ifndef cmComputeLinkInformation_h
|
|
|
|
#define cmComputeLinkInformation_h
|
|
|
|
|
2017-04-11 20:00:21 +00:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2008-01-22 14:13:04 +00:00
|
|
|
|
2016-08-17 22:24:24 +00:00
|
|
|
#include <iosfwd>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
2019-01-21 16:15:21 +00:00
|
|
|
#include <utility>
|
2016-08-17 22:24:24 +00:00
|
|
|
#include <vector>
|
2008-01-22 14:13:04 +00:00
|
|
|
|
2019-09-30 14:46:28 +00:00
|
|
|
#include "cmsys/RegularExpression.hxx"
|
|
|
|
|
2016-08-17 22:24:24 +00:00
|
|
|
class cmGeneratorTarget;
|
2008-01-22 14:13:04 +00:00
|
|
|
class cmGlobalGenerator;
|
|
|
|
class cmMakefile;
|
2008-02-21 16:41:11 +00:00
|
|
|
class cmOrderDirectories;
|
2016-08-17 22:24:24 +00:00
|
|
|
class cmake;
|
2019-09-11 17:28:38 +00:00
|
|
|
template <typename T>
|
|
|
|
class BT;
|
2008-01-22 14:13:04 +00:00
|
|
|
|
|
|
|
/** \class cmComputeLinkInformation
|
|
|
|
* \brief Compute link information for a target in one configuration.
|
|
|
|
*/
|
|
|
|
class cmComputeLinkInformation
|
|
|
|
{
|
|
|
|
public:
|
2015-08-04 17:19:50 +00:00
|
|
|
cmComputeLinkInformation(cmGeneratorTarget const* target,
|
|
|
|
const std::string& config);
|
2008-02-01 13:56:00 +00:00
|
|
|
~cmComputeLinkInformation();
|
2008-01-22 14:13:04 +00:00
|
|
|
bool Compute();
|
|
|
|
|
|
|
|
struct Item
|
|
|
|
{
|
2019-01-22 22:44:50 +00:00
|
|
|
Item() = default;
|
2019-01-21 16:15:21 +00:00
|
|
|
Item(std::string v, bool p, cmGeneratorTarget const* target = nullptr)
|
|
|
|
: Value(std::move(v))
|
2016-05-16 14:34:04 +00:00
|
|
|
, IsPath(p)
|
|
|
|
, Target(target)
|
|
|
|
{
|
|
|
|
}
|
2008-01-22 14:13:04 +00:00
|
|
|
std::string Value;
|
2018-11-21 22:17:54 +00:00
|
|
|
bool IsPath = true;
|
|
|
|
cmGeneratorTarget const* Target = nullptr;
|
2008-01-22 14:13:04 +00:00
|
|
|
};
|
2019-08-23 21:25:56 +00:00
|
|
|
using ItemVector = std::vector<Item>;
|
2019-09-11 17:28:38 +00:00
|
|
|
void AppendValues(std::string& result, std::vector<BT<std::string>>& values);
|
2018-03-15 15:52:48 +00:00
|
|
|
ItemVector const& GetItems() const;
|
2018-03-22 22:31:29 +00:00
|
|
|
std::vector<std::string> const& GetDirectories() const;
|
2019-09-11 17:31:05 +00:00
|
|
|
std::vector<BT<std::string>> GetDirectoriesWithBacktraces();
|
2018-03-22 22:31:29 +00:00
|
|
|
std::vector<std::string> const& GetDepends() const;
|
|
|
|
std::vector<std::string> const& GetFrameworkPaths() const;
|
2014-02-04 02:20:56 +00:00
|
|
|
std::string GetLinkLanguage() const { return this->LinkLanguage; }
|
2018-03-22 22:31:29 +00:00
|
|
|
std::vector<std::string> const& GetRuntimeSearchPath() const;
|
2008-01-29 20:07:33 +00:00
|
|
|
std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
|
|
|
|
std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
|
2018-03-22 22:31:29 +00:00
|
|
|
void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install) const;
|
|
|
|
std::string GetRPathString(bool for_install) const;
|
|
|
|
std::string GetChrpathString() const;
|
|
|
|
std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked() const;
|
2008-02-01 13:56:00 +00:00
|
|
|
|
2019-08-02 15:51:55 +00:00
|
|
|
std::string const& GetLibLinkFileFlag() const
|
|
|
|
{
|
|
|
|
return this->LibLinkFileFlag;
|
|
|
|
}
|
|
|
|
|
2008-02-01 13:56:00 +00:00
|
|
|
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
|
2018-03-22 22:31:29 +00:00
|
|
|
std::string GetRPathLinkString() const;
|
2016-05-16 14:34:04 +00:00
|
|
|
|
2016-10-13 13:08:44 +00:00
|
|
|
std::string GetConfig() const { return this->Config; }
|
2018-06-01 13:53:41 +00:00
|
|
|
|
2019-09-13 17:59:53 +00:00
|
|
|
const cmGeneratorTarget* GetTarget() { return this->Target; }
|
|
|
|
|
2008-01-22 14:13:04 +00:00
|
|
|
private:
|
2015-10-07 22:41:15 +00:00
|
|
|
void AddItem(std::string const& item, const cmGeneratorTarget* tgt);
|
|
|
|
void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt);
|
2008-01-22 14:13:04 +00:00
|
|
|
|
|
|
|
// Output information.
|
|
|
|
ItemVector Items;
|
|
|
|
std::vector<std::string> Directories;
|
|
|
|
std::vector<std::string> Depends;
|
|
|
|
std::vector<std::string> FrameworkPaths;
|
|
|
|
std::vector<std::string> RuntimeSearchPath;
|
2015-10-07 22:51:05 +00:00
|
|
|
std::set<cmGeneratorTarget const*> SharedLibrariesLinked;
|
2008-01-22 14:13:04 +00:00
|
|
|
|
|
|
|
// Context information.
|
2018-03-22 22:31:29 +00:00
|
|
|
cmGeneratorTarget const* const Target;
|
|
|
|
cmMakefile* const Makefile;
|
|
|
|
cmGlobalGenerator* const GlobalGenerator;
|
|
|
|
cmake* const CMakeInstance;
|
2008-01-22 14:13:04 +00:00
|
|
|
|
|
|
|
// Configuration information.
|
2018-03-22 22:31:29 +00:00
|
|
|
std::string const Config;
|
2014-02-04 02:20:56 +00:00
|
|
|
std::string LinkLanguage;
|
2008-01-22 14:13:04 +00:00
|
|
|
|
2008-01-31 20:45:31 +00:00
|
|
|
// Modes for dealing with dependent shared libraries.
|
|
|
|
enum SharedDepMode
|
|
|
|
{
|
2008-02-21 16:41:11 +00:00
|
|
|
SharedDepModeNone, // Drop
|
|
|
|
SharedDepModeDir, // List dir in -rpath-link flag
|
|
|
|
SharedDepModeLibDir, // List dir in linker search path
|
|
|
|
SharedDepModeLink // List file on link line
|
2008-01-31 20:45:31 +00:00
|
|
|
};
|
|
|
|
|
2008-01-22 14:13:04 +00:00
|
|
|
const char* LoaderFlag;
|
|
|
|
std::string LibLinkFlag;
|
2008-01-23 18:30:55 +00:00
|
|
|
std::string LibLinkFileFlag;
|
2008-01-22 14:13:04 +00:00
|
|
|
std::string LibLinkSuffix;
|
2008-01-29 20:07:33 +00:00
|
|
|
std::string RuntimeFlag;
|
|
|
|
std::string RuntimeSep;
|
|
|
|
std::string RuntimeAlways;
|
2008-02-01 13:56:00 +00:00
|
|
|
std::string RPathLinkFlag;
|
2008-01-31 20:45:31 +00:00
|
|
|
SharedDepMode SharedDependencyMode;
|
2008-01-22 14:13:04 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
enum LinkType
|
|
|
|
{
|
|
|
|
LinkUnknown,
|
|
|
|
LinkStatic,
|
|
|
|
LinkShared
|
|
|
|
};
|
2015-06-06 07:59:24 +00:00
|
|
|
void SetCurrentLinkType(LinkType lt);
|
|
|
|
|
2008-01-22 14:13:04 +00:00
|
|
|
// Link type adjustment.
|
|
|
|
void ComputeLinkTypeInfo();
|
|
|
|
LinkType StartLinkType;
|
|
|
|
LinkType CurrentLinkType;
|
|
|
|
std::string StaticLinkTypeFlag;
|
|
|
|
std::string SharedLinkTypeFlag;
|
|
|
|
|
|
|
|
// Link item parsing.
|
|
|
|
void ComputeItemParserInfo();
|
|
|
|
std::vector<std::string> StaticLinkExtensions;
|
|
|
|
std::vector<std::string> SharedLinkExtensions;
|
|
|
|
std::vector<std::string> LinkExtensions;
|
2014-02-10 05:21:34 +00:00
|
|
|
std::set<std::string> LinkPrefixes;
|
2008-01-22 14:13:04 +00:00
|
|
|
cmsys::RegularExpression ExtractStaticLibraryName;
|
|
|
|
cmsys::RegularExpression ExtractSharedLibraryName;
|
|
|
|
cmsys::RegularExpression ExtractAnyLibraryName;
|
2008-04-30 22:04:48 +00:00
|
|
|
std::string SharedRegexString;
|
2008-01-22 14:13:04 +00:00
|
|
|
void AddLinkPrefix(const char* p);
|
|
|
|
void AddLinkExtension(const char* e, LinkType type);
|
2013-04-11 14:55:36 +00:00
|
|
|
std::string CreateExtensionRegex(std::vector<std::string> const& exts,
|
|
|
|
LinkType type);
|
2008-01-22 14:13:04 +00:00
|
|
|
std::string NoCaseExpression(const char* str);
|
|
|
|
|
2008-02-21 16:41:11 +00:00
|
|
|
// Handling of link items.
|
2015-10-07 22:45:02 +00:00
|
|
|
void AddTargetItem(std::string const& item, const cmGeneratorTarget* target);
|
2008-01-22 15:05:27 +00:00
|
|
|
void AddFullItem(std::string const& item);
|
2008-01-31 12:50:40 +00:00
|
|
|
bool CheckImplicitDirItem(std::string const& item);
|
2008-07-23 16:19:54 +00:00
|
|
|
void AddUserItem(std::string const& item, bool pathNotKnown);
|
2008-01-22 14:13:04 +00:00
|
|
|
void AddDirectoryItem(std::string const& item);
|
|
|
|
void AddFrameworkItem(std::string const& item);
|
|
|
|
void DropDirectoryItem(std::string const& item);
|
2008-02-21 16:41:11 +00:00
|
|
|
bool CheckSharedLibNoSOName(std::string const& item);
|
|
|
|
void AddSharedLibNoSOName(std::string const& item);
|
2008-07-23 16:59:14 +00:00
|
|
|
void HandleBadFullItem(std::string const& item, std::string const& file);
|
2008-01-22 14:13:04 +00:00
|
|
|
|
|
|
|
// Framework info.
|
|
|
|
void ComputeFrameworkInfo();
|
|
|
|
void AddFrameworkPath(std::string const& p);
|
2014-02-10 05:21:34 +00:00
|
|
|
std::set<std::string> FrameworkPathsEmmitted;
|
2008-01-22 14:13:04 +00:00
|
|
|
cmsys::RegularExpression SplitFramework;
|
|
|
|
|
|
|
|
// Linker search path computation.
|
2008-02-21 16:41:11 +00:00
|
|
|
cmOrderDirectories* OrderLinkerSearchPath;
|
2008-03-13 20:23:18 +00:00
|
|
|
bool FinishLinkerSearchDirectories();
|
2008-03-21 01:11:26 +00:00
|
|
|
void PrintLinkPolicyDiagnosis(std::ostream&);
|
2009-07-27 16:43:17 +00:00
|
|
|
|
|
|
|
// Implicit link libraries and directories for linker language.
|
2009-07-14 14:14:52 +00:00
|
|
|
void LoadImplicitLinkInfo();
|
2009-08-24 17:15:47 +00:00
|
|
|
void AddImplicitLinkInfo();
|
|
|
|
void AddImplicitLinkInfo(std::string const& lang);
|
2014-02-10 05:21:34 +00:00
|
|
|
std::set<std::string> ImplicitLinkDirs;
|
|
|
|
std::set<std::string> ImplicitLinkLibs;
|
2008-01-22 14:13:04 +00:00
|
|
|
|
2010-02-15 16:22:36 +00:00
|
|
|
// Additional paths configured by the runtime linker
|
|
|
|
std::vector<std::string> RuntimeLinkDirs;
|
|
|
|
|
2008-01-23 20:22:38 +00:00
|
|
|
// Linker search path compatibility mode.
|
2014-02-10 05:21:34 +00:00
|
|
|
std::set<std::string> OldLinkDirMask;
|
2008-02-21 16:41:11 +00:00
|
|
|
std::vector<std::string> OldLinkDirItems;
|
2008-03-13 20:23:18 +00:00
|
|
|
std::vector<std::string> OldUserFlagItems;
|
2015-04-07 14:43:47 +00:00
|
|
|
std::set<std::string> CMP0060WarnItems;
|
2015-06-06 07:59:24 +00:00
|
|
|
// Dependent library path computation.
|
|
|
|
cmOrderDirectories* OrderDependentRPath;
|
2008-01-22 14:13:04 +00:00
|
|
|
// Runtime path computation.
|
2008-02-21 16:41:11 +00:00
|
|
|
cmOrderDirectories* OrderRuntimeSearchPath;
|
2015-06-06 07:59:24 +00:00
|
|
|
|
|
|
|
bool OldLinkDirMode;
|
|
|
|
bool OpenBSD;
|
|
|
|
bool LinkDependsNoShared;
|
|
|
|
bool RuntimeUseChrpath;
|
|
|
|
bool NoSONameUsesPath;
|
|
|
|
bool LinkWithRuntimePath;
|
|
|
|
bool LinkTypeEnabled;
|
|
|
|
bool ArchivesMayBeShared;
|
|
|
|
bool CMP0060Warn;
|
|
|
|
|
2013-12-10 14:30:41 +00:00
|
|
|
void AddLibraryRuntimeInfo(std::string const& fullPath,
|
2015-10-07 22:45:02 +00:00
|
|
|
const cmGeneratorTarget* target);
|
2008-02-06 18:34:44 +00:00
|
|
|
void AddLibraryRuntimeInfo(std::string const& fullPath);
|
2008-01-22 14:13:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|