CMake/Source/cmComputeLinkInformation.h

205 lines
6.3 KiB
C
Raw Permalink Normal View History

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
2016-09-27 22:01:08 +03:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmComputeLinkInformation_h
#define cmComputeLinkInformation_h
#include <cmConfigure.h> // IWYU pragma: keep
#include <cmsys/RegularExpression.hxx>
#include <iosfwd>
#include <set>
#include <string>
#include <vector>
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmMakefile;
class cmOrderDirectories;
class cmake;
/** \class cmComputeLinkInformation
* \brief Compute link information for a target in one configuration.
*/
class cmComputeLinkInformation
{
public:
cmComputeLinkInformation(cmGeneratorTarget const* target,
const std::string& config);
~cmComputeLinkInformation();
bool Compute();
struct Item
{
Item()
: Value()
, IsPath(true)
2016-06-27 23:44:16 +03:00
, Target(CM_NULLPTR)
{
}
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)
: Value(v)
, IsPath(p)
, Target(target)
{
}
std::string Value;
bool IsPath;
cmGeneratorTarget const* Target;
};
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();
std::string GetLinkLanguage() const { return this->LinkLanguage; }
std::vector<std::string> const& GetRuntimeSearchPath();
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();
std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked();
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
std::string GetRPathLinkString();
private:
void AddItem(std::string const& item, const cmGeneratorTarget* tgt);
void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt);
// Output information.
ItemVector Items;
std::vector<std::string> Directories;
std::vector<std::string> Depends;
std::vector<std::string> FrameworkPaths;
std::vector<std::string> RuntimeSearchPath;
std::set<cmGeneratorTarget const*> SharedLibrariesLinked;
// Context information.
cmGeneratorTarget const* Target;
cmMakefile* Makefile;
cmGlobalGenerator* GlobalGenerator;
cmake* CMakeInstance;
// Configuration information.
std::string Config;
std::string LinkLanguage;
// Modes for dealing with dependent shared libraries.
enum SharedDepMode
{
SharedDepModeNone, // Drop
SharedDepModeDir, // List dir in -rpath-link flag
SharedDepModeLibDir, // List dir in linker search path
SharedDepModeLink // List file on link line
};
const char* LoaderFlag;
std::string LibLinkFlag;
std::string LibLinkFileFlag;
std::string LibLinkSuffix;
std::string RuntimeFlag;
std::string RuntimeSep;
std::string RuntimeAlways;
std::string RPathLinkFlag;
SharedDepMode SharedDependencyMode;
enum LinkType
{
LinkUnknown,
LinkStatic,
LinkShared
};
void SetCurrentLinkType(LinkType lt);
// 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;
std::set<std::string> LinkPrefixes;
cmsys::RegularExpression ExtractStaticLibraryName;
cmsys::RegularExpression ExtractSharedLibraryName;
cmsys::RegularExpression ExtractAnyLibraryName;
std::string SharedRegexString;
void AddLinkPrefix(const char* p);
void AddLinkExtension(const char* e, LinkType type);
std::string CreateExtensionRegex(std::vector<std::string> const& exts,
LinkType type);
std::string NoCaseExpression(const char* str);
// Handling of link items.
void AddTargetItem(std::string const& item, const cmGeneratorTarget* target);
void AddFullItem(std::string const& item);
bool CheckImplicitDirItem(std::string const& item);
void AddUserItem(std::string const& item, bool pathNotKnown);
void AddDirectoryItem(std::string const& item);
void AddFrameworkItem(std::string const& item);
void DropDirectoryItem(std::string const& item);
bool CheckSharedLibNoSOName(std::string const& item);
void AddSharedLibNoSOName(std::string const& item);
void HandleBadFullItem(std::string const& item, std::string const& file);
// Framework info.
void ComputeFrameworkInfo();
void AddFrameworkPath(std::string const& p);
std::set<std::string> FrameworkPathsEmmitted;
cmsys::RegularExpression SplitFramework;
// Linker search path computation.
cmOrderDirectories* OrderLinkerSearchPath;
bool FinishLinkerSearchDirectories();
void PrintLinkPolicyDiagnosis(std::ostream&);
// Implicit link libraries and directories for linker language.
void LoadImplicitLinkInfo();
void AddImplicitLinkInfo();
void AddImplicitLinkInfo(std::string const& lang);
std::set<std::string> ImplicitLinkDirs;
std::set<std::string> ImplicitLinkLibs;
// Additional paths configured by the runtime linker
std::vector<std::string> RuntimeLinkDirs;
// Linker search path compatibility mode.
std::set<std::string> OldLinkDirMask;
std::vector<std::string> OldLinkDirItems;
std::vector<std::string> OldUserFlagItems;
std::set<std::string> CMP0060WarnItems;
// Dependent library path computation.
cmOrderDirectories* OrderDependentRPath;
// Runtime path computation.
cmOrderDirectories* OrderRuntimeSearchPath;
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,
const cmGeneratorTarget* target);
void AddLibraryRuntimeInfo(std::string const& fullPath);
};
#endif