cmake/Source/cmLinkItem.h

145 lines
4.1 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2015-11-17 17:22:37 +01:00
#ifndef cmLinkItem_h
#define cmLinkItem_h
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2017-04-14 19:02:05 +02:00
#include <map>
2018-10-28 12:09:07 +01:00
#include <ostream>
2017-04-14 19:02:05 +02:00
#include <string>
#include <vector>
2020-08-30 11:54:41 +02:00
#include <cmext/algorithm>
2015-11-17 17:22:37 +01:00
#include "cmListFileCache.h"
2016-03-13 13:35:51 +01:00
#include "cmSystemTools.h"
2017-04-14 19:02:05 +02:00
#include "cmTargetLinkLibraryType.h"
2015-11-17 17:22:37 +01:00
2016-03-13 13:35:51 +01:00
class cmGeneratorTarget;
2015-11-17 17:22:37 +01:00
// Basic information about each link item.
2018-10-28 12:09:07 +01:00
class cmLinkItem
2015-11-17 17:22:37 +01:00
{
2018-10-28 12:09:07 +01:00
std::string String;
2016-07-09 11:21:54 +02:00
2015-11-17 17:22:37 +01:00
public:
2018-10-28 12:09:07 +01:00
cmLinkItem();
2020-08-30 11:54:41 +02:00
cmLinkItem(std::string s, bool c, cmListFileBacktrace bt);
cmLinkItem(cmGeneratorTarget const* t, bool c, cmListFileBacktrace bt);
2018-10-28 12:09:07 +01:00
std::string const& AsStr() const;
2019-11-11 23:01:05 +01:00
cmGeneratorTarget const* Target = nullptr;
2020-08-30 11:54:41 +02:00
bool Cross = false;
2019-11-11 23:01:05 +01:00
cmListFileBacktrace Backtrace;
2018-10-28 12:09:07 +01:00
friend bool operator<(cmLinkItem const& l, cmLinkItem const& r);
friend bool operator==(cmLinkItem const& l, cmLinkItem const& r);
friend std::ostream& operator<<(std::ostream& os, cmLinkItem const& item);
2015-11-17 17:22:37 +01:00
};
2016-07-09 11:21:54 +02:00
class cmLinkImplItem : public cmLinkItem
2015-11-17 17:22:37 +01:00
{
public:
2018-10-28 12:09:07 +01:00
cmLinkImplItem();
2019-11-11 23:01:05 +01:00
cmLinkImplItem(cmLinkItem item, bool fromGenex);
bool FromGenex = false;
2015-11-17 17:22:37 +01:00
};
/** The link implementation specifies the direct library
dependencies needed by the object files of the target. */
struct cmLinkImplementationLibraries
{
// Libraries linked directly in this configuration.
std::vector<cmLinkImplItem> Libraries;
// Libraries linked directly in other configurations.
// Needed only for OLD behavior of CMP0003.
std::vector<cmLinkItem> WrongConfigLibraries;
2020-08-30 11:54:41 +02:00
// Whether the list depends on a genex referencing the configuration.
bool HadContextSensitiveCondition = false;
2015-11-17 17:22:37 +01:00
};
struct cmLinkInterfaceLibraries
{
// Libraries listed in the interface.
std::vector<cmLinkItem> Libraries;
2020-02-01 23:06:01 +01:00
// Whether the list depends on a genex referencing the head target.
bool HadHeadSensitiveCondition = false;
2020-08-30 11:54:41 +02:00
// Whether the list depends on a genex referencing the configuration.
bool HadContextSensitiveCondition = false;
2015-11-17 17:22:37 +01:00
};
2016-07-09 11:21:54 +02:00
struct cmLinkInterface : public cmLinkInterfaceLibraries
2015-11-17 17:22:37 +01:00
{
// 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;
// Number of repetitions of a strongly connected component of two
// or more static libraries.
2019-11-11 23:01:05 +01:00
unsigned int Multiplicity = 0;
2015-11-17 17:22:37 +01:00
// Libraries listed for other configurations.
// Needed only for OLD behavior of CMP0003.
std::vector<cmLinkItem> WrongConfigLibraries;
2019-11-11 23:01:05 +01:00
bool ImplementationIsInterface = false;
2020-08-30 11:54:41 +02:00
// Whether the list depends on a link language genex.
bool HadLinkLanguageSensitiveCondition = false;
2015-11-17 17:22:37 +01:00
};
2016-07-09 11:21:54 +02:00
struct cmOptionalLinkInterface : public cmLinkInterface
2015-11-17 17:22:37 +01:00
{
2019-11-11 23:01:05 +01:00
bool LibrariesDone = false;
bool AllDone = false;
bool Exists = false;
2020-02-01 23:06:01 +01:00
bool Explicit = false;
2015-11-17 17:22:37 +01:00
};
2016-07-09 11:21:54 +02:00
struct cmHeadToLinkInterfaceMap
: public std::map<cmGeneratorTarget const*, cmOptionalLinkInterface>
2015-11-17 17:22:37 +01:00
{
};
2016-07-09 11:21:54 +02:00
struct cmLinkImplementation : public cmLinkImplementationLibraries
2015-11-17 17:22:37 +01:00
{
// Languages whose runtime libraries must be linked.
std::vector<std::string> Languages;
2020-08-30 11:54:41 +02:00
// Whether the list depends on a link language genex.
bool HadLinkLanguageSensitiveCondition = false;
2015-11-17 17:22:37 +01:00
};
// Cache link implementation computation from each configuration.
2016-07-09 11:21:54 +02:00
struct cmOptionalLinkImplementation : public cmLinkImplementation
2015-11-17 17:22:37 +01:00
{
2019-11-11 23:01:05 +01:00
bool LibrariesDone = false;
bool LanguagesDone = false;
bool HadHeadSensitiveCondition = false;
2015-11-17 17:22:37 +01:00
};
2016-03-13 13:35:51 +01:00
/** Compute the link type to use for the given configuration. */
2016-07-09 11:21:54 +02:00
inline cmTargetLinkLibraryType CMP0003_ComputeLinkType(
const std::string& config, std::vector<std::string> const& debugConfigs)
2016-03-13 13:35:51 +01:00
{
// No configuration is always optimized.
2016-07-09 11:21:54 +02:00
if (config.empty()) {
2016-03-13 13:35:51 +01:00
return OPTIMIZED_LibraryType;
2016-07-09 11:21:54 +02:00
}
2016-03-13 13:35:51 +01:00
// Check if any entry in the list matches this configuration.
std::string configUpper = cmSystemTools::UpperCase(config);
2020-08-30 11:54:41 +02:00
if (cm::contains(debugConfigs, configUpper)) {
2016-03-13 13:35:51 +01:00
return DEBUG_LibraryType;
2016-07-09 11:21:54 +02:00
}
2016-03-13 13:35:51 +01:00
// The current configuration is not a debug configuration.
return OPTIMIZED_LibraryType;
}
2015-11-17 17:22:37 +01:00
#endif