2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2008-01-22 17:13:04 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2008-01-22 17:13:04 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2008-01-22 17:13:04 +03:00
|
|
|
#ifndef cmComputeLinkInformation_h
|
|
|
|
#define cmComputeLinkInformation_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
|
|
|
|
|
|
|
#include <cmsys/RegularExpression.hxx>
|
|
|
|
|
2008-02-04 23:22:10 +03:00
|
|
|
class cmake;
|
2008-01-22 17:13:04 +03:00
|
|
|
class cmGlobalGenerator;
|
|
|
|
class cmMakefile;
|
2015-08-04 20:19:49 +03:00
|
|
|
class cmGeneratorTarget;
|
2008-02-21 19:41:11 +03:00
|
|
|
class cmOrderDirectories;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
/** \class cmComputeLinkInformation
|
|
|
|
* \brief Compute link information for a target in one configuration.
|
|
|
|
*/
|
|
|
|
class cmComputeLinkInformation
|
|
|
|
{
|
|
|
|
public:
|
2015-08-04 20:19:50 +03:00
|
|
|
cmComputeLinkInformation(cmGeneratorTarget const* target,
|
|
|
|
const std::string& config);
|
2008-02-01 16:56:00 +03:00
|
|
|
~cmComputeLinkInformation();
|
2008-01-22 17:13:04 +03:00
|
|
|
bool Compute();
|
|
|
|
|
|
|
|
struct Item
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
Item()
|
|
|
|
: Value()
|
|
|
|
, IsPath(true)
|
2016-06-27 23:44:16 +03:00
|
|
|
, Target(CM_NULLPTR)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
Item(Item const& item)
|
|
|
|
: Value(item.Value)
|
|
|
|
, IsPath(item.IsPath)
|
|
|
|
, Target(item.Target)
|
|
|
|
{
|
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
Item(std::string const& v, bool p,
|
|
|
|
cmGeneratorTarget const* target = CM_NULLPTR)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Value(v)
|
|
|
|
, IsPath(p)
|
|
|
|
, Target(target)
|
|
|
|
{
|
|
|
|
}
|
2008-01-22 17:13:04 +03:00
|
|
|
std::string Value;
|
|
|
|
bool IsPath;
|
2015-10-08 01:49:38 +03:00
|
|
|
cmGeneratorTarget const* Target;
|
2008-01-22 17:13:04 +03:00
|
|
|
};
|
|
|
|
typedef std::vector<Item> ItemVector;
|
|
|
|
ItemVector const& GetItems();
|
|
|
|
std::vector<std::string> const& GetDirectories();
|
|
|
|
std::vector<std::string> const& GetDepends();
|
|
|
|
std::vector<std::string> const& GetFrameworkPaths();
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string GetLinkLanguage() const { return this->LinkLanguage; }
|
2008-01-22 17:13:04 +03:00
|
|
|
std::vector<std::string> const& GetRuntimeSearchPath();
|
2008-01-29 23:07:33 +03:00
|
|
|
std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
|
|
|
|
std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
|
|
|
|
void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install);
|
|
|
|
std::string GetRPathString(bool for_install);
|
|
|
|
std::string GetChrpathString();
|
2015-10-08 01:51:05 +03:00
|
|
|
std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked();
|
2008-02-01 16:56:00 +03:00
|
|
|
|
|
|
|
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
|
|
|
|
std::string GetRPathLinkString();
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2008-01-22 17:13:04 +03:00
|
|
|
private:
|
2015-10-08 01:41:15 +03:00
|
|
|
void AddItem(std::string const& item, const cmGeneratorTarget* tgt);
|
|
|
|
void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt);
|
2008-01-22 17:13:04 +03: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-08 01:51:05 +03:00
|
|
|
std::set<cmGeneratorTarget const*> SharedLibrariesLinked;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Context information.
|
2015-08-04 20:19:50 +03:00
|
|
|
cmGeneratorTarget const* Target;
|
2008-01-22 17:13:04 +03:00
|
|
|
cmMakefile* Makefile;
|
|
|
|
cmGlobalGenerator* GlobalGenerator;
|
2008-02-04 23:22:10 +03:00
|
|
|
cmake* CMakeInstance;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Configuration information.
|
2014-02-10 07:48:34 +04:00
|
|
|
std::string Config;
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string LinkLanguage;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
2008-01-31 23:45:31 +03:00
|
|
|
// Modes for dealing with dependent shared libraries.
|
|
|
|
enum SharedDepMode
|
|
|
|
{
|
2008-02-21 19:41:11 +03: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 23:45:31 +03:00
|
|
|
};
|
|
|
|
|
2008-01-22 17:13:04 +03:00
|
|
|
const char* LoaderFlag;
|
|
|
|
std::string LibLinkFlag;
|
2008-01-23 21:30:55 +03:00
|
|
|
std::string LibLinkFileFlag;
|
2008-01-22 17:13:04 +03:00
|
|
|
std::string LibLinkSuffix;
|
2008-01-29 23:07:33 +03:00
|
|
|
std::string RuntimeFlag;
|
|
|
|
std::string RuntimeSep;
|
|
|
|
std::string RuntimeAlways;
|
2008-02-01 16:56:00 +03:00
|
|
|
std::string RPathLinkFlag;
|
2008-01-31 23:45:31 +03:00
|
|
|
SharedDepMode SharedDependencyMode;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
enum LinkType
|
|
|
|
{
|
|
|
|
LinkUnknown,
|
|
|
|
LinkStatic,
|
|
|
|
LinkShared
|
|
|
|
};
|
2015-06-06 10:59:24 +03:00
|
|
|
void SetCurrentLinkType(LinkType lt);
|
|
|
|
|
2008-01-22 17:13:04 +03: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 09:21:34 +04:00
|
|
|
std::set<std::string> LinkPrefixes;
|
2008-01-22 17:13:04 +03:00
|
|
|
cmsys::RegularExpression ExtractStaticLibraryName;
|
|
|
|
cmsys::RegularExpression ExtractSharedLibraryName;
|
|
|
|
cmsys::RegularExpression ExtractAnyLibraryName;
|
2008-05-01 02:04:48 +04:00
|
|
|
std::string SharedRegexString;
|
2008-01-22 17:13:04 +03:00
|
|
|
void AddLinkPrefix(const char* p);
|
|
|
|
void AddLinkExtension(const char* e, LinkType type);
|
2013-04-11 18:55:36 +04:00
|
|
|
std::string CreateExtensionRegex(std::vector<std::string> const& exts,
|
|
|
|
LinkType type);
|
2008-01-22 17:13:04 +03:00
|
|
|
std::string NoCaseExpression(const char* str);
|
|
|
|
|
2008-02-21 19:41:11 +03:00
|
|
|
// Handling of link items.
|
2015-10-08 01:45:02 +03:00
|
|
|
void AddTargetItem(std::string const& item, const cmGeneratorTarget* target);
|
2008-01-22 18:05:27 +03:00
|
|
|
void AddFullItem(std::string const& item);
|
2008-01-31 15:50:40 +03:00
|
|
|
bool CheckImplicitDirItem(std::string const& item);
|
2008-07-23 20:19:54 +04:00
|
|
|
void AddUserItem(std::string const& item, bool pathNotKnown);
|
2008-01-22 17:13:04 +03:00
|
|
|
void AddDirectoryItem(std::string const& item);
|
|
|
|
void AddFrameworkItem(std::string const& item);
|
|
|
|
void DropDirectoryItem(std::string const& item);
|
2008-02-21 19:41:11 +03:00
|
|
|
bool CheckSharedLibNoSOName(std::string const& item);
|
|
|
|
void AddSharedLibNoSOName(std::string const& item);
|
2008-07-23 20:59:14 +04:00
|
|
|
void HandleBadFullItem(std::string const& item, std::string const& file);
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Framework info.
|
|
|
|
void ComputeFrameworkInfo();
|
|
|
|
void AddFrameworkPath(std::string const& p);
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> FrameworkPathsEmmitted;
|
2008-01-22 17:13:04 +03:00
|
|
|
cmsys::RegularExpression SplitFramework;
|
|
|
|
|
|
|
|
// Linker search path computation.
|
2008-02-21 19:41:11 +03:00
|
|
|
cmOrderDirectories* OrderLinkerSearchPath;
|
2008-03-13 23:23:18 +03:00
|
|
|
bool FinishLinkerSearchDirectories();
|
2008-03-21 04:11:26 +03:00
|
|
|
void PrintLinkPolicyDiagnosis(std::ostream&);
|
2009-07-27 20:43:17 +04:00
|
|
|
|
|
|
|
// Implicit link libraries and directories for linker language.
|
2009-07-14 18:14:52 +04:00
|
|
|
void LoadImplicitLinkInfo();
|
2009-08-24 21:15:47 +04:00
|
|
|
void AddImplicitLinkInfo();
|
|
|
|
void AddImplicitLinkInfo(std::string const& lang);
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> ImplicitLinkDirs;
|
|
|
|
std::set<std::string> ImplicitLinkLibs;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
2010-02-15 19:22:36 +03:00
|
|
|
// Additional paths configured by the runtime linker
|
|
|
|
std::vector<std::string> RuntimeLinkDirs;
|
|
|
|
|
2008-01-23 23:22:38 +03:00
|
|
|
// Linker search path compatibility mode.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> OldLinkDirMask;
|
2008-02-21 19:41:11 +03:00
|
|
|
std::vector<std::string> OldLinkDirItems;
|
2008-03-13 23:23:18 +03:00
|
|
|
std::vector<std::string> OldUserFlagItems;
|
2015-04-07 17:43:47 +03:00
|
|
|
std::set<std::string> CMP0060WarnItems;
|
2015-06-06 10:59:24 +03:00
|
|
|
// Dependent library path computation.
|
|
|
|
cmOrderDirectories* OrderDependentRPath;
|
2008-01-22 17:13:04 +03:00
|
|
|
// Runtime path computation.
|
2008-02-21 19:41:11 +03:00
|
|
|
cmOrderDirectories* OrderRuntimeSearchPath;
|
2015-06-06 10:59:24 +03:00
|
|
|
|
|
|
|
bool OldLinkDirMode;
|
|
|
|
bool OpenBSD;
|
|
|
|
bool LinkDependsNoShared;
|
|
|
|
bool UseImportLibrary;
|
|
|
|
bool RuntimeUseChrpath;
|
|
|
|
bool NoSONameUsesPath;
|
|
|
|
bool LinkWithRuntimePath;
|
|
|
|
bool LinkTypeEnabled;
|
|
|
|
bool ArchivesMayBeShared;
|
|
|
|
bool CMP0060Warn;
|
|
|
|
|
2013-12-10 18:30:41 +04:00
|
|
|
void AddLibraryRuntimeInfo(std::string const& fullPath,
|
2015-10-08 01:45:02 +03:00
|
|
|
const cmGeneratorTarget* target);
|
2008-02-06 21:34:44 +03:00
|
|
|
void AddLibraryRuntimeInfo(std::string const& fullPath);
|
2008-01-22 17:13:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|