cmake/Source/cmLinkItem.h

174 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
2017-04-14 19:02:05 +02:00
#include <cmConfigure.h>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
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.
2016-07-09 11:21:54 +02:00
class cmLinkItem : public std::string
2015-11-17 17:22:37 +01:00
{
typedef std::string std_string;
2016-07-09 11:21:54 +02:00
2015-11-17 17:22:37 +01:00
public:
2016-07-09 11:21:54 +02:00
cmLinkItem()
: std_string()
2016-10-30 18:24:19 +01:00
, Target(CM_NULLPTR)
2016-07-09 11:21:54 +02:00
{
}
cmLinkItem(const std_string& n, cmGeneratorTarget const* t)
: std_string(n)
, Target(t)
{
}
cmLinkItem(cmLinkItem const& r)
: std_string(r)
, Target(r.Target)
{
}
2016-03-13 13:35:51 +01:00
cmGeneratorTarget const* Target;
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:
2016-07-09 11:21:54 +02:00
cmLinkImplItem()
: cmLinkItem()
, Backtrace()
, FromGenex(false)
{
}
cmLinkImplItem(std::string const& n, cmGeneratorTarget const* t,
cmListFileBacktrace const& bt, bool fromGenex)
: cmLinkItem(n, t)
, Backtrace(bt)
, FromGenex(fromGenex)
{
}
cmLinkImplItem(cmLinkImplItem const& r)
: cmLinkItem(r)
, Backtrace(r.Backtrace)
, FromGenex(r.FromGenex)
{
}
2015-11-17 17:22:37 +01:00
cmListFileBacktrace Backtrace;
bool FromGenex;
};
/** 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;
};
struct cmLinkInterfaceLibraries
{
// Libraries listed in the interface.
std::vector<cmLinkItem> Libraries;
};
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.
2016-07-09 11:21:54 +02:00
unsigned int Multiplicity;
2015-11-17 17:22:37 +01:00
// Libraries listed for other configurations.
// Needed only for OLD behavior of CMP0003.
std::vector<cmLinkItem> WrongConfigLibraries;
bool ImplementationIsInterface;
2016-07-09 11:21:54 +02:00
cmLinkInterface()
: Multiplicity(0)
, ImplementationIsInterface(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
{
2016-07-09 11:21:54 +02:00
cmOptionalLinkInterface()
: LibrariesDone(false)
, AllDone(false)
, Exists(false)
, HadHeadSensitiveCondition(false)
2016-10-30 18:24:19 +01:00
, ExplicitLibraries(CM_NULLPTR)
2016-07-09 11:21:54 +02:00
{
}
2015-11-17 17:22:37 +01:00
bool LibrariesDone;
bool AllDone;
bool Exists;
bool HadHeadSensitiveCondition;
const char* ExplicitLibraries;
};
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;
};
// 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
{
2016-07-09 11:21:54 +02:00
cmOptionalLinkImplementation()
: LibrariesDone(false)
, LanguagesDone(false)
, HadHeadSensitiveCondition(false)
{
}
2015-11-17 17:22:37 +01:00
bool LibrariesDone;
bool LanguagesDone;
bool HadHeadSensitiveCondition;
};
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);
if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) !=
2016-07-09 11:21:54 +02:00
debugConfigs.end()) {
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