CMake/Source/cmLinkItem.h

163 lines
3.9 KiB
C
Raw 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 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
#include "cmConfigure.h" // IWYU pragma: keep
#include <algorithm>
#include <map>
#include <string>
#include <vector>
2015-08-04 17:49:49 +00:00
#include "cmListFileCache.h"
#include "cmSystemTools.h"
#include "cmTargetLinkLibraryType.h"
2015-08-04 17:49:49 +00:00
class cmGeneratorTarget;
2015-08-04 17:49:49 +00:00
// Basic information about each link item.
class cmLinkItem : public std::string
2015-08-04 17:49:49 +00:00
{
typedef std::string std_string;
2015-08-04 17:49:49 +00:00
public:
cmLinkItem()
: std_string()
2017-08-22 21:42:36 +00:00
, Target(nullptr)
{
}
cmLinkItem(const std_string& n, cmGeneratorTarget const* t)
: std_string(n)
, Target(t)
{
}
2015-10-07 23:18:42 +00:00
cmGeneratorTarget const* Target;
2015-08-04 17:49:49 +00:00
};
class cmLinkImplItem : public cmLinkItem
2015-08-04 17:49:49 +00:00
{
public:
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)
{
}
2015-08-04 17:49:49 +00: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;
};
struct cmLinkInterface : public cmLinkInterfaceLibraries
{
// 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.
unsigned int Multiplicity;
// Libraries listed for other configurations.
// Needed only for OLD behavior of CMP0003.
std::vector<cmLinkItem> WrongConfigLibraries;
bool ImplementationIsInterface;
cmLinkInterface()
: Multiplicity(0)
, ImplementationIsInterface(false)
{
}
};
struct cmOptionalLinkInterface : public cmLinkInterface
{
cmOptionalLinkInterface()
: LibrariesDone(false)
, AllDone(false)
, Exists(false)
, HadHeadSensitiveCondition(false)
2017-08-22 21:42:36 +00:00
, ExplicitLibraries(nullptr)
{
}
bool LibrariesDone;
bool AllDone;
bool Exists;
bool HadHeadSensitiveCondition;
const char* ExplicitLibraries;
};
struct cmHeadToLinkInterfaceMap
: public std::map<cmGeneratorTarget const*, cmOptionalLinkInterface>
{
};
struct cmLinkImplementation : public cmLinkImplementationLibraries
{
// Languages whose runtime libraries must be linked.
std::vector<std::string> Languages;
};
// Cache link implementation computation from each configuration.
struct cmOptionalLinkImplementation : public cmLinkImplementation
{
cmOptionalLinkImplementation()
: LibrariesDone(false)
, LanguagesDone(false)
, HadHeadSensitiveCondition(false)
{
}
bool LibrariesDone;
bool LanguagesDone;
bool HadHeadSensitiveCondition;
};
/** Compute the link type to use for the given configuration. */
inline cmTargetLinkLibraryType CMP0003_ComputeLinkType(
const std::string& config, std::vector<std::string> const& debugConfigs)
{
// No configuration is always optimized.
if (config.empty()) {
return OPTIMIZED_LibraryType;
}
// Check if any entry in the list matches this configuration.
std::string configUpper = cmSystemTools::UpperCase(config);
if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) !=
debugConfigs.end()) {
return DEBUG_LibraryType;
}
// The current configuration is not a debug configuration.
return OPTIMIZED_LibraryType;
}
2015-08-04 17:49:49 +00:00
#endif