summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx384
1 files changed, 244 insertions, 140 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index e8d66a25bf..6ce814058b 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2,6 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorTarget.h"
+#include <algorithm>
+#include <assert.h>
+#include <cmsys/RegularExpression.hxx>
+#include <errno.h>
+#include <iterator>
+#include <queue>
+#include <sstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
@@ -15,32 +26,38 @@
#include "cmPropertyMap.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
+#include "cmState.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
+#include "cmTargetPropertyComputer.h"
#include "cm_auto_ptr.hxx"
+#include "cm_unordered_set.hxx"
#include "cmake.h"
-#include <algorithm>
-#include <assert.h>
-#include <cmsys/RegularExpression.hxx>
-#include <errno.h>
-#include <iterator>
-#include <queue>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+class cmMessenger;
-#if defined(CMake_HAVE_CXX_UNORDERED_SET)
-#include <unordered_set>
-#define UNORDERED_SET std::unordered_set
-#elif defined(CMAKE_BUILD_WITH_CMAKE)
-#include <cmsys/hash_set.hxx>
-#define UNORDERED_SET cmsys::hash_set
-#else
-#define UNORDERED_SET std::set
-#endif
+template <>
+const char* cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
+ cmGeneratorTarget const* tgt, cmMessenger* /* messenger */,
+ cmListFileBacktrace const& /* context */)
+{
+ return tgt->GetSourcesProperty();
+}
+
+template <>
+const char* cmTargetPropertyComputer::ComputeLocationForBuild<
+ cmGeneratorTarget>(cmGeneratorTarget const* tgt)
+{
+ return tgt->GetLocation("");
+}
+
+template <>
+const char* cmTargetPropertyComputer::ComputeLocation<cmGeneratorTarget>(
+ cmGeneratorTarget const* tgt, const std::string& config)
+{
+ return tgt->GetLocation(config);
+}
class cmGeneratorTarget::TargetPropertyEntry
{
@@ -192,7 +209,7 @@ struct TagVisitor
, Target(target)
, GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator())
, Header(CM_HEADER_REGEX)
- , IsObjLib(target->GetType() == cmState::OBJECT_LIBRARY)
+ , IsObjLib(target->GetType() == cmStateEnums::OBJECT_LIBRARY)
{
}
@@ -207,7 +224,7 @@ struct TagVisitor
std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
if (sf->GetCustomCommand()) {
DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf);
- } else if (this->Target->GetType() == cmState::UTILITY) {
+ } else if (this->Target->GetType() == cmStateEnums::UTILITY) {
DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
} else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) {
DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
@@ -320,12 +337,32 @@ cmGeneratorTarget::~cmGeneratorTarget()
cmDeleteAll(this->LinkInformation);
}
+const char* cmGeneratorTarget::GetSourcesProperty() const
+{
+ std::vector<std::string> values;
+ for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
+ it = this->SourceEntries.begin(),
+ end = this->SourceEntries.end();
+ it != end; ++it) {
+ values.push_back((*it)->ge->GetInput());
+ }
+ static std::string value;
+ value.clear();
+ value = cmJoin(values, "");
+ return value.c_str();
+}
+
+cmGlobalGenerator* cmGeneratorTarget::GetGlobalGenerator() const
+{
+ return this->GetLocalGenerator()->GetGlobalGenerator();
+}
+
cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const
{
return this->LocalGenerator;
}
-cmState::TargetType cmGeneratorTarget::GetType() const
+cmStateEnums::TargetType cmGeneratorTarget::GetType() const
{
return this->Target->GetType();
}
@@ -354,13 +391,25 @@ std::string cmGeneratorTarget::GetExportName() const
const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
{
+ if (!cmTargetPropertyComputer::PassesWhitelist(
+ this->GetType(), prop, this->Makefile->GetMessenger(),
+ this->GetBacktrace())) {
+ return CM_NULLPTR;
+ }
+ if (const char* result = cmTargetPropertyComputer::GetProperty(
+ this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) {
+ return result;
+ }
+ if (cmSystemTools::GetFatalErrorOccured()) {
+ return CM_NULLPTR;
+ }
return this->Target->GetProperty(prop);
}
const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const
{
switch (this->GetType()) {
- case cmState::SHARED_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
if (this->IsDLLPlatform()) {
if (implib) {
// A DLL import library is treated as an archive target.
@@ -373,10 +422,10 @@ const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const
// library targets.
return "LIBRARY";
}
- case cmState::STATIC_LIBRARY:
+ case cmStateEnums::STATIC_LIBRARY:
// Static libraries are always treated as archive targets.
return "ARCHIVE";
- case cmState::MODULE_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
if (implib) {
// Module libraries are always treated as library targets.
return "ARCHIVE";
@@ -384,7 +433,7 @@ const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const
// Module import libraries are treated as archive targets.
return "LIBRARY";
}
- case cmState::EXECUTABLE:
+ case cmStateEnums::EXECUTABLE:
if (implib) {
// Executable import libraries are treated as archive targets.
return "ARCHIVE";
@@ -484,6 +533,21 @@ void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs)
}
}
+void cmGeneratorTarget::AddIncludeDirectory(const std::string& src,
+ bool before)
+{
+ this->Target->InsertInclude(src, this->Makefile->GetBacktrace(), before);
+ cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+ cmGeneratorExpression ge(lfbt);
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src);
+ cge->SetEvaluateForBuildsystem(true);
+ // Insert before begin/end
+ std::vector<TargetPropertyEntry*>::iterator pos = before
+ ? this->IncludeDirectoriesEntries.begin()
+ : this->IncludeDirectoriesEntries.end();
+ this->IncludeDirectoriesEntries.insert(pos, new TargetPropertyEntry(cge));
+}
+
std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
cmSourceFile const* sf) const
{
@@ -790,7 +854,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const
bool cmGeneratorTarget::IsSystemIncludeDirectory(
const std::string& dir, const std::string& config) const
{
- assert(this->GetType() != cmState::INTERFACE_LIBRARY);
+ assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
std::string config_upper;
if (!config.empty()) {
config_upper = cmSystemTools::UpperCase(config);
@@ -870,7 +934,7 @@ static void AddInterfaceEntries(
static bool processSources(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& srcs, UNORDERED_SET<std::string>& uniqueSrcs,
+ std::vector<std::string>& srcs, CM_UNORDERED_SET<std::string>& uniqueSrcs,
cmGeneratorExpressionDAGChecker* dagChecker, std::string const& config,
bool debugSources)
{
@@ -951,7 +1015,7 @@ static bool processSources(
void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files,
const std::string& config) const
{
- assert(this->GetType() != cmState::INTERFACE_LIBRARY);
+ assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
// At configure-time, this method can be called as part of getting the
@@ -997,7 +1061,7 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files,
cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "SOURCES",
CM_NULLPTR, CM_NULLPTR);
- UNORDERED_SET<std::string> uniqueSrcs;
+ CM_UNORDERED_SET<std::string> uniqueSrcs;
bool contextDependentDirectSources =
processSources(this, this->SourceEntries, files, uniqueSrcs, &dagChecker,
config, debugSources);
@@ -1096,7 +1160,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const
{
// soname is supported only for shared libraries and modules,
// and then only when the platform supports an soname flag.
- return ((this->GetType() == cmState::SHARED_LIBRARY) &&
+ return ((this->GetType() == cmStateEnums::SHARED_LIBRARY) &&
!this->GetPropertyAsBool("NO_SONAME") &&
this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config)));
}
@@ -1106,9 +1170,9 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall(
{
// Only executables and shared libraries can have an rpath and may
// need relinking.
- if (this->GetType() != cmState::EXECUTABLE &&
- this->GetType() != cmState::SHARED_LIBRARY &&
- this->GetType() != cmState::MODULE_LIBRARY) {
+ if (this->GetType() != cmStateEnums::EXECUTABLE &&
+ this->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GetType() != cmStateEnums::MODULE_LIBRARY) {
return false;
}
@@ -1180,9 +1244,9 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall(
bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const
{
// Only certain target types have an rpath.
- if (!(this->GetType() == cmState::SHARED_LIBRARY ||
- this->GetType() == cmState::MODULE_LIBRARY ||
- this->GetType() == cmState::EXECUTABLE)) {
+ if (!(this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::MODULE_LIBRARY ||
+ this->GetType() == cmStateEnums::EXECUTABLE)) {
return false;
}
@@ -1237,7 +1301,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const
bool cmGeneratorTarget::IsImportedSharedLibWithoutSOName(
const std::string& config) const
{
- if (this->IsImported() && this->GetType() == cmState::SHARED_LIBRARY) {
+ if (this->IsImported() && this->GetType() == cmStateEnums::SHARED_LIBRARY) {
if (cmGeneratorTarget::ImportInfo const* info =
this->GetImportInfo(config)) {
return info->NoSOName;
@@ -1253,7 +1317,7 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
bool macosx_rpath = false;
if (!this->IsImported()) {
- if (this->GetType() != cmState::SHARED_LIBRARY) {
+ if (this->GetType() != cmStateEnums::SHARED_LIBRARY) {
return false;
}
const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
@@ -1507,17 +1571,17 @@ const cmListFileBacktrace* cmGeneratorTarget::GetUtilityBacktrace(
bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
{
- return this->GetType() == cmState::STATIC_LIBRARY ||
- this->GetType() == cmState::SHARED_LIBRARY ||
- this->GetType() == cmState::MODULE_LIBRARY ||
- this->GetType() == cmState::EXECUTABLE;
+ return this->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::MODULE_LIBRARY ||
+ this->GetType() == cmStateEnums::EXECUTABLE;
}
const char* cmGeneratorTarget::GetExportMacro() const
{
// Define the symbol for targets that export symbols.
- if (this->GetType() == cmState::SHARED_LIBRARY ||
- this->GetType() == cmState::MODULE_LIBRARY ||
+ if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::MODULE_LIBRARY ||
this->IsExecutableWithExports()) {
if (const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) {
this->ExportMacro = custom_export_name;
@@ -1536,7 +1600,7 @@ class cmTargetCollectLinkLanguages
public:
cmTargetCollectLinkLanguages(cmGeneratorTarget const* target,
const std::string& config,
- UNORDERED_SET<std::string>& languages,
+ CM_UNORDERED_SET<std::string>& languages,
cmGeneratorTarget const* head)
: Config(config)
, Languages(languages)
@@ -1603,7 +1667,7 @@ public:
private:
std::string Config;
- UNORDERED_SET<std::string>& Languages;
+ CM_UNORDERED_SET<std::string>& Languages;
cmGeneratorTarget const* HeadTarget;
const cmGeneratorTarget* Target;
std::set<cmGeneratorTarget const*> Visited;
@@ -1675,7 +1739,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
LinkClosure& lc) const
{
// Get languages built in this target.
- UNORDERED_SET<std::string> languages;
+ CM_UNORDERED_SET<std::string> languages;
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
assert(impl);
for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
@@ -1692,7 +1756,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
}
// Store the transitive closure of languages.
- for (UNORDERED_SET<std::string>::const_iterator li = languages.begin();
+ for (CM_UNORDERED_SET<std::string>::const_iterator li = languages.begin();
li != languages.end(); ++li) {
lc.Languages.push_back(*li);
}
@@ -1713,7 +1777,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
}
// Now consider languages that propagate from linked targets.
- for (UNORDERED_SET<std::string>::const_iterator sit = languages.begin();
+ for (CM_UNORDERED_SET<std::string>::const_iterator sit = languages.begin();
sit != languages.end(); ++sit) {
std::string propagates =
"CMAKE_" + *sit + "_LINKER_PREFERENCE_PROPAGATES";
@@ -1767,6 +1831,22 @@ std::string cmGeneratorTarget::GetMacContentDirectory(
return fpath;
}
+std::string cmGeneratorTarget::GetEffectiveFolderName() const
+{
+ std::string effectiveFolder;
+
+ if (!this->GlobalGenerator->UseFolderProperty()) {
+ return effectiveFolder;
+ }
+
+ const char* targetFolder = this->GetProperty("FOLDER");
+ if (targetFolder) {
+ effectiveFolder += targetFolder;
+ }
+
+ return effectiveFolder;
+}
+
cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo(
const std::string& config) const
{
@@ -1775,7 +1855,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo(
return CM_NULLPTR;
}
- if (this->GetType() > cmState::OBJECT_LIBRARY) {
+ if (this->GetType() > cmStateEnums::OBJECT_LIBRARY) {
std::string msg = "cmTarget::GetCompileInfo called for ";
msg += this->GetName();
msg += " which has type ";
@@ -1952,7 +2032,7 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
this->CurrentEntry = CM_NULLPTR;
// Queue all the source files already specified for the target.
- if (target->GetType() != cmState::INTERFACE_LIBRARY) {
+ if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty()) {
@@ -2087,8 +2167,8 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
// then make sure it was not a full path to something else, and
// the fact that the name matched a target was just a coincidence.
if (cmSystemTools::FileIsFullPath(dep.c_str())) {
- if (t->GetType() >= cmState::EXECUTABLE &&
- t->GetType() <= cmState::MODULE_LIBRARY) {
+ if (t->GetType() >= cmStateEnums::EXECUTABLE &&
+ t->GetType() <= cmStateEnums::MODULE_LIBRARY) {
// This is really only for compatibility so we do not need to
// worry about configuration names and output names.
std::string tLocation = t->GetLocationForBuild();
@@ -2128,7 +2208,7 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
// Check for a target with this name.
if (cmGeneratorTarget* t =
this->LocalGenerator->FindGeneratorTargetToUse(command)) {
- if (t->GetType() == cmState::EXECUTABLE) {
+ if (t->GetType() == cmStateEnums::EXECUTABLE) {
// The command refers to an executable target built in
// this project. Add the target-level dependency to make
// sure the executable is up to date before this custom
@@ -2202,7 +2282,7 @@ void cmGeneratorTarget::TraceDependencies()
// would find nothing anyway, but when building CMake itself the "install"
// target command ends up referencing the "cmake" target but we do not
// really want the dependency because "install" depend on "all" anyway.
- if (this->GetType() == cmState::GLOBAL_TARGET) {
+ if (this->GetType() == cmStateEnums::GLOBAL_TARGET) {
return;
}
@@ -2241,7 +2321,7 @@ std::string cmGeneratorTarget::GetCreateRuleVariable(
std::string const& lang, std::string const& config) const
{
switch (this->GetType()) {
- case cmState::STATIC_LIBRARY: {
+ case cmStateEnums::STATIC_LIBRARY: {
std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY";
if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION", config)) {
std::string varIPO = var + "_IPO";
@@ -2251,11 +2331,11 @@ std::string cmGeneratorTarget::GetCreateRuleVariable(
}
return var;
}
- case cmState::SHARED_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY";
- case cmState::MODULE_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
return "CMAKE_" + lang + "_CREATE_SHARED_MODULE";
- case cmState::EXECUTABLE:
+ case cmStateEnums::EXECUTABLE:
return "CMAKE_" + lang + "_LINK_EXECUTABLE";
default:
break;
@@ -2266,7 +2346,7 @@ static void processIncludeDirectories(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
std::vector<std::string>& includes,
- UNORDERED_SET<std::string>& uniqueIncludes,
+ CM_UNORDERED_SET<std::string>& uniqueIncludes,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugIncludes, const std::string& language)
{
@@ -2379,7 +2459,7 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
const std::string& config, const std::string& lang) const
{
std::vector<std::string> includes;
- UNORDERED_SET<std::string> uniqueIncludes;
+ CM_UNORDERED_SET<std::string> uniqueIncludes;
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR);
@@ -2456,7 +2536,8 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
static void processCompileOptionsInternal(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+ std::vector<std::string>& options,
+ CM_UNORDERED_SET<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, const char* logName, std::string const& language)
{
@@ -2493,7 +2574,8 @@ static void processCompileOptionsInternal(
static void processCompileOptions(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+ std::vector<std::string>& options,
+ CM_UNORDERED_SET<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, std::string const& language)
{
@@ -2506,7 +2588,7 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
const std::string& config,
const std::string& language) const
{
- UNORDERED_SET<std::string> uniqueOptions;
+ CM_UNORDERED_SET<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "COMPILE_OPTIONS", CM_NULLPTR, CM_NULLPTR);
@@ -2546,7 +2628,8 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
static void processCompileFeatures(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+ std::vector<std::string>& options,
+ CM_UNORDERED_SET<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions)
{
@@ -2558,7 +2641,7 @@ static void processCompileFeatures(
void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
const std::string& config) const
{
- UNORDERED_SET<std::string> uniqueFeatures;
+ CM_UNORDERED_SET<std::string> uniqueFeatures;
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "COMPILE_FEATURES", CM_NULLPTR, CM_NULLPTR);
@@ -2595,7 +2678,8 @@ void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
static void processCompileDefinitions(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+ std::vector<std::string>& options,
+ CM_UNORDERED_SET<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, std::string const& language)
{
@@ -2608,7 +2692,7 @@ void cmGeneratorTarget::GetCompileDefinitions(
std::vector<std::string>& list, const std::string& config,
const std::string& language) const
{
- UNORDERED_SET<std::string> uniqueOptions;
+ CM_UNORDERED_SET<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "COMPILE_DEFINITIONS", CM_NULLPTR, CM_NULLPTR);
@@ -2682,11 +2766,11 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
std::string realName;
std::string impName;
std::string pdbName;
- if (this->GetType() == cmState::EXECUTABLE) {
+ if (this->GetType() == cmStateEnums::EXECUTABLE) {
this->GetExecutableNames(name, realName, impName, pdbName, config);
- } else if (this->GetType() == cmState::STATIC_LIBRARY ||
- this->GetType() == cmState::SHARED_LIBRARY ||
- this->GetType() == cmState::MODULE_LIBRARY) {
+ } else if (this->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::MODULE_LIBRARY) {
this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
} else {
return;
@@ -2729,6 +2813,16 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
}
}
+std::string cmGeneratorTarget::GetImportedLibName(
+ std::string const& config) const
+{
+ if (cmGeneratorTarget::ImportInfo const* info =
+ this->GetImportInfo(config)) {
+ return info->LibName;
+ }
+ return std::string();
+}
+
std::string cmGeneratorTarget::GetFullPath(const std::string& config,
bool implib, bool realname) const
{
@@ -2772,7 +2866,7 @@ std::string cmGeneratorTarget::NormalGetRealName(
this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
}
- if (this->GetType() == cmState::EXECUTABLE) {
+ if (this->GetType() == cmStateEnums::EXECUTABLE) {
// Compute the real name that will be built.
std::string name;
std::string realName;
@@ -2855,8 +2949,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
}
// The import library name.
- if (this->GetType() == cmState::SHARED_LIBRARY ||
- this->GetType() == cmState::MODULE_LIBRARY) {
+ if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::MODULE_LIBRARY) {
impName = this->GetFullNameInternal(config, true);
} else {
impName = "";
@@ -2888,7 +2982,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
#else
// Check for executable version properties.
const char* version = this->GetProperty("VERSION");
- if (this->GetType() != cmState::EXECUTABLE ||
+ if (this->GetType() != cmStateEnums::EXECUTABLE ||
this->Makefile->IsOn("XCODE")) {
version = CM_NULLPTR;
}
@@ -2957,10 +3051,10 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
std::string& outSuffix) const
{
// Use just the target name for non-main target types.
- if (this->GetType() != cmState::STATIC_LIBRARY &&
- this->GetType() != cmState::SHARED_LIBRARY &&
- this->GetType() != cmState::MODULE_LIBRARY &&
- this->GetType() != cmState::EXECUTABLE) {
+ if (this->GetType() != cmStateEnums::STATIC_LIBRARY &&
+ this->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GetType() != cmStateEnums::MODULE_LIBRARY &&
+ this->GetType() != cmStateEnums::EXECUTABLE) {
outPrefix = "";
outBase = this->GetName();
outSuffix = "";
@@ -2979,9 +3073,9 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
// The implib option is only allowed for shared libraries, module
// libraries, and executables.
- if (this->GetType() != cmState::SHARED_LIBRARY &&
- this->GetType() != cmState::MODULE_LIBRARY &&
- this->GetType() != cmState::EXECUTABLE) {
+ if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GetType() != cmStateEnums::MODULE_LIBRARY &&
+ this->GetType() != cmStateEnums::EXECUTABLE) {
implib = false;
}
@@ -3059,7 +3153,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
// Name shared libraries with their version number on some platforms.
if (const char* soversion = this->GetProperty("SOVERSION")) {
- if (this->GetType() == cmState::SHARED_LIBRARY && !implib &&
+ if (this->GetType() == cmStateEnums::SHARED_LIBRARY && !implib &&
this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) {
outBase += "-";
outBase += soversion;
@@ -3225,8 +3319,8 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty(
const std::string& p, const std::string& config) const
{
- if (this->GetType() == cmState::OBJECT_LIBRARY ||
- this->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return false;
}
return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0;
@@ -3235,8 +3329,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty(
bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty(
const std::string& p, const std::string& config) const
{
- if (this->GetType() == cmState::OBJECT_LIBRARY ||
- this->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return false;
}
return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0;
@@ -3245,8 +3339,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty(
bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty(
const std::string& p, const std::string& config) const
{
- if (this->GetType() == cmState::OBJECT_LIBRARY ||
- this->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return false;
}
return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0;
@@ -3255,8 +3349,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty(
bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty(
const std::string& p, const std::string& config) const
{
- if (this->GetType() == cmState::OBJECT_LIBRARY ||
- this->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return false;
}
return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0;
@@ -3295,7 +3389,8 @@ const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
{
switch (t) {
case BoolType:
- assert(0 && "String compatibility check function called for boolean");
+ assert(false &&
+ "String compatibility check function called for boolean");
return CM_NULLPTR;
case StringType:
return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
@@ -3304,7 +3399,7 @@ const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
case NumberMaxType:
return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config);
}
- assert(0 && "Unreachable!");
+ assert(false && "Unreachable!");
return CM_NULLPTR;
}
@@ -3495,7 +3590,7 @@ std::string compatibilityType(CompatibleType t)
case NumberMinType:
return "Numeric minimum compatibility";
}
- assert(0 && "Unreachable!");
+ assert(false && "Unreachable!");
return "";
}
@@ -3509,7 +3604,7 @@ std::string compatibilityAgree(CompatibleType t, bool dominant)
case NumberMinType:
return dominant ? "(Dominant)\n" : "(Ignored)\n";
}
- assert(0 && "Unreachable!");
+ assert(false && "Unreachable!");
return "";
}
@@ -3619,7 +3714,7 @@ std::pair<bool, const char*> consistentProperty(const char* lhs,
switch (t) {
case BoolType:
- assert(0 && "consistentProperty for strings called with BoolType");
+ assert(false && "consistentProperty for strings called with BoolType");
return std::pair<bool, const char*>(false, null_ptr);
case StringType:
return consistentStringProperty(lhs, rhs);
@@ -3627,7 +3722,7 @@ std::pair<bool, const char*> consistentProperty(const char* lhs,
case NumberMaxType:
return consistentNumberProperty(lhs, rhs, t);
}
- assert(0 && "Unreachable!");
+ assert(false && "Unreachable!");
return std::pair<bool, const char*>(false, null_ptr);
}
@@ -3850,7 +3945,7 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major,
minor = 0;
patch = 0;
- assert(this->GetType() != cmState::INTERFACE_LIBRARY);
+ assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
// Look for a VERSION or SOVERSION property.
const char* prop = soversion ? "SOVERSION" : "VERSION";
@@ -3878,9 +3973,9 @@ std::string cmGeneratorTarget::GetFortranModuleDirectory(
std::string const& working_dir) const
{
if (!this->FortranModuleDirectoryCreated) {
- this->FortranModuleDirectory = true;
this->FortranModuleDirectory =
this->CreateFortranModuleDirectory(working_dir);
+ this->FortranModuleDirectoryCreated = true;
}
return this->FortranModuleDirectory;
@@ -3922,7 +4017,7 @@ std::string cmGeneratorTarget::CreateFortranModuleDirectory(
std::string cmGeneratorTarget::GetFrameworkVersion() const
{
- assert(this->GetType() != cmState::INTERFACE_LIBRARY);
+ assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) {
return fversion;
@@ -3950,7 +4045,7 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
{
- cmPropertyMap propsObject = this->Target->GetProperties();
+ cmPropertyMap const& propsObject = this->Target->GetProperties();
std::vector<std::string> props;
props.reserve(propsObject.size());
for (cmPropertyMap::const_iterator it = propsObject.begin();
@@ -4038,7 +4133,7 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(
// Link interfaces are not supported for executables that do not
// export symbols.
- if (this->GetType() == cmState::EXECUTABLE &&
+ if (this->GetType() == cmStateEnums::EXECUTABLE &&
!this->IsExecutableWithExports()) {
return CM_NULLPTR;
}
@@ -4072,18 +4167,18 @@ void cmGeneratorTarget::ComputeLinkInterface(
cmGeneratorTarget const* headTarget) const
{
if (iface.ExplicitLibraries) {
- if (this->GetType() == cmState::SHARED_LIBRARY ||
- this->GetType() == cmState::STATIC_LIBRARY ||
- this->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Shared libraries may have runtime implementation dependencies
// on other shared libraries that are not in the interface.
- UNORDERED_SET<std::string> emitted;
+ CM_UNORDERED_SET<std::string> emitted;
for (std::vector<cmLinkItem>::const_iterator li =
iface.Libraries.begin();
li != iface.Libraries.end(); ++li) {
emitted.insert(*li);
}
- if (this->GetType() != cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
for (std::vector<cmLinkImplItem>::const_iterator li =
impl->Libraries.begin();
@@ -4091,7 +4186,7 @@ void cmGeneratorTarget::ComputeLinkInterface(
if (emitted.insert(*li).second) {
if (li->Target) {
// This is a runtime dependency on another shared library.
- if (li->Target->GetType() == cmState::SHARED_LIBRARY) {
+ if (li->Target->GetType() == cmStateEnums::SHARED_LIBRARY) {
iface.SharedDeps.push_back(*li);
}
} else {
@@ -4121,7 +4216,7 @@ void cmGeneratorTarget::ComputeLinkInterface(
}
}
- if (this->GetType() == cmState::STATIC_LIBRARY) {
+ if (this->GetType() == cmStateEnums::STATIC_LIBRARY) {
// Construct the property name suffix for this configuration.
std::string suffix = "_";
if (!config.empty()) {
@@ -4154,7 +4249,7 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries(
// Link interfaces are not supported for executables that do not
// export symbols.
- if (this->GetType() == cmState::EXECUTABLE &&
+ if (this->GetType() == cmStateEnums::EXECUTABLE &&
!this->IsExecutableWithExports()) {
return CM_NULLPTR;
}
@@ -4301,12 +4396,12 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
if (out != outdir) {
conf = "";
}
- } else if (this->GetType() == cmState::EXECUTABLE) {
+ } else if (this->GetType() == cmStateEnums::EXECUTABLE) {
// Lookup the output path for executables.
out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
- } else if (this->GetType() == cmState::STATIC_LIBRARY ||
- this->GetType() == cmState::SHARED_LIBRARY ||
- this->GetType() == cmState::MODULE_LIBRARY) {
+ } else if (this->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::MODULE_LIBRARY) {
// Lookup the output path for libraries.
out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
}
@@ -4324,9 +4419,10 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
// The generator may add the configuration's subdirectory.
if (!conf.empty()) {
- bool iosPlatform = this->Makefile->PlatformIsAppleIos();
+ bool useEPN =
+ this->GlobalGenerator->UseEffectivePlatformName(this->Makefile);
std::string suffix =
- usesDefaultOutputDir && iosPlatform ? "${EFFECTIVE_PLATFORM_NAME}" : "";
+ usesDefaultOutputDir && useEPN ? "${EFFECTIVE_PLATFORM_NAME}" : "";
this->LocalGenerator->GetGlobalGenerator()->AppendDirectoryForConfig(
"/", conf, suffix, out);
}
@@ -4415,7 +4511,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
explicitLibraries = this->GetProperty(linkIfaceProp);
- } else if (this->GetType() == cmState::SHARED_LIBRARY ||
+ } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()) {
// CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a
// shared lib or executable.
@@ -4460,8 +4556,9 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// There is no implicit link interface for executables or modules
// so if none was explicitly set then there is no link interface.
- if (!explicitLibraries && (this->GetType() == cmState::EXECUTABLE ||
- (this->GetType() == cmState::MODULE_LIBRARY))) {
+ if (!explicitLibraries &&
+ (this->GetType() == cmStateEnums::EXECUTABLE ||
+ (this->GetType() == cmStateEnums::MODULE_LIBRARY))) {
return;
}
iface.Exists = true;
@@ -4590,7 +4687,7 @@ cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo(
i = this->ImportInfoMap.insert(entry).first;
}
- if (this->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return &i->second;
}
// If the location is empty then the target is not available for
@@ -4625,7 +4722,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
std::string linkProp = "INTERFACE_LINK_LIBRARIES";
const char* propertyLibs = this->GetProperty(linkProp);
- if (this->GetType() != cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
if (!propertyLibs) {
linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
linkProp += suffix;
@@ -4642,7 +4739,10 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
info.Libraries = propertyLibs;
}
}
- if (this->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (loc) {
+ info.LibName = loc;
+ }
return;
}
@@ -4663,7 +4763,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
}
// Get the soname.
- if (this->GetType() == cmState::SHARED_LIBRARY) {
+ if (this->GetType() == cmStateEnums::SHARED_LIBRARY) {
std::string soProp = "IMPORTED_SONAME";
soProp += suffix;
if (const char* config_soname = this->GetProperty(soProp)) {
@@ -4674,7 +4774,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
}
// Get the "no-soname" mark.
- if (this->GetType() == cmState::SHARED_LIBRARY) {
+ if (this->GetType() == cmStateEnums::SHARED_LIBRARY) {
std::string soProp = "IMPORTED_NO_SONAME";
soProp += suffix;
if (const char* config_no_soname = this->GetProperty(soProp)) {
@@ -4688,7 +4788,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Get the import library.
if (imp) {
info.ImportLibrary = imp;
- } else if (this->GetType() == cmState::SHARED_LIBRARY ||
+ } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()) {
std::string impProp = "IMPORTED_IMPLIB";
impProp += suffix;
@@ -4724,7 +4824,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
}
// Get the cyclic repetition count.
- if (this->GetType() == cmState::STATIC_LIBRARY) {
+ if (this->GetType() == cmStateEnums::STATIC_LIBRARY) {
std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
linkProp += suffix;
if (const char* config_reps = this->GetProperty(linkProp)) {
@@ -4965,6 +5065,9 @@ bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const
if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
return false;
}
+ if (this->GetProperty("BUILD_RPATH")) {
+ return true;
+ }
if (cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config)) {
return !impl->Libraries.empty();
@@ -5117,12 +5220,12 @@ cmGeneratorTarget* cmGeneratorTarget::FindTargetToLink(
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
// within the project.
- if (tgt && tgt->GetType() == cmState::EXECUTABLE &&
+ if (tgt && tgt->GetType() == cmStateEnums::EXECUTABLE &&
!tgt->IsExecutableWithExports()) {
tgt = CM_NULLPTR;
}
- if (tgt && tgt->GetType() == cmState::OBJECT_LIBRARY) {
+ if (tgt && tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
std::ostringstream e;
e << "Target \"" << this->GetName() << "\" links to "
"OBJECT library \""
@@ -5168,14 +5271,14 @@ bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName,
bool cmGeneratorTarget::IsExecutableWithExports() const
{
- return (this->GetType() == cmState::EXECUTABLE &&
+ return (this->GetType() == cmStateEnums::EXECUTABLE &&
this->GetPropertyAsBool("ENABLE_EXPORTS"));
}
bool cmGeneratorTarget::HasImportLibrary() const
{
return (this->IsDLLPlatform() &&
- (this->GetType() == cmState::SHARED_LIBRARY ||
+ (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()));
}
@@ -5195,24 +5298,25 @@ std::string cmGeneratorTarget::GetSupportDirectory() const
bool cmGeneratorTarget::IsLinkable() const
{
- return (this->GetType() == cmState::STATIC_LIBRARY ||
- this->GetType() == cmState::SHARED_LIBRARY ||
- this->GetType() == cmState::MODULE_LIBRARY ||
- this->GetType() == cmState::UNKNOWN_LIBRARY ||
- this->GetType() == cmState::INTERFACE_LIBRARY ||
+ return (this->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::MODULE_LIBRARY ||
+ this->GetType() == cmStateEnums::UNKNOWN_LIBRARY ||
+ this->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
this->IsExecutableWithExports());
}
bool cmGeneratorTarget::IsFrameworkOnApple() const
{
- return (this->GetType() == cmState::SHARED_LIBRARY &&
+ return ((this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::STATIC_LIBRARY) &&
this->Makefile->IsOn("APPLE") &&
this->GetPropertyAsBool("FRAMEWORK"));
}
bool cmGeneratorTarget::IsAppBundleOnApple() const
{
- return (this->GetType() == cmState::EXECUTABLE &&
+ return (this->GetType() == cmStateEnums::EXECUTABLE &&
this->Makefile->IsOn("APPLE") &&
this->GetPropertyAsBool("MACOSX_BUNDLE"));
}
@@ -5224,6 +5328,6 @@ bool cmGeneratorTarget::IsXCTestOnApple() const
bool cmGeneratorTarget::IsCFBundleOnApple() const
{
- return (this->GetType() == cmState::MODULE_LIBRARY &&
+ return (this->GetType() == cmStateEnums::MODULE_LIBRARY &&
this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("BUNDLE"));
}