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. */
|
2015-08-04 17:49:49 +00:00
|
|
|
#ifndef cmLinkItem_h
|
|
|
|
#define cmLinkItem_h
|
|
|
|
|
2016-11-05 20:40:14 +00:00
|
|
|
#include <cmConfigure.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2015-08-04 17:49:49 +00:00
|
|
|
#include "cmListFileCache.h"
|
2015-10-19 22:57:35 +00:00
|
|
|
#include "cmSystemTools.h"
|
2016-11-05 20:40:14 +00:00
|
|
|
#include "cmTargetLinkLibraryType.h"
|
2015-08-04 17:49:49 +00:00
|
|
|
|
2015-10-07 23:05:41 +00:00
|
|
|
class cmGeneratorTarget;
|
2015-08-04 17:49:49 +00:00
|
|
|
|
|
|
|
// Basic information about each link item.
|
2016-05-16 14:34:04 +00:00
|
|
|
class cmLinkItem : public std::string
|
2015-08-04 17:49:49 +00:00
|
|
|
{
|
|
|
|
typedef std::string std_string;
|
2016-05-16 14:34:04 +00:00
|
|
|
|
2015-08-04 17:49:49 +00:00
|
|
|
public:
|
2016-05-16 14:34:04 +00:00
|
|
|
cmLinkItem()
|
|
|
|
: std_string()
|
2016-06-27 20:44:16 +00:00
|
|
|
, Target(CM_NULLPTR)
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
cmLinkItem(const std_string& n, cmGeneratorTarget const* t)
|
|
|
|
: std_string(n)
|
|
|
|
, Target(t)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
cmLinkItem(cmLinkItem const& r)
|
|
|
|
: std_string(r)
|
|
|
|
, Target(r.Target)
|
|
|
|
{
|
|
|
|
}
|
2015-10-07 23:18:42 +00:00
|
|
|
cmGeneratorTarget const* Target;
|
2015-08-04 17:49:49 +00:00
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
class cmLinkImplItem : public cmLinkItem
|
2015-08-04 17:49:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-05-16 14:34:04 +00: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-08-04 17:49:49 +00:00
|
|
|
cmListFileBacktrace Backtrace;
|
|
|
|
bool FromGenex;
|
|
|
|
};
|
|
|
|
|
2015-08-04 17:55:46 +00: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;
|
|
|
|
};
|
|
|
|
|
2015-08-26 17:35:45 +00:00
|
|
|
struct cmLinkInterfaceLibraries
|
|
|
|
{
|
|
|
|
// Libraries listed in the interface.
|
|
|
|
std::vector<cmLinkItem> Libraries;
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
struct cmLinkInterface : public cmLinkInterfaceLibraries
|
2015-08-26 17:35:45 +00: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-02-03 22:22:38 +00:00
|
|
|
unsigned int Multiplicity;
|
2015-08-26 17:35:45 +00:00
|
|
|
|
|
|
|
// Libraries listed for other configurations.
|
|
|
|
// Needed only for OLD behavior of CMP0003.
|
|
|
|
std::vector<cmLinkItem> WrongConfigLibraries;
|
|
|
|
|
|
|
|
bool ImplementationIsInterface;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmLinkInterface()
|
|
|
|
: Multiplicity(0)
|
|
|
|
, ImplementationIsInterface(false)
|
|
|
|
{
|
|
|
|
}
|
2015-08-26 17:35:45 +00:00
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
struct cmOptionalLinkInterface : public cmLinkInterface
|
2015-08-26 17:35:45 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
cmOptionalLinkInterface()
|
|
|
|
: LibrariesDone(false)
|
|
|
|
, AllDone(false)
|
|
|
|
, Exists(false)
|
|
|
|
, HadHeadSensitiveCondition(false)
|
2016-06-27 20:44:16 +00:00
|
|
|
, ExplicitLibraries(CM_NULLPTR)
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
}
|
2015-08-26 17:35:45 +00:00
|
|
|
bool LibrariesDone;
|
|
|
|
bool AllDone;
|
|
|
|
bool Exists;
|
|
|
|
bool HadHeadSensitiveCondition;
|
|
|
|
const char* ExplicitLibraries;
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
struct cmHeadToLinkInterfaceMap
|
|
|
|
: public std::map<cmGeneratorTarget const*, cmOptionalLinkInterface>
|
2015-08-26 17:37:06 +00:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
struct cmLinkImplementation : public cmLinkImplementationLibraries
|
2015-08-05 15:37:48 +00:00
|
|
|
{
|
|
|
|
// Languages whose runtime libraries must be linked.
|
|
|
|
std::vector<std::string> Languages;
|
|
|
|
};
|
|
|
|
|
2015-08-05 15:37:48 +00:00
|
|
|
// Cache link implementation computation from each configuration.
|
2016-05-16 14:34:04 +00:00
|
|
|
struct cmOptionalLinkImplementation : public cmLinkImplementation
|
2015-08-05 15:37:48 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
cmOptionalLinkImplementation()
|
|
|
|
: LibrariesDone(false)
|
|
|
|
, LanguagesDone(false)
|
|
|
|
, HadHeadSensitiveCondition(false)
|
|
|
|
{
|
|
|
|
}
|
2015-08-05 15:37:48 +00:00
|
|
|
bool LibrariesDone;
|
|
|
|
bool LanguagesDone;
|
|
|
|
bool HadHeadSensitiveCondition;
|
|
|
|
};
|
|
|
|
|
2015-10-19 22:57:35 +00:00
|
|
|
/** Compute the link type to use for the given configuration. */
|
2016-05-16 14:34:04 +00:00
|
|
|
inline cmTargetLinkLibraryType CMP0003_ComputeLinkType(
|
|
|
|
const std::string& config, std::vector<std::string> const& debugConfigs)
|
2015-10-19 22:57:35 +00:00
|
|
|
{
|
|
|
|
// No configuration is always optimized.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (config.empty()) {
|
2015-10-19 22:57:35 +00:00
|
|
|
return OPTIMIZED_LibraryType;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-19 22:57:35 +00: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-05-16 14:34:04 +00:00
|
|
|
debugConfigs.end()) {
|
2015-10-19 22:57:35 +00:00
|
|
|
return DEBUG_LibraryType;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-19 22:57:35 +00:00
|
|
|
// The current configuration is not a debug configuration.
|
|
|
|
return OPTIMIZED_LibraryType;
|
|
|
|
}
|
|
|
|
|
2015-08-04 17:49:49 +00:00
|
|
|
#endif
|