From c9bd2e941f106c4c23bb2bb2623991251b528aa5 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 14:46:29 +0100 Subject: cmTarget: Rename member `Internal` to `impl` --- Source/cmTarget.cxx | 252 +++++++++++++++++++++++++--------------------------- Source/cmTarget.h | 2 +- 2 files changed, 124 insertions(+), 130 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c6a69be..9e2f88c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -362,9 +362,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (!this->IsImported()) { // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: - CApp(this->Internal->IncludeDirectoriesEntries, + CApp(impl->IncludeDirectoriesEntries, this->Makefile->GetIncludeDirectoriesEntries()); - CApp(this->Internal->IncludeDirectoriesBacktraces, + CApp(impl->IncludeDirectoriesBacktraces, this->Makefile->GetIncludeDirectoriesBacktraces()); { @@ -372,19 +372,18 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); } - CApp(this->Internal->CompileOptionsEntries, + CApp(impl->CompileOptionsEntries, this->Makefile->GetCompileOptionsEntries()); - CApp(this->Internal->CompileOptionsBacktraces, + CApp(impl->CompileOptionsBacktraces, this->Makefile->GetCompileOptionsBacktraces()); - CApp(this->Internal->LinkOptionsEntries, - this->Makefile->GetLinkOptionsEntries()); - CApp(this->Internal->LinkOptionsBacktraces, + CApp(impl->LinkOptionsEntries, this->Makefile->GetLinkOptionsEntries()); + CApp(impl->LinkOptionsBacktraces, this->Makefile->GetLinkOptionsBacktraces()); - CApp(this->Internal->LinkDirectoriesEntries, + CApp(impl->LinkDirectoriesEntries, this->Makefile->GetLinkDirectoriesEntries()); - CApp(this->Internal->LinkDirectoriesBacktraces, + CApp(impl->LinkDirectoriesBacktraces, this->Makefile->GetLinkDirectoriesBacktraces()); } @@ -510,8 +509,8 @@ void cmTarget::AddTracedSources(std::vector const& srcs) { if (!srcs.empty()) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(cmJoin(srcs, ";")); - this->Internal->SourceBacktraces.push_back(lfbt); + impl->SourceEntries.push_back(cmJoin(srcs, ";")); + impl->SourceBacktraces.push_back(lfbt); } } @@ -535,8 +534,8 @@ void cmTarget::AddSources(std::vector const& srcs) } if (!srcFiles.empty()) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(std::move(srcFiles)); - this->Internal->SourceBacktraces.push_back(lfbt); + impl->SourceEntries.push_back(std::move(srcFiles)); + impl->SourceBacktraces.push_back(lfbt); } } @@ -645,19 +644,15 @@ cmSourceFile* cmTarget::AddSource(const std::string& src, bool before) { cmSourceFileLocation sfl(this->Makefile, src, cmSourceFileLocationKind::Known); - if (std::find_if(this->Internal->SourceEntries.begin(), - this->Internal->SourceEntries.end(), + if (std::find_if(impl->SourceEntries.begin(), impl->SourceEntries.end(), TargetPropertyEntryFinder(sfl)) == - this->Internal->SourceEntries.end()) { + impl->SourceEntries.end()) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.insert( - before ? this->Internal->SourceEntries.begin() - : this->Internal->SourceEntries.end(), - src); - this->Internal->SourceBacktraces.insert( - before ? this->Internal->SourceBacktraces.begin() - : this->Internal->SourceBacktraces.end(), - lfbt); + impl->SourceEntries.insert( + before ? impl->SourceEntries.begin() : impl->SourceEntries.end(), src); + impl->SourceBacktraces.insert(before ? impl->SourceBacktraces.begin() + : impl->SourceBacktraces.end(), + lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { return nullptr; @@ -814,82 +809,82 @@ void cmTarget::AddSystemIncludeDirectories(const std::set& incs) cmStringRange cmTarget::GetIncludeDirectoriesEntries() const { - return cmMakeRange(this->Internal->IncludeDirectoriesEntries); + return cmMakeRange(impl->IncludeDirectoriesEntries); } cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const { - return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); + return cmMakeRange(impl->IncludeDirectoriesBacktraces); } cmStringRange cmTarget::GetCompileOptionsEntries() const { - return cmMakeRange(this->Internal->CompileOptionsEntries); + return cmMakeRange(impl->CompileOptionsEntries); } cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const { - return cmMakeRange(this->Internal->CompileOptionsBacktraces); + return cmMakeRange(impl->CompileOptionsBacktraces); } cmStringRange cmTarget::GetCompileFeaturesEntries() const { - return cmMakeRange(this->Internal->CompileFeaturesEntries); + return cmMakeRange(impl->CompileFeaturesEntries); } cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const { - return cmMakeRange(this->Internal->CompileFeaturesBacktraces); + return cmMakeRange(impl->CompileFeaturesBacktraces); } cmStringRange cmTarget::GetCompileDefinitionsEntries() const { - return cmMakeRange(this->Internal->CompileDefinitionsEntries); + return cmMakeRange(impl->CompileDefinitionsEntries); } cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const { - return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); + return cmMakeRange(impl->CompileDefinitionsBacktraces); } cmStringRange cmTarget::GetSourceEntries() const { - return cmMakeRange(this->Internal->SourceEntries); + return cmMakeRange(impl->SourceEntries); } cmBacktraceRange cmTarget::GetSourceBacktraces() const { - return cmMakeRange(this->Internal->SourceBacktraces); + return cmMakeRange(impl->SourceBacktraces); } cmStringRange cmTarget::GetLinkOptionsEntries() const { - return cmMakeRange(this->Internal->LinkOptionsEntries); + return cmMakeRange(impl->LinkOptionsEntries); } cmBacktraceRange cmTarget::GetLinkOptionsBacktraces() const { - return cmMakeRange(this->Internal->LinkOptionsBacktraces); + return cmMakeRange(impl->LinkOptionsBacktraces); } cmStringRange cmTarget::GetLinkDirectoriesEntries() const { - return cmMakeRange(this->Internal->LinkDirectoriesEntries); + return cmMakeRange(impl->LinkDirectoriesEntries); } cmBacktraceRange cmTarget::GetLinkDirectoriesBacktraces() const { - return cmMakeRange(this->Internal->LinkDirectoriesBacktraces); + return cmMakeRange(impl->LinkDirectoriesBacktraces); } cmStringRange cmTarget::GetLinkImplementationEntries() const { - return cmMakeRange(this->Internal->LinkImplementationPropertyEntries); + return cmMakeRange(impl->LinkImplementationPropertyEntries); } cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const { - return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces); + return cmMakeRange(impl->LinkImplementationPropertyBacktraces); } void cmTarget::SetProperty(const std::string& prop, const char* value) @@ -956,68 +951,68 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } if (prop == propINCLUDE_DIRECTORIES) { - this->Internal->IncludeDirectoriesEntries.clear(); - this->Internal->IncludeDirectoriesBacktraces.clear(); + impl->IncludeDirectoriesEntries.clear(); + impl->IncludeDirectoriesBacktraces.clear(); if (value) { - this->Internal->IncludeDirectoriesEntries.emplace_back(value); + impl->IncludeDirectoriesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); + impl->IncludeDirectoriesBacktraces.push_back(lfbt); } } else if (prop == propCOMPILE_OPTIONS) { - this->Internal->CompileOptionsEntries.clear(); - this->Internal->CompileOptionsBacktraces.clear(); + impl->CompileOptionsEntries.clear(); + impl->CompileOptionsBacktraces.clear(); if (value) { - this->Internal->CompileOptionsEntries.emplace_back(value); + impl->CompileOptionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileOptionsBacktraces.push_back(lfbt); + impl->CompileOptionsBacktraces.push_back(lfbt); } } else if (prop == propCOMPILE_FEATURES) { - this->Internal->CompileFeaturesEntries.clear(); - this->Internal->CompileFeaturesBacktraces.clear(); + impl->CompileFeaturesEntries.clear(); + impl->CompileFeaturesBacktraces.clear(); if (value) { - this->Internal->CompileFeaturesEntries.emplace_back(value); + impl->CompileFeaturesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileFeaturesBacktraces.push_back(lfbt); + impl->CompileFeaturesBacktraces.push_back(lfbt); } } else if (prop == propCOMPILE_DEFINITIONS) { - this->Internal->CompileDefinitionsEntries.clear(); - this->Internal->CompileDefinitionsBacktraces.clear(); + impl->CompileDefinitionsEntries.clear(); + impl->CompileDefinitionsBacktraces.clear(); if (value) { - this->Internal->CompileDefinitionsEntries.emplace_back(value); + impl->CompileDefinitionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); + impl->CompileDefinitionsBacktraces.push_back(lfbt); } } else if (prop == propLINK_OPTIONS) { - this->Internal->LinkOptionsEntries.clear(); - this->Internal->LinkOptionsBacktraces.clear(); + impl->LinkOptionsEntries.clear(); + impl->LinkOptionsBacktraces.clear(); if (value) { - this->Internal->LinkOptionsEntries.emplace_back(value); + impl->LinkOptionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkOptionsBacktraces.push_back(lfbt); + impl->LinkOptionsBacktraces.push_back(lfbt); } } else if (prop == propLINK_DIRECTORIES) { - this->Internal->LinkDirectoriesEntries.clear(); - this->Internal->LinkDirectoriesBacktraces.clear(); + impl->LinkDirectoriesEntries.clear(); + impl->LinkDirectoriesBacktraces.clear(); if (value) { - this->Internal->LinkDirectoriesEntries.emplace_back(value); + impl->LinkDirectoriesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkDirectoriesBacktraces.push_back(lfbt); + impl->LinkDirectoriesBacktraces.push_back(lfbt); } } else if (prop == propLINK_LIBRARIES) { - this->Internal->LinkImplementationPropertyEntries.clear(); - this->Internal->LinkImplementationPropertyBacktraces.clear(); + impl->LinkImplementationPropertyEntries.clear(); + impl->LinkImplementationPropertyBacktraces.clear(); if (value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkImplementationPropertyEntries.emplace_back(value); - this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt); + impl->LinkImplementationPropertyEntries.emplace_back(value); + impl->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == propSOURCES) { - this->Internal->SourceEntries.clear(); - this->Internal->SourceBacktraces.clear(); + impl->SourceEntries.clear(); + impl->SourceBacktraces.clear(); if (value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.emplace_back(value); - this->Internal->SourceBacktraces.push_back(lfbt); + impl->SourceEntries.emplace_back(value); + impl->SourceBacktraces.push_back(lfbt); } } else if (prop == propIMPORTED_GLOBAL) { if (!cmSystemTools::IsOn(value)) { @@ -1086,50 +1081,50 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } if (prop == "INCLUDE_DIRECTORIES") { if (value && *value) { - this->Internal->IncludeDirectoriesEntries.emplace_back(value); + impl->IncludeDirectoriesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); + impl->IncludeDirectoriesBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_OPTIONS") { if (value && *value) { - this->Internal->CompileOptionsEntries.emplace_back(value); + impl->CompileOptionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileOptionsBacktraces.push_back(lfbt); + impl->CompileOptionsBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_FEATURES") { if (value && *value) { - this->Internal->CompileFeaturesEntries.emplace_back(value); + impl->CompileFeaturesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileFeaturesBacktraces.push_back(lfbt); + impl->CompileFeaturesBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_DEFINITIONS") { if (value && *value) { - this->Internal->CompileDefinitionsEntries.emplace_back(value); + impl->CompileDefinitionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); + impl->CompileDefinitionsBacktraces.push_back(lfbt); } } else if (prop == "LINK_OPTIONS") { if (value && *value) { - this->Internal->LinkOptionsEntries.emplace_back(value); + impl->LinkOptionsEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkOptionsBacktraces.push_back(lfbt); + impl->LinkOptionsBacktraces.push_back(lfbt); } } else if (prop == "LINK_DIRECTORIES") { if (value && *value) { - this->Internal->LinkDirectoriesEntries.emplace_back(value); + impl->LinkDirectoriesEntries.emplace_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkDirectoriesBacktraces.push_back(lfbt); + impl->LinkDirectoriesBacktraces.push_back(lfbt); } } else if (prop == "LINK_LIBRARIES") { if (value && *value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkImplementationPropertyEntries.emplace_back(value); - this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt); + impl->LinkImplementationPropertyEntries.emplace_back(value); + impl->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == "SOURCES") { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.emplace_back(value); - this->Internal->SourceBacktraces.push_back(lfbt); + impl->SourceEntries.emplace_back(value); + impl->SourceBacktraces.push_back(lfbt); } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME")) { this->Makefile->IssueMessage(MessageType::FATAL_ERROR, prop + " property may not be APPENDed."); @@ -1169,67 +1164,66 @@ void cmTarget::InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before) { std::vector::iterator position = before - ? this->Internal->IncludeDirectoriesEntries.begin() - : this->Internal->IncludeDirectoriesEntries.end(); + ? impl->IncludeDirectoriesEntries.begin() + : impl->IncludeDirectoriesEntries.end(); std::vector::iterator btPosition = before - ? this->Internal->IncludeDirectoriesBacktraces.begin() - : this->Internal->IncludeDirectoriesBacktraces.end(); + ? impl->IncludeDirectoriesBacktraces.begin() + : impl->IncludeDirectoriesBacktraces.end(); - this->Internal->IncludeDirectoriesEntries.insert(position, entry); - this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt); + impl->IncludeDirectoriesEntries.insert(position, entry); + impl->IncludeDirectoriesBacktraces.insert(btPosition, bt); } void cmTarget::InsertCompileOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { std::vector::iterator position = before - ? this->Internal->CompileOptionsEntries.begin() - : this->Internal->CompileOptionsEntries.end(); + ? impl->CompileOptionsEntries.begin() + : impl->CompileOptionsEntries.end(); std::vector::iterator btPosition = before - ? this->Internal->CompileOptionsBacktraces.begin() - : this->Internal->CompileOptionsBacktraces.end(); + ? impl->CompileOptionsBacktraces.begin() + : impl->CompileOptionsBacktraces.end(); - this->Internal->CompileOptionsEntries.insert(position, entry); - this->Internal->CompileOptionsBacktraces.insert(btPosition, bt); + impl->CompileOptionsEntries.insert(position, entry); + impl->CompileOptionsBacktraces.insert(btPosition, bt); } void cmTarget::InsertCompileDefinition(std::string const& entry, cmListFileBacktrace const& bt) { - this->Internal->CompileDefinitionsEntries.push_back(entry); - this->Internal->CompileDefinitionsBacktraces.push_back(bt); + impl->CompileDefinitionsEntries.push_back(entry); + impl->CompileDefinitionsBacktraces.push_back(bt); } void cmTarget::InsertLinkOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - std::vector::iterator position = before - ? this->Internal->LinkOptionsEntries.begin() - : this->Internal->LinkOptionsEntries.end(); + std::vector::iterator position = + before ? impl->LinkOptionsEntries.begin() : impl->LinkOptionsEntries.end(); std::vector::iterator btPosition = before - ? this->Internal->LinkOptionsBacktraces.begin() - : this->Internal->LinkOptionsBacktraces.end(); + ? impl->LinkOptionsBacktraces.begin() + : impl->LinkOptionsBacktraces.end(); - this->Internal->LinkOptionsEntries.insert(position, entry); - this->Internal->LinkOptionsBacktraces.insert(btPosition, bt); + impl->LinkOptionsEntries.insert(position, entry); + impl->LinkOptionsBacktraces.insert(btPosition, bt); } void cmTarget::InsertLinkDirectory(std::string const& entry, cmListFileBacktrace const& bt, bool before) { std::vector::iterator position = before - ? this->Internal->LinkDirectoriesEntries.begin() - : this->Internal->LinkDirectoriesEntries.end(); + ? impl->LinkDirectoriesEntries.begin() + : impl->LinkDirectoriesEntries.end(); std::vector::iterator btPosition = before - ? this->Internal->LinkDirectoriesBacktraces.begin() - : this->Internal->LinkDirectoriesBacktraces.end(); + ? impl->LinkDirectoriesBacktraces.begin() + : impl->LinkDirectoriesBacktraces.end(); - this->Internal->LinkDirectoriesEntries.insert(position, entry); - this->Internal->LinkDirectoriesBacktraces.insert(btPosition, bt); + impl->LinkDirectoriesEntries.insert(position, entry); + impl->LinkDirectoriesBacktraces.insert(btPosition, bt); } static void cmTargetCheckLINK_INTERFACE_LIBRARIES(const std::string& prop, @@ -1380,12 +1374,12 @@ const char* cmTarget::GetProperty(const std::string& prop) const } if (specialProps.count(prop)) { if (prop == propLINK_LIBRARIES) { - if (this->Internal->LinkImplementationPropertyEntries.empty()) { + if (impl->LinkImplementationPropertyEntries.empty()) { return nullptr; } static std::string output; - output = cmJoin(this->Internal->LinkImplementationPropertyEntries, ";"); + output = cmJoin(impl->LinkImplementationPropertyEntries, ";"); return output.c_str(); } // the type property returns what type the target is @@ -1393,57 +1387,57 @@ const char* cmTarget::GetProperty(const std::string& prop) const return cmState::GetTargetTypeName(this->GetType()); } if (prop == propINCLUDE_DIRECTORIES) { - if (this->Internal->IncludeDirectoriesEntries.empty()) { + if (impl->IncludeDirectoriesEntries.empty()) { return nullptr; } static std::string output; - output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";"); + output = cmJoin(impl->IncludeDirectoriesEntries, ";"); return output.c_str(); } if (prop == propCOMPILE_FEATURES) { - if (this->Internal->CompileFeaturesEntries.empty()) { + if (impl->CompileFeaturesEntries.empty()) { return nullptr; } static std::string output; - output = cmJoin(this->Internal->CompileFeaturesEntries, ";"); + output = cmJoin(impl->CompileFeaturesEntries, ";"); return output.c_str(); } if (prop == propCOMPILE_OPTIONS) { - if (this->Internal->CompileOptionsEntries.empty()) { + if (impl->CompileOptionsEntries.empty()) { return nullptr; } static std::string output; - output = cmJoin(this->Internal->CompileOptionsEntries, ";"); + output = cmJoin(impl->CompileOptionsEntries, ";"); return output.c_str(); } if (prop == propCOMPILE_DEFINITIONS) { - if (this->Internal->CompileDefinitionsEntries.empty()) { + if (impl->CompileDefinitionsEntries.empty()) { return nullptr; } static std::string output; - output = cmJoin(this->Internal->CompileDefinitionsEntries, ";"); + output = cmJoin(impl->CompileDefinitionsEntries, ";"); return output.c_str(); } if (prop == propLINK_OPTIONS) { - if (this->Internal->LinkOptionsEntries.empty()) { + if (impl->LinkOptionsEntries.empty()) { return nullptr; } static std::string output; - output = cmJoin(this->Internal->LinkOptionsEntries, ";"); + output = cmJoin(impl->LinkOptionsEntries, ";"); return output.c_str(); } if (prop == propLINK_DIRECTORIES) { - if (this->Internal->LinkDirectoriesEntries.empty()) { + if (impl->LinkDirectoriesEntries.empty()) { return nullptr; } static std::string output; - output = cmJoin(this->Internal->LinkDirectoriesEntries, ";"); + output = cmJoin(impl->LinkDirectoriesEntries, ";"); return output.c_str(); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 24b3742..0701661 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -319,7 +319,7 @@ private: std::vector> TLLCommands; LinkLibraryVectorType OriginalLinkLibraries; cmMakefile* Makefile; - cmTargetInternalPointer Internal; + cmTargetInternalPointer impl; cmStateEnums::TargetType TargetTypeValue; bool HaveInstallRule; bool DLLPlatform; -- cgit v0.12 From fa8e2dfc7b10066b2ba575c20ea96d802109e6c3 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 14:57:09 +0100 Subject: cmTarget: Move member `TargetType` to impl --- Source/cmTarget.cxx | 32 +++++++++++++++++++------------- Source/cmTarget.h | 7 ++----- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9e2f88c..14f860f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -164,6 +164,7 @@ const char* cmTargetPropertyComputer::GetSources( class cmTargetInternals { public: + cmStateEnums::TargetType TargetType; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; @@ -186,9 +187,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, Visibility vis, cmMakefile* mf) { assert(mf); + impl->TargetType = type; this->IsGeneratorProvided = false; this->Name = name; - this->TargetTypeValue = type; this->Makefile = mf; this->HaveInstallRule = false; this->DLLPlatform = false; @@ -333,7 +334,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, for (auto const& prop : configProps) { // Interface libraries have no output locations, so honor only // the configuration map. - if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY && + if (impl->TargetType == cmStateEnums::INTERFACE_LIBRARY && strcmp(prop, "MAP_IMPORTED_CONFIG_") != 0) { continue; } @@ -347,8 +348,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, // compatibility with previous CMake versions in which executables // did not support this variable. Projects may still specify the // property directly. - if (this->TargetTypeValue != cmStateEnums::EXECUTABLE && - this->TargetTypeValue != cmStateEnums::INTERFACE_LIBRARY) { + if (impl->TargetType != cmStateEnums::EXECUTABLE && + impl->TargetType != cmStateEnums::INTERFACE_LIBRARY) { std::string property = cmSystemTools::UpperCase(configName); property += "_POSTFIX"; this->SetPropertyDefault(property, nullptr); @@ -395,17 +396,17 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", nullptr); } - if (this->TargetTypeValue == cmStateEnums::EXECUTABLE) { + if (impl->TargetType == cmStateEnums::EXECUTABLE) { this->SetPropertyDefault("ANDROID_GUI", nullptr); this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", nullptr); this->SetPropertyDefault("ENABLE_EXPORTS", nullptr); } - if (this->TargetTypeValue == cmStateEnums::SHARED_LIBRARY || - this->TargetTypeValue == cmStateEnums::MODULE_LIBRARY) { + if (impl->TargetType == cmStateEnums::SHARED_LIBRARY || + impl->TargetType == cmStateEnums::MODULE_LIBRARY) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); } - if (this->TargetTypeValue == cmStateEnums::SHARED_LIBRARY || - this->TargetTypeValue == cmStateEnums::EXECUTABLE) { + if (impl->TargetType == cmStateEnums::SHARED_LIBRARY || + impl->TargetType == cmStateEnums::EXECUTABLE) { this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", nullptr); } @@ -417,7 +418,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, // Record current policies for later use. this->Makefile->RecordPolicies(this->PolicyMap); - if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY) { + if (impl->TargetType == cmStateEnums::INTERFACE_LIBRARY) { // This policy is checked in a few conditions. The properties relevant // to the policy are always ignored for cmStateEnums::INTERFACE_LIBRARY // targets, @@ -431,7 +432,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("JOB_POOL_LINK", nullptr); } - if (this->TargetTypeValue <= cmStateEnums::UTILITY) { + if (impl->TargetType <= cmStateEnums::UTILITY) { this->SetPropertyDefault("DOTNET_TARGET_FRAMEWORK_VERSION", nullptr); } @@ -461,6 +462,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } } +cmStateEnums::TargetType cmTarget::GetType() const +{ + return impl->TargetType; +} + cmGlobalGenerator* cmTarget::GetGlobalGenerator() const { return this->GetMakefile()->GetGlobalGenerator(); @@ -772,8 +778,8 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, // may be purposefully duplicated to handle recursive dependencies, // and we removing one instance will break the link line. Duplicates // will be appropriately eliminated at emit time. - if (this->TargetTypeValue >= cmStateEnums::STATIC_LIBRARY && - this->TargetTypeValue <= cmStateEnums::MODULE_LIBRARY && + if (impl->TargetType >= cmStateEnums::STATIC_LIBRARY && + impl->TargetType <= cmStateEnums::MODULE_LIBRARY && (this->GetPolicyStatusCMP0073() == cmPolicies::OLD || this->GetPolicyStatusCMP0073() == cmPolicies::WARN)) { std::string targetEntry = this->Name; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0701661..d18acef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -66,10 +66,8 @@ public: POST_BUILD }; - /** - * Return the type of target. - */ - cmStateEnums::TargetType GetType() const { return this->TargetTypeValue; } + ///! Return the type of target. + cmStateEnums::TargetType GetType() const; cmGlobalGenerator* GetGlobalGenerator() const; @@ -320,7 +318,6 @@ private: LinkLibraryVectorType OriginalLinkLibraries; cmMakefile* Makefile; cmTargetInternalPointer impl; - cmStateEnums::TargetType TargetTypeValue; bool HaveInstallRule; bool DLLPlatform; bool IsAndroid; -- cgit v0.12 From 2cd41046007de479f660a7794292105908276345 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 15:03:23 +0100 Subject: cmTarget: Move member `Makefile` to impl --- Source/cmTarget.cxx | 157 ++++++++++++++++++++++++++-------------------------- Source/cmTarget.h | 8 +-- 2 files changed, 84 insertions(+), 81 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 14f860f..74402da 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -165,6 +165,7 @@ class cmTargetInternals { public: cmStateEnums::TargetType TargetType; + cmMakefile* Makefile; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; @@ -188,9 +189,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, { assert(mf); impl->TargetType = type; + impl->Makefile = mf; this->IsGeneratorProvided = false; this->Name = name; - this->Makefile = mf; this->HaveInstallRule = false; this->DLLPlatform = false; this->IsAndroid = false; @@ -201,11 +202,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, // Check whether this is a DLL platform. this->DLLPlatform = - !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); + !impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); // Check whether we are targeting an Android platform. this->IsAndroid = - (this->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android"); + (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android"); // Setup default property values. if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && @@ -358,34 +359,34 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } // Save the backtrace of target construction. - this->Backtrace = this->Makefile->GetBacktrace(); + this->Backtrace = impl->Makefile->GetBacktrace(); if (!this->IsImported()) { // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: CApp(impl->IncludeDirectoriesEntries, - this->Makefile->GetIncludeDirectoriesEntries()); + impl->Makefile->GetIncludeDirectoriesEntries()); CApp(impl->IncludeDirectoriesBacktraces, - this->Makefile->GetIncludeDirectoriesBacktraces()); + impl->Makefile->GetIncludeDirectoriesBacktraces()); { - auto const& sysInc = this->Makefile->GetSystemIncludeDirectories(); + auto const& sysInc = impl->Makefile->GetSystemIncludeDirectories(); this->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); } CApp(impl->CompileOptionsEntries, - this->Makefile->GetCompileOptionsEntries()); + impl->Makefile->GetCompileOptionsEntries()); CApp(impl->CompileOptionsBacktraces, - this->Makefile->GetCompileOptionsBacktraces()); + impl->Makefile->GetCompileOptionsBacktraces()); - CApp(impl->LinkOptionsEntries, this->Makefile->GetLinkOptionsEntries()); + CApp(impl->LinkOptionsEntries, impl->Makefile->GetLinkOptionsEntries()); CApp(impl->LinkOptionsBacktraces, - this->Makefile->GetLinkOptionsBacktraces()); + impl->Makefile->GetLinkOptionsBacktraces()); CApp(impl->LinkDirectoriesEntries, - this->Makefile->GetLinkDirectoriesEntries()); + impl->Makefile->GetLinkDirectoriesEntries()); CApp(impl->LinkDirectoriesBacktraces, - this->Makefile->GetLinkDirectoriesBacktraces()); + impl->Makefile->GetLinkDirectoriesBacktraces()); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && @@ -416,7 +417,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } // Record current policies for later use. - this->Makefile->RecordPolicies(this->PolicyMap); + impl->Makefile->RecordPolicies(this->PolicyMap); if (impl->TargetType == cmStateEnums::INTERFACE_LIBRARY) { // This policy is checked in a few conditions. The properties relevant @@ -467,9 +468,14 @@ cmStateEnums::TargetType cmTarget::GetType() const return impl->TargetType; } +cmMakefile* cmTarget::GetMakefile() const +{ + return impl->Makefile; +} + cmGlobalGenerator* cmTarget::GetGlobalGenerator() const { - return this->GetMakefile()->GetGlobalGenerator(); + return impl->Makefile->GetGlobalGenerator(); } void cmTarget::AddUtility(std::string const& u, cmMakefile* mf) @@ -500,21 +506,21 @@ bool cmTarget::IsFrameworkOnApple() const { return ((this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::STATIC_LIBRARY) && - this->Makefile->IsOn("APPLE") && + impl->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("FRAMEWORK")); } bool cmTarget::IsAppBundleOnApple() const { return (this->GetType() == cmStateEnums::EXECUTABLE && - this->Makefile->IsOn("APPLE") && + impl->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("MACOSX_BUNDLE")); } void cmTarget::AddTracedSources(std::vector const& srcs) { if (!srcs.empty()) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->SourceEntries.push_back(cmJoin(srcs, ";")); impl->SourceBacktraces.push_back(lfbt); } @@ -532,14 +538,14 @@ void cmTarget::AddSources(std::vector const& srcs) return; } } - this->Makefile->GetOrCreateSource(filename); + impl->Makefile->GetOrCreateSource(filename); } srcFiles += sep; srcFiles += filename; sep = ";"; } if (!srcFiles.empty()) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->SourceEntries.push_back(std::move(srcFiles)); impl->SourceBacktraces.push_back(lfbt); } @@ -551,12 +557,12 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) // For backwards compatibility replace variables in source names. // This should eventually be removed. - this->Makefile->ExpandVariablesInString(src); + impl->Makefile->ExpandVariablesInString(src); if (src != s) { std::ostringstream e; bool noMessage = false; MessageType messageType = MessageType::AUTHOR_WARNING; - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) { + switch (impl->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0049) << "\n"; break; @@ -573,7 +579,7 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) << "\" expanded to \"" << src << "\" in target \"" << this->GetName() << "\". This behavior will be removed in a " "future version of CMake."; - this->Makefile->IssueMessage(messageType, e.str()); + impl->Makefile->IssueMessage(messageType, e.str()); if (messageType == MessageType::FATAL_ERROR) { return ""; } @@ -648,12 +654,12 @@ public: cmSourceFile* cmTarget::AddSource(const std::string& src, bool before) { - cmSourceFileLocation sfl(this->Makefile, src, + cmSourceFileLocation sfl(impl->Makefile, src, cmSourceFileLocationKind::Known); if (std::find_if(impl->SourceEntries.begin(), impl->SourceEntries.end(), TargetPropertyEntryFinder(sfl)) == impl->SourceEntries.end()) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->SourceEntries.insert( before ? impl->SourceEntries.begin() : impl->SourceEntries.end(), src); impl->SourceBacktraces.insert(before ? impl->SourceBacktraces.begin() @@ -663,7 +669,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src, bool before) if (cmGeneratorExpression::Find(src) != std::string::npos) { return nullptr; } - return this->Makefile->GetOrCreateSource(src, false, + return impl->Makefile->GetOrCreateSource(src, false, cmSourceFileLocationKind::Known); } @@ -683,7 +689,7 @@ std::string cmTarget::GetDebugGeneratorExpressions( // Get the list of configurations considered to be DEBUG. std::vector debugConfigs = - this->Makefile->GetCMakeInstance()->GetDebugConfigs(); + impl->Makefile->GetCMakeInstance()->GetDebugConfigs(); std::string configString = "$"; @@ -725,13 +731,12 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const const char* sigString = (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); s << "The uses of the " << sigString << " signature are here:\n"; - cmStateDirectory cmDir = - this->GetMakefile()->GetStateSnapshot().GetDirectory(); + cmStateDirectory cmDir = impl->Makefile->GetStateSnapshot().GetDirectory(); for (auto const& cmd : this->TLLCommands) { if (cmd.first == sig) { cmListFileContext lfc = cmd.second; lfc.FilePath = cmDir.ConvertToRelPathIfNotContained( - this->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath); + impl->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath); s << " * " << lfc << std::endl; } } @@ -896,8 +901,8 @@ cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const void cmTarget::SetProperty(const std::string& prop, const char* value) { if (!cmTargetPropertyComputer::PassesWhitelist( - this->GetType(), prop, this->Makefile->GetMessenger(), - this->Makefile->GetBacktrace())) { + this->GetType(), prop, impl->Makefile->GetMessenger(), + impl->Makefile->GetBacktrace())) { return; } #define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP @@ -919,40 +924,40 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) if (prop == propMANUALLY_ADDED_DEPENDENCIES) { std::ostringstream e; e << "MANUALLY_ADDED_DEPENDENCIES property is read-only\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == propNAME) { std::ostringstream e; e << "NAME property is read-only\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == propTYPE) { std::ostringstream e; e << "TYPE property is read-only\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == propEXPORT_NAME && this->IsImported()) { std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == propSOURCES && this->IsImported()) { std::ostringstream e; e << "SOURCES property can't be set on imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == propIMPORTED_GLOBAL && !this->IsImported()) { std::ostringstream e; e << "IMPORTED_GLOBAL property can't be set on non-imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } @@ -961,7 +966,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->IncludeDirectoriesBacktraces.clear(); if (value) { impl->IncludeDirectoriesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->IncludeDirectoriesBacktraces.push_back(lfbt); } } else if (prop == propCOMPILE_OPTIONS) { @@ -969,7 +974,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->CompileOptionsBacktraces.clear(); if (value) { impl->CompileOptionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->CompileOptionsBacktraces.push_back(lfbt); } } else if (prop == propCOMPILE_FEATURES) { @@ -977,7 +982,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->CompileFeaturesBacktraces.clear(); if (value) { impl->CompileFeaturesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->CompileFeaturesBacktraces.push_back(lfbt); } } else if (prop == propCOMPILE_DEFINITIONS) { @@ -985,7 +990,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->CompileDefinitionsBacktraces.clear(); if (value) { impl->CompileDefinitionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->CompileDefinitionsBacktraces.push_back(lfbt); } } else if (prop == propLINK_OPTIONS) { @@ -993,7 +998,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->LinkOptionsBacktraces.clear(); if (value) { impl->LinkOptionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->LinkOptionsBacktraces.push_back(lfbt); } } else if (prop == propLINK_DIRECTORIES) { @@ -1001,14 +1006,14 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->LinkDirectoriesBacktraces.clear(); if (value) { impl->LinkDirectoriesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->LinkDirectoriesBacktraces.push_back(lfbt); } } else if (prop == propLINK_LIBRARIES) { impl->LinkImplementationPropertyEntries.clear(); impl->LinkImplementationPropertyBacktraces.clear(); if (value) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->LinkImplementationPropertyEntries.emplace_back(value); impl->LinkImplementationPropertyBacktraces.push_back(lfbt); } @@ -1016,7 +1021,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->SourceEntries.clear(); impl->SourceBacktraces.clear(); if (value) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->SourceEntries.emplace_back(value); impl->SourceBacktraces.push_back(lfbt); } @@ -1025,7 +1030,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) std::ostringstream e; e << "IMPORTED_GLOBAL property can't be set to FALSE on targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } /* no need to change anything if value does not change */ @@ -1042,7 +1047,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) e << "CUDA_PTX_COMPILATION property can only be applied to OBJECT " "targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } else { this->Properties.SetProperty(prop, value); @@ -1053,28 +1058,28 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, bool asString) { if (!cmTargetPropertyComputer::PassesWhitelist( - this->GetType(), prop, this->Makefile->GetMessenger(), - this->Makefile->GetBacktrace())) { + this->GetType(), prop, impl->Makefile->GetMessenger(), + impl->Makefile->GetBacktrace())) { return; } if (prop == "NAME") { std::ostringstream e; e << "NAME property is read-only\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == "EXPORT_NAME" && this->IsImported()) { std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == "SOURCES" && this->IsImported()) { std::ostringstream e; e << "SOURCES property can't be set on imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == "IMPORTED_GLOBAL") { @@ -1082,57 +1087,57 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, e << "IMPORTED_GLOBAL property can't be appended, only set on imported " "targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == "INCLUDE_DIRECTORIES") { if (value && *value) { impl->IncludeDirectoriesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->IncludeDirectoriesBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_OPTIONS") { if (value && *value) { impl->CompileOptionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->CompileOptionsBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_FEATURES") { if (value && *value) { impl->CompileFeaturesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->CompileFeaturesBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_DEFINITIONS") { if (value && *value) { impl->CompileDefinitionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->CompileDefinitionsBacktraces.push_back(lfbt); } } else if (prop == "LINK_OPTIONS") { if (value && *value) { impl->LinkOptionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->LinkOptionsBacktraces.push_back(lfbt); } } else if (prop == "LINK_DIRECTORIES") { if (value && *value) { impl->LinkDirectoriesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->LinkDirectoriesBacktraces.push_back(lfbt); } } else if (prop == "LINK_LIBRARIES") { if (value && *value) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->LinkImplementationPropertyEntries.emplace_back(value); impl->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == "SOURCES") { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); impl->SourceEntries.emplace_back(value); impl->SourceBacktraces.push_back(lfbt); } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME")) { - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, prop + " property may not be APPENDed."); } else { this->Properties.AppendProperty(prop, value, asString); @@ -1153,12 +1158,12 @@ void cmTarget::AppendBuildInterfaceIncludes() } this->BuildInterfaceIncludesAppended = true; - if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) { - std::string dirs = this->Makefile->GetCurrentBinaryDirectory(); + if (impl->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) { + std::string dirs = impl->Makefile->GetCurrentBinaryDirectory(); if (!dirs.empty()) { dirs += ';'; } - dirs += this->Makefile->GetCurrentSourceDirectory(); + dirs += impl->Makefile->GetCurrentSourceDirectory(); if (!dirs.empty()) { this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", ("$").c_str()); @@ -1466,15 +1471,13 @@ const char* cmTarget::GetProperty(const std::string& prop) const return this->GetName().c_str(); } if (prop == propBINARY_DIR) { - return this->GetMakefile() - ->GetStateSnapshot() + return impl->Makefile->GetStateSnapshot() .GetDirectory() .GetCurrentBinary() .c_str(); } if (prop == propSOURCE_DIR) { - return this->GetMakefile() - ->GetStateSnapshot() + return impl->Makefile->GetStateSnapshot() .GetDirectory() .GetCurrentSource() .c_str(); @@ -1483,10 +1486,10 @@ const char* cmTarget::GetProperty(const std::string& prop) const const char* retVal = this->Properties.GetPropertyValue(prop); if (!retVal) { - const bool chain = this->GetMakefile()->GetState()->IsPropertyChained( - prop, cmProperty::TARGET); + const bool chain = + impl->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TARGET); if (chain) { - return this->Makefile->GetStateSnapshot().GetDirectory().GetProperty( + return impl->Makefile->GetStateSnapshot().GetDirectory().GetProperty( prop, chain); } } @@ -1655,7 +1658,7 @@ void cmTarget::SetPropertyDefault(const std::string& property, std::string var = "CMAKE_"; var += property; - if (const char* value = this->Makefile->GetDefinition(var)) { + if (const char* value = impl->Makefile->GetDefinition(var)) { this->SetProperty(property, value); } else if (default_value) { this->SetProperty(property, default_value); @@ -1667,7 +1670,7 @@ bool cmTarget::CheckImportedLibName(std::string const& prop, { if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY || !this->IsImported()) { - this->Makefile->IssueMessage( + impl->Makefile->IssueMessage( MessageType::FATAL_ERROR, prop + " property may be set only on imported INTERFACE library targets."); @@ -1675,14 +1678,14 @@ bool cmTarget::CheckImportedLibName(std::string const& prop, } if (!value.empty()) { if (value[0] == '-') { - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, prop + " property value\n " + value + "\nmay not start with '-'."); return false; } std::string::size_type bad = value.find_first_of(":/\\;"); if (bad != std::string::npos) { - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, prop + " property value\n " + value + "\nmay not contain '" + value.substr(bad, 1) + "'."); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d18acef..58ab255 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -69,14 +69,15 @@ public: ///! Return the type of target. cmStateEnums::TargetType GetType() const; + ///! Get the cmMakefile that owns this target. + cmMakefile* GetMakefile() const; + + ///! Return the global generator. cmGlobalGenerator* GetGlobalGenerator() const; ///! Set/Get the name of the target const std::string& GetName() const { return this->Name; } - /** Get the cmMakefile that owns this target. */ - cmMakefile* GetMakefile() const { return this->Makefile; } - #define DECLARE_TARGET_POLICY(POLICY) \ cmPolicies::PolicyStatus GetPolicyStatus##POLICY() const \ { \ @@ -316,7 +317,6 @@ private: std::vector PostBuildCommands; std::vector> TLLCommands; LinkLibraryVectorType OriginalLinkLibraries; - cmMakefile* Makefile; cmTargetInternalPointer impl; bool HaveInstallRule; bool DLLPlatform; -- cgit v0.12 From 46075091d55334d04a2f11207cfedee10149b1d3 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 15:23:34 +0100 Subject: cmTarget: Move member `Properties` to impl class --- Source/cmTarget.cxx | 13 ++++++++++--- Source/cmTarget.h | 8 +++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 74402da..ae29a05 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -21,6 +21,7 @@ #include "cmMessageType.h" #include "cmMessenger.h" #include "cmProperty.h" +#include "cmPropertyMap.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" @@ -166,6 +167,7 @@ class cmTargetInternals public: cmStateEnums::TargetType TargetType; cmMakefile* Makefile; + cmPropertyMap Properties; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; @@ -1050,7 +1052,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } else { - this->Properties.SetProperty(prop, value); + impl->Properties.SetProperty(prop, value); } } @@ -1140,7 +1142,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, prop + " property may not be APPENDed."); } else { - this->Properties.AppendProperty(prop, value, asString); + impl->Properties.AppendProperty(prop, value, asString); } } @@ -1484,7 +1486,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const } } - const char* retVal = this->Properties.GetPropertyValue(prop); + const char* retVal = impl->Properties.GetPropertyValue(prop); if (!retVal) { const bool chain = impl->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TARGET); @@ -1510,6 +1512,11 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const return cmSystemTools::IsOn(this->GetProperty(prop)); } +cmPropertyMap const& cmTarget::GetProperties() const +{ + return impl->Properties; +} + const char* cmTarget::GetSuffixVariableInternal( cmStateEnums::ArtifactType artifact) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 58ab255..a1245a8 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -16,13 +16,13 @@ #include "cmCustomCommand.h" #include "cmListFileCache.h" #include "cmPolicies.h" -#include "cmPropertyMap.h" #include "cmStateTypes.h" #include "cmTargetLinkLibraryType.h" class cmGlobalGenerator; class cmMakefile; class cmMessenger; +class cmPropertyMap; class cmSourceFile; class cmTargetInternals; @@ -208,6 +208,8 @@ public: const char* GetComputedProperty(const std::string& prop, cmMessenger* messenger, cmListFileBacktrace const& context) const; + ///! Get all properties + cmPropertyMap const& GetProperties() const; bool IsImported() const { return this->IsImportedTarget; } bool IsImportedGloballyVisible() const @@ -215,9 +217,6 @@ public: return this->ImportedGloballyVisible; } - // Get the properties - cmPropertyMap const& GetProperties() const { return this->Properties; } - bool GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, std::string& suffix) const; @@ -305,7 +304,6 @@ private: private: bool IsGeneratorProvided; - cmPropertyMap Properties; std::set SystemIncludeDirectories; std::set> Utilities; cmPolicies::PolicyMap PolicyMap; -- cgit v0.12 From 856a271fb7023e5ee1a251a9ebe55c91072d9cf6 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 15:41:12 +0100 Subject: cmTarget: Move member `SystemIncludeDirectories` to impl --- Source/cmTarget.cxx | 10 ++++++++-- Source/cmTarget.h | 8 ++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ae29a05..1638c64 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -168,6 +168,7 @@ public: cmStateEnums::TargetType TargetType; cmMakefile* Makefile; cmPropertyMap Properties; + std::set SystemIncludeDirectories; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; @@ -373,7 +374,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, { auto const& sysInc = impl->Makefile->GetSystemIncludeDirectories(); - this->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); + impl->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); } CApp(impl->CompileOptionsEntries, @@ -817,7 +818,12 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, void cmTarget::AddSystemIncludeDirectories(const std::set& incs) { - this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); + impl->SystemIncludeDirectories.insert(incs.begin(), incs.end()); +} + +std::set const& cmTarget::GetSystemIncludeDirectories() const +{ + return impl->SystemIncludeDirectories; } cmStringRange cmTarget::GetIncludeDirectoriesEntries() const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a1245a8..dca3dd4 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -250,11 +250,8 @@ public: std::string GetDebugGeneratorExpressions(const std::string& value, cmTargetLinkLibraryType llt) const; - void AddSystemIncludeDirectories(const std::set& incs); - std::set const& GetSystemIncludeDirectories() const - { - return this->SystemIncludeDirectories; - } + void AddSystemIncludeDirectories(std::set const& incs); + std::set const& GetSystemIncludeDirectories() const; cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const; @@ -304,7 +301,6 @@ private: private: bool IsGeneratorProvided; - std::set SystemIncludeDirectories; std::set> Utilities; cmPolicies::PolicyMap PolicyMap; std::string Name; -- cgit v0.12 From 3c09bf0fa7139be0215224ef85a4c2d3c38227f0 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 15:45:44 +0100 Subject: cmTarget: Move member `Utilities` to impl --- Source/cmTarget.cxx | 16 +++++++++++----- Source/cmTarget.h | 11 ++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1638c64..8244c84 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -168,6 +168,7 @@ public: cmStateEnums::TargetType TargetType; cmMakefile* Makefile; cmPropertyMap Properties; + std::set> Utilities; std::set SystemIncludeDirectories; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; @@ -481,10 +482,15 @@ cmGlobalGenerator* cmTarget::GetGlobalGenerator() const return impl->Makefile->GetGlobalGenerator(); } -void cmTarget::AddUtility(std::string const& u, cmMakefile* mf) +void cmTarget::AddUtility(std::string const& name, cmMakefile* mf) { - BT util(u, mf ? mf->GetBacktrace() : cmListFileBacktrace()); - this->Utilities.insert(util); + impl->Utilities.insert( + BT(name, mf ? mf->GetBacktrace() : cmListFileBacktrace())); +} + +std::set> const& cmTarget::GetUtilities() const +{ + return impl->Utilities; } cmListFileBacktrace const& cmTarget::GetBacktrace() const @@ -1461,12 +1467,12 @@ const char* cmTarget::GetProperty(const std::string& prop) const return output.c_str(); } if (prop == propMANUALLY_ADDED_DEPENDENCIES) { - if (this->Utilities.empty()) { + if (impl->Utilities.empty()) { return nullptr; } static std::string output; - output = cmJoin(this->Utilities, ";"); + output = cmJoin(impl->Utilities, ";"); return output.c_str(); } if (prop == propIMPORTED) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dca3dd4..f552d23 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -184,16 +184,14 @@ public: bool GetIsGeneratorProvided() const { return this->IsGeneratorProvided; } void SetIsGeneratorProvided(bool igp) { this->IsGeneratorProvided = igp; } - /** Add a utility on which this project depends. A utility is an executable + /** + * Add a utility on which this project depends. A utility is an executable * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE * commands. It is not a full path nor does it have an extension. */ - void AddUtility(std::string const& u, cmMakefile* mf = nullptr); + void AddUtility(std::string const& name, cmMakefile* mf = nullptr); ///! Get the utilities used by this target - std::set> const& GetUtilities() const - { - return this->Utilities; - } + std::set> const& GetUtilities() const; ///! Set/Get a property of this target file void SetProperty(const std::string& prop, const char* value); @@ -301,7 +299,6 @@ private: private: bool IsGeneratorProvided; - std::set> Utilities; cmPolicies::PolicyMap PolicyMap; std::string Name; std::string InstallPath; -- cgit v0.12 From f6241db3e0b69fbf99835b955b17be0f253a742f Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 15:53:29 +0100 Subject: cmTarget: Move member `OriginalLinkLibraries` to impl --- Source/cmGeneratorTarget.cxx | 2 +- Source/cmTarget.cxx | 9 ++++++++- Source/cmTarget.h | 17 ++++------------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5916fcc..23b5bcb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -262,7 +262,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->DLLPlatform = !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); - this->PolicyMap = t->PolicyMap; + this->PolicyMap = t->GetPolicyMap(); } cmGeneratorTarget::~cmGeneratorTarget() diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8244c84..596fd15 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,6 +170,7 @@ public: cmPropertyMap Properties; std::set> Utilities; std::set SystemIncludeDirectories; + cmTarget::LinkLibraryVectorType OriginalLinkLibraries; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; @@ -751,6 +752,12 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const } } +cmTarget::LinkLibraryVectorType const& cmTarget::GetOriginalLinkLibraries() + const +{ + return impl->OriginalLinkLibraries; +} + void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib, cmTargetLinkLibraryType llt) { @@ -782,7 +789,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, return; } - this->OriginalLinkLibraries.emplace_back(lib, llt); + impl->OriginalLinkLibraries.emplace_back(lib, llt); // Add the explicit dependency information for libraries. This is // simply a set of libraries separated by ";". There should always diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f552d23..33439fa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -116,26 +116,18 @@ public: this->PostBuildCommands.push_back(cmd); } - /** - * Add sources to the target. - */ + ///! Add sources to the target. void AddSources(std::vector const& srcs); void AddTracedSources(std::vector const& srcs); cmSourceFile* AddSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src, bool before = false); - //* how we identify a library, by name and type + ///! how we identify a library, by name and type typedef std::pair LibraryID; - typedef std::vector LinkLibraryVectorType; - const LinkLibraryVectorType& GetOriginalLinkLibraries() const - { - return this->OriginalLinkLibraries; - } + LinkLibraryVectorType const& GetOriginalLinkLibraries() const; - /** - * Clear the dependency information recorded for this target, if any. - */ + ///! Clear the dependency information recorded for this target, if any. void ClearDependencyInformation(cmMakefile& mf); void AddLinkLibrary(cmMakefile& mf, const std::string& lib, @@ -307,7 +299,6 @@ private: std::vector PreLinkCommands; std::vector PostBuildCommands; std::vector> TLLCommands; - LinkLibraryVectorType OriginalLinkLibraries; cmTargetInternalPointer impl; bool HaveInstallRule; bool DLLPlatform; -- cgit v0.12 From 2c14eb4852924e5423d58785e2cb3bcd72af7710 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 16:03:55 +0100 Subject: cmTarget: Move member `PolicyMap` to impl --- Source/cmTarget.cxx | 16 ++++++++++++++-- Source/cmTarget.h | 9 +++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 596fd15..be03e56 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -167,6 +167,7 @@ class cmTargetInternals public: cmStateEnums::TargetType TargetType; cmMakefile* Makefile; + cmPolicies::PolicyMap PolicyMap; cmPropertyMap Properties; std::set> Utilities; std::set SystemIncludeDirectories; @@ -422,14 +423,14 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } // Record current policies for later use. - impl->Makefile->RecordPolicies(this->PolicyMap); + impl->Makefile->RecordPolicies(impl->PolicyMap); if (impl->TargetType == cmStateEnums::INTERFACE_LIBRARY) { // This policy is checked in a few conditions. The properties relevant // to the policy are always ignored for cmStateEnums::INTERFACE_LIBRARY // targets, // so ensure that the conditions don't lead to nonsense. - this->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW); + impl->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && @@ -478,6 +479,17 @@ cmMakefile* cmTarget::GetMakefile() const return impl->Makefile; } +cmPolicies::PolicyMap const& cmTarget::GetPolicyMap() const +{ + return impl->PolicyMap; +} + +cmPolicies::PolicyStatus cmTarget::GetPolicyStatus( + cmPolicies::PolicyID policy) const +{ + return impl->PolicyMap.Get(policy); +} + cmGlobalGenerator* cmTarget::GetGlobalGenerator() const { return impl->Makefile->GetGlobalGenerator(); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 33439fa..ca9a31d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,10 +78,16 @@ public: ///! Set/Get the name of the target const std::string& GetName() const { return this->Name; } + ///! Get the policy map + cmPolicies::PolicyMap const& GetPolicyMap() const; + + ///! Get policy status + cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID policy) const; + #define DECLARE_TARGET_POLICY(POLICY) \ cmPolicies::PolicyStatus GetPolicyStatus##POLICY() const \ { \ - return this->PolicyMap.Get(cmPolicies::POLICY); \ + return this->GetPolicyStatus(cmPolicies::POLICY); \ } CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY) @@ -291,7 +297,6 @@ private: private: bool IsGeneratorProvided; - cmPolicies::PolicyMap PolicyMap; std::string Name; std::string InstallPath; std::string RuntimeInstallPath; -- cgit v0.12 From 7742bf4ff5180f85bc4401745e11ce6e031f32e7 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 16:17:03 +0100 Subject: cmTarget: Move member `Backtrace` to impl --- Source/cmTarget.cxx | 5 +++-- Source/cmTarget.h | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index be03e56..d3b2e1d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -188,6 +188,7 @@ public: std::vector LinkDirectoriesBacktraces; std::vector LinkImplementationPropertyEntries; std::vector LinkImplementationPropertyBacktraces; + cmListFileBacktrace Backtrace; }; cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, @@ -365,7 +366,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } // Save the backtrace of target construction. - this->Backtrace = impl->Makefile->GetBacktrace(); + impl->Backtrace = impl->Makefile->GetBacktrace(); if (!this->IsImported()) { // Initialize the INCLUDE_DIRECTORIES property based on the current value @@ -508,7 +509,7 @@ std::set> const& cmTarget::GetUtilities() const cmListFileBacktrace const& cmTarget::GetBacktrace() const { - return this->Backtrace; + return impl->Backtrace; } bool cmTarget::IsExecutableWithExports() const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index ca9a31d..8b51c93 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -321,8 +321,6 @@ private: friend class cmTargetInternals; friend class cmGeneratorTarget; friend class cmTargetTraceDependencies; - - cmListFileBacktrace Backtrace; }; typedef std::unordered_map cmTargets; -- cgit v0.12 From ccf76c6e4cfd9fc7b04db099f7e165cda2336096 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 16:18:41 +0100 Subject: cmTarget: Move member `TLLCommands` to impl --- Source/cmTarget.cxx | 12 +++++++----- Source/cmTarget.h | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d3b2e1d..6dd7887 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -188,6 +188,8 @@ public: std::vector LinkDirectoriesBacktraces; std::vector LinkImplementationPropertyEntries; std::vector LinkImplementationPropertyBacktraces; + std::vector> + TLLCommands; cmListFileBacktrace Backtrace; }; @@ -738,13 +740,13 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature, cmListFileContext const& lfc) { bool ret = true; - if (!this->TLLCommands.empty()) { - if (this->TLLCommands.back().first != signature) { + if (!impl->TLLCommands.empty()) { + if (impl->TLLCommands.back().first != signature) { ret = false; } } - if (this->TLLCommands.empty() || this->TLLCommands.back().second != lfc) { - this->TLLCommands.emplace_back(signature, lfc); + if (impl->TLLCommands.empty() || impl->TLLCommands.back().second != lfc) { + impl->TLLCommands.emplace_back(signature, lfc); } return ret; } @@ -755,7 +757,7 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); s << "The uses of the " << sigString << " signature are here:\n"; cmStateDirectory cmDir = impl->Makefile->GetStateSnapshot().GetDirectory(); - for (auto const& cmd : this->TLLCommands) { + for (auto const& cmd : impl->TLLCommands) { if (cmd.first == sig) { cmListFileContext lfc = cmd.second; lfc.FilePath = cmDir.ConvertToRelPathIfNotContained( diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8b51c93..860a18e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -303,7 +303,6 @@ private: std::vector PreBuildCommands; std::vector PreLinkCommands; std::vector PostBuildCommands; - std::vector> TLLCommands; cmTargetInternalPointer impl; bool HaveInstallRule; bool DLLPlatform; -- cgit v0.12 From 5db17e9d8107629c1dabd0c1e2bf26429e5d841d Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 16:30:27 +0100 Subject: cmTarget: Move member `Name` to impl --- Source/cmTarget.cxx | 28 +++++++++++++++++----------- Source/cmTarget.h | 3 +-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6dd7887..ebf5e6d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -168,6 +168,7 @@ public: cmStateEnums::TargetType TargetType; cmMakefile* Makefile; cmPolicies::PolicyMap PolicyMap; + std::string Name; cmPropertyMap Properties; std::set> Utilities; std::set SystemIncludeDirectories; @@ -199,8 +200,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, assert(mf); impl->TargetType = type; impl->Makefile = mf; + impl->Name = name; this->IsGeneratorProvided = false; - this->Name = name; this->HaveInstallRule = false; this->DLLPlatform = false; this->IsAndroid = false; @@ -487,6 +488,11 @@ cmPolicies::PolicyMap const& cmTarget::GetPolicyMap() const return impl->PolicyMap; } +const std::string& cmTarget::GetName() const +{ + return impl->Name; +} + cmPolicies::PolicyStatus cmTarget::GetPolicyStatus( cmPolicies::PolicyID policy) const { @@ -800,7 +806,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, (tgt && (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY || tgt->GetType() == cmStateEnums::OBJECT_LIBRARY)) || - (this->Name == lib)) { + (impl->Name == lib)) { return; } @@ -818,7 +824,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, impl->TargetType <= cmStateEnums::MODULE_LIBRARY && (this->GetPolicyStatusCMP0073() == cmPolicies::OLD || this->GetPolicyStatusCMP0073() == cmPolicies::WARN)) { - std::string targetEntry = this->Name; + std::string targetEntry = impl->Name; targetEntry += "_LIB_DEPENDS"; std::string dependencies; const char* old_val = mf.GetDefinition(targetEntry); @@ -978,13 +984,13 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) if (prop == propEXPORT_NAME && this->IsImported()) { std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" - << this->Name << "\")\n"; + << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == propSOURCES && this->IsImported()) { std::ostringstream e; - e << "SOURCES property can't be set on imported targets (\"" << this->Name + e << "SOURCES property can't be set on imported targets (\"" << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; @@ -992,7 +998,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) if (prop == propIMPORTED_GLOBAL && !this->IsImported()) { std::ostringstream e; e << "IMPORTED_GLOBAL property can't be set on non-imported targets (\"" - << this->Name << "\")\n"; + << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } @@ -1065,7 +1071,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) if (!cmSystemTools::IsOn(value)) { std::ostringstream e; e << "IMPORTED_GLOBAL property can't be set to FALSE on targets (\"" - << this->Name << "\")\n"; + << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } @@ -1082,7 +1088,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) std::ostringstream e; e << "CUDA_PTX_COMPILATION property can only be applied to OBJECT " "targets (\"" - << this->Name << "\")\n"; + << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } else { @@ -1107,13 +1113,13 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, if (prop == "EXPORT_NAME" && this->IsImported()) { std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" - << this->Name << "\")\n"; + << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == "SOURCES" && this->IsImported()) { std::ostringstream e; - e << "SOURCES property can't be set on imported targets (\"" << this->Name + e << "SOURCES property can't be set on imported targets (\"" << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; @@ -1122,7 +1128,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, std::ostringstream e; e << "IMPORTED_GLOBAL property can't be appended, only set on imported " "targets (\"" - << this->Name << "\")\n"; + << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 860a18e..f9dd83e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -76,7 +76,7 @@ public: cmGlobalGenerator* GetGlobalGenerator() const; ///! Set/Get the name of the target - const std::string& GetName() const { return this->Name; } + const std::string& GetName() const; ///! Get the policy map cmPolicies::PolicyMap const& GetPolicyMap() const; @@ -297,7 +297,6 @@ private: private: bool IsGeneratorProvided; - std::string Name; std::string InstallPath; std::string RuntimeInstallPath; std::vector PreBuildCommands; -- cgit v0.12 From 0dcef68cd8961f8b3d89edbf46093949778daac8 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 16:42:11 +0100 Subject: cmTarget: Move member `InstallPath` to impl --- Source/cmInstallTargetsCommand.cxx | 2 +- Source/cmTarget.cxx | 11 +++++++++++ Source/cmTarget.h | 5 ++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index d721ca0..8f417db 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -40,7 +40,7 @@ bool cmInstallTargetsCommand::InitialPass(std::vector const& args, } else { cmTargets::iterator ti = tgts.find(*s); if (ti != tgts.end()) { - ti->second.SetInstallPath(args[0].c_str()); + ti->second.SetInstallPath(args[0]); ti->second.SetRuntimeInstallPath(runtime_dir.c_str()); ti->second.SetHaveInstallRule(true); } else { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ebf5e6d..fa0e3e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -169,6 +169,7 @@ public: cmMakefile* Makefile; cmPolicies::PolicyMap PolicyMap; std::string Name; + std::string InstallPath; cmPropertyMap Properties; std::set> Utilities; std::set SystemIncludeDirectories; @@ -773,6 +774,16 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const } } +std::string const& cmTarget::GetInstallPath() const +{ + return impl->InstallPath; +} + +void cmTarget::SetInstallPath(std::string const& name) +{ + impl->InstallPath = name; +} + cmTarget::LinkLibraryVectorType const& cmTarget::GetOriginalLinkLibraries() const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f9dd83e..7dfedf1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -154,8 +154,8 @@ public: * Set the path where this target should be installed. This is relative to * INSTALL_PREFIX */ - std::string GetInstallPath() const { return this->InstallPath; } - void SetInstallPath(const char* name) { this->InstallPath = name; } + std::string const& GetInstallPath() const; + void SetInstallPath(std::string const& name); /** * Set the path where this target (if it has a runtime part) should be @@ -297,7 +297,6 @@ private: private: bool IsGeneratorProvided; - std::string InstallPath; std::string RuntimeInstallPath; std::vector PreBuildCommands; std::vector PreLinkCommands; -- cgit v0.12 From 30495bb1c291627f94912049da6e06d951a062ec Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 16:45:21 +0100 Subject: cmTarget: Move member `RuntimeInstallPath` to impl --- Source/cmInstallTargetsCommand.cxx | 2 +- Source/cmTarget.cxx | 11 +++++++++++ Source/cmTarget.h | 11 ++--------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 8f417db..7e67d4e 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -41,7 +41,7 @@ bool cmInstallTargetsCommand::InitialPass(std::vector const& args, cmTargets::iterator ti = tgts.find(*s); if (ti != tgts.end()) { ti->second.SetInstallPath(args[0]); - ti->second.SetRuntimeInstallPath(runtime_dir.c_str()); + ti->second.SetRuntimeInstallPath(runtime_dir); ti->second.SetHaveInstallRule(true); } else { std::string str = "Cannot find target: \"" + *s + "\" to install."; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fa0e3e7..208655c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,6 +170,7 @@ public: cmPolicies::PolicyMap PolicyMap; std::string Name; std::string InstallPath; + std::string RuntimeInstallPath; cmPropertyMap Properties; std::set> Utilities; std::set SystemIncludeDirectories; @@ -784,6 +785,16 @@ void cmTarget::SetInstallPath(std::string const& name) impl->InstallPath = name; } +std::string const& cmTarget::GetRuntimeInstallPath() const +{ + return impl->RuntimeInstallPath; +} + +void cmTarget::SetRuntimeInstallPath(std::string const& name) +{ + impl->RuntimeInstallPath = name; +} + cmTarget::LinkLibraryVectorType const& cmTarget::GetOriginalLinkLibraries() const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 7dfedf1..b441df1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -161,14 +161,8 @@ public: * Set the path where this target (if it has a runtime part) should be * installed. This is relative to INSTALL_PREFIX */ - std::string GetRuntimeInstallPath() const - { - return this->RuntimeInstallPath; - } - void SetRuntimeInstallPath(const char* name) - { - this->RuntimeInstallPath = name; - } + std::string const& GetRuntimeInstallPath() const; + void SetRuntimeInstallPath(std::string const& name); /** * Get/Set whether there is an install rule for this target. @@ -297,7 +291,6 @@ private: private: bool IsGeneratorProvided; - std::string RuntimeInstallPath; std::vector PreBuildCommands; std::vector PreLinkCommands; std::vector PostBuildCommands; -- cgit v0.12 From db182eb160f2e61bebeb1bb5f289a6d899da18da Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 16:57:16 +0100 Subject: cmTarget: Move member `*Commands` to impl --- Source/cmGlobalVisualStudioGenerator.cxx | 1 + Source/cmGlobalXCodeGenerator.cxx | 1 + Source/cmLocalUnixMakefileGenerator3.cxx | 1 + Source/cmLocalVisualStudio7Generator.cxx | 1 + Source/cmLocalVisualStudioGenerator.cxx | 1 + Source/cmNinjaNormalTargetGenerator.cxx | 3 +-- Source/cmTarget.cxx | 34 +++++++++++++++++++++++ Source/cmTarget.h | 43 +++++++++--------------------- Source/cmVisualStudio10TargetGenerator.cxx | 1 + 9 files changed, 53 insertions(+), 33 deletions(-) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index bc40a5c..280c986 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -12,6 +12,7 @@ #include "cmAlgorithms.h" #include "cmCallVisualStudioMacro.h" +#include "cmCustomCommand.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmLocalVisualStudioGenerator.h" diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4025073..ad1a636 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -12,6 +12,7 @@ #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" +#include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f3d5a94..f6ee9fc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -11,6 +11,7 @@ #include #include "cmAlgorithms.h" +#include "cmCustomCommand.h" // IWYU pragma: keep #include "cmCustomCommandGenerator.h" #include "cmFileTimeCache.h" #include "cmGeneratedFileStream.h" diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index a497308..e519d78 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLocalVisualStudio7Generator.h" +#include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmGeneratorTarget.h" #include "cmGlobalVisualStudio7Generator.h" diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 660729c..f3f2042 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLocalVisualStudioGenerator.h" +#include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b38d410..3300fef 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -12,6 +12,7 @@ #include #include "cmAlgorithms.h" +#include "cmCustomCommand.h" // IWYU pragma: keep #include "cmCustomCommandGenerator.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" @@ -32,8 +33,6 @@ #include "cmStateTypes.h" #include "cmSystemTools.h" -class cmCustomCommand; - cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( cmGeneratorTarget* target) : cmNinjaTargetGenerator(target) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 208655c..91023ee 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -13,6 +13,7 @@ #include #include "cmAlgorithms.h" +#include "cmCustomCommand.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -173,6 +174,9 @@ public: std::string RuntimeInstallPath; cmPropertyMap Properties; std::set> Utilities; + std::vector PreBuildCommands; + std::vector PreLinkCommands; + std::vector PostBuildCommands; std::set SystemIncludeDirectories; cmTarget::LinkLibraryVectorType OriginalLinkLibraries; std::vector IncludeDirectoriesEntries; @@ -550,6 +554,36 @@ bool cmTarget::IsAppBundleOnApple() const this->GetPropertyAsBool("MACOSX_BUNDLE")); } +std::vector const& cmTarget::GetPreBuildCommands() const +{ + return impl->PreBuildCommands; +} + +void cmTarget::AddPreBuildCommand(cmCustomCommand const& cmd) +{ + impl->PreBuildCommands.push_back(cmd); +} + +std::vector const& cmTarget::GetPreLinkCommands() const +{ + return impl->PreLinkCommands; +} + +void cmTarget::AddPreLinkCommand(cmCustomCommand const& cmd) +{ + impl->PreLinkCommands.push_back(cmd); +} + +std::vector const& cmTarget::GetPostBuildCommands() const +{ + return impl->PostBuildCommands; +} + +void cmTarget::AddPostBuildCommand(cmCustomCommand const& cmd) +{ + impl->PostBuildCommands.push_back(cmd); +} + void cmTarget::AddTracedSources(std::vector const& srcs) { if (!srcs.empty()) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b441df1..297f501 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -13,12 +13,12 @@ #include #include "cmAlgorithms.h" -#include "cmCustomCommand.h" #include "cmListFileCache.h" #include "cmPolicies.h" #include "cmStateTypes.h" #include "cmTargetLinkLibraryType.h" +class cmCustomCommand; class cmGlobalGenerator; class cmMakefile; class cmMessenger; @@ -94,33 +94,17 @@ public: #undef DECLARE_TARGET_POLICY - /** - * Get the list of the custom commands for this target - */ - std::vector const& GetPreBuildCommands() const - { - return this->PreBuildCommands; - } - std::vector const& GetPreLinkCommands() const - { - return this->PreLinkCommands; - } - std::vector const& GetPostBuildCommands() const - { - return this->PostBuildCommands; - } - void AddPreBuildCommand(cmCustomCommand const& cmd) - { - this->PreBuildCommands.push_back(cmd); - } - void AddPreLinkCommand(cmCustomCommand const& cmd) - { - this->PreLinkCommands.push_back(cmd); - } - void AddPostBuildCommand(cmCustomCommand const& cmd) - { - this->PostBuildCommands.push_back(cmd); - } + ///! Get the list of the PRE_BUILD custom commands for this target + std::vector const& GetPreBuildCommands() const; + void AddPreBuildCommand(cmCustomCommand const& cmd); + + ///! Get the list of the PRE_LINK custom commands for this target + std::vector const& GetPreLinkCommands() const; + void AddPreLinkCommand(cmCustomCommand const& cmd); + + ///! Get the list of the POST_BUILD custom commands for this target + std::vector const& GetPostBuildCommands() const; + void AddPostBuildCommand(cmCustomCommand const& cmd); ///! Add sources to the target. void AddSources(std::vector const& srcs); @@ -291,9 +275,6 @@ private: private: bool IsGeneratorProvided; - std::vector PreBuildCommands; - std::vector PreLinkCommands; - std::vector PostBuildCommands; cmTargetInternalPointer impl; bool HaveInstallRule; bool DLLPlatform; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 5c9f25e..8804e6c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -4,6 +4,7 @@ #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" +#include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" -- cgit v0.12 From 72b0eeeb21807132e110011add7a243a01653f83 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 17:21:01 +0100 Subject: cmTarget: Move member booleans to impl --- Source/cmTarget.cxx | 69 ++++++++++++++++++++++++++++++++++++++++------------- Source/cmTarget.h | 22 +++++------------ 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 91023ee..16c1e05 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -173,6 +173,13 @@ public: std::string InstallPath; std::string RuntimeInstallPath; cmPropertyMap Properties; + bool IsGeneratorProvided; + bool HaveInstallRule; + bool DLLPlatform; + bool IsAndroid; + bool IsImportedTarget; + bool ImportedGloballyVisible; + bool BuildInterfaceIncludesAppended; std::set> Utilities; std::vector PreBuildCommands; std::vector PreLinkCommands; @@ -207,21 +214,21 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->TargetType = type; impl->Makefile = mf; impl->Name = name; - this->IsGeneratorProvided = false; - this->HaveInstallRule = false; - this->DLLPlatform = false; - this->IsAndroid = false; - this->IsImportedTarget = + impl->IsGeneratorProvided = false; + impl->HaveInstallRule = false; + impl->DLLPlatform = false; + impl->IsAndroid = false; + impl->IsImportedTarget = (vis == VisibilityImported || vis == VisibilityImportedGlobally); - this->ImportedGloballyVisible = vis == VisibilityImportedGlobally; - this->BuildInterfaceIncludesAppended = false; + impl->ImportedGloballyVisible = vis == VisibilityImportedGlobally; + impl->BuildInterfaceIncludesAppended = false; // Check whether this is a DLL platform. - this->DLLPlatform = + impl->DLLPlatform = !impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); // Check whether we are targeting an Android platform. - this->IsAndroid = + impl->IsAndroid = (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android"); // Setup default property values. @@ -534,7 +541,7 @@ bool cmTarget::IsExecutableWithExports() const bool cmTarget::HasImportLibrary() const { - return (this->DLLPlatform && + return (impl->DLLPlatform && (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->IsExecutableWithExports())); } @@ -829,6 +836,26 @@ void cmTarget::SetRuntimeInstallPath(std::string const& name) impl->RuntimeInstallPath = name; } +bool cmTarget::GetHaveInstallRule() const +{ + return impl->HaveInstallRule; +} + +void cmTarget::SetHaveInstallRule(bool hir) +{ + impl->HaveInstallRule = hir; +} + +bool cmTarget::GetIsGeneratorProvided() const +{ + return impl->IsGeneratorProvided; +} + +void cmTarget::SetIsGeneratorProvided(bool igp) +{ + impl->IsGeneratorProvided = igp; +} + cmTarget::LinkLibraryVectorType const& cmTarget::GetOriginalLinkLibraries() const { @@ -1132,8 +1159,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) return; } /* no need to change anything if value does not change */ - if (!this->ImportedGloballyVisible) { - this->ImportedGloballyVisible = true; + if (!impl->ImportedGloballyVisible) { + impl->ImportedGloballyVisible = true; this->GetGlobalGenerator()->IndexTarget(this); } } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") && @@ -1251,10 +1278,10 @@ void cmTarget::AppendBuildInterfaceIncludes() !this->IsExecutableWithExports()) { return; } - if (this->BuildInterfaceIncludesAppended) { + if (impl->BuildInterfaceIncludesAppended) { return; } - this->BuildInterfaceIncludesAppended = true; + impl->BuildInterfaceIncludesAppended = true; if (impl->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) { std::string dirs = impl->Makefile->GetCurrentBinaryDirectory(); @@ -1613,6 +1640,16 @@ cmPropertyMap const& cmTarget::GetProperties() const return impl->Properties; } +bool cmTarget::IsImported() const +{ + return impl->IsImportedTarget; +} + +bool cmTarget::IsImportedGloballyVisible() const +{ + return impl->ImportedGloballyVisible; +} + const char* cmTarget::GetSuffixVariableInternal( cmStateEnums::ArtifactType artifact) const { @@ -1640,7 +1677,7 @@ const char* cmTarget::GetSuffixVariableInternal( case cmStateEnums::RuntimeBinaryArtifact: // Android GUI application packages store the native // binary as a shared library. - return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + return (impl->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") ? "CMAKE_SHARED_LIBRARY_SUFFIX" : "CMAKE_EXECUTABLE_SUFFIX"); case cmStateEnums::ImportLibraryArtifact: @@ -1680,7 +1717,7 @@ const char* cmTarget::GetPrefixVariableInternal( case cmStateEnums::RuntimeBinaryArtifact: // Android GUI application packages store the native // binary as a shared library. - return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + return (impl->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") ? "CMAKE_SHARED_LIBRARY_PREFIX" : ""); case cmStateEnums::ImportLibraryArtifact: diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 297f501..7937969 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -151,14 +151,14 @@ public: /** * Get/Set whether there is an install rule for this target. */ - bool GetHaveInstallRule() const { return this->HaveInstallRule; } - void SetHaveInstallRule(bool h) { this->HaveInstallRule = h; } + bool GetHaveInstallRule() const; + void SetHaveInstallRule(bool hir); /** * Get/Set whether this target was auto-created by a generator. */ - bool GetIsGeneratorProvided() const { return this->IsGeneratorProvided; } - void SetIsGeneratorProvided(bool igp) { this->IsGeneratorProvided = igp; } + bool GetIsGeneratorProvided() const; + void SetIsGeneratorProvided(bool igp); /** * Add a utility on which this project depends. A utility is an executable @@ -185,11 +185,8 @@ public: ///! Get all properties cmPropertyMap const& GetProperties() const; - bool IsImported() const { return this->IsImportedTarget; } - bool IsImportedGloballyVisible() const - { - return this->ImportedGloballyVisible; - } + bool IsImported() const; + bool IsImportedGloballyVisible() const; bool GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, std::string& suffix) const; @@ -274,14 +271,7 @@ private: std::string const& value) const; private: - bool IsGeneratorProvided; cmTargetInternalPointer impl; - bool HaveInstallRule; - bool DLLPlatform; - bool IsAndroid; - bool IsImportedTarget; - bool ImportedGloballyVisible; - bool BuildInterfaceIncludesAppended; std::string ProcessSourceItemCMP0049(const std::string& s); -- cgit v0.12 From afc4612fa57da09748745fefac02a2086f374db1 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 17:38:20 +0100 Subject: cmTarget: Move member method `ProcessSourceItemCMP0049()` to impl --- Source/cmTarget.cxx | 17 ++++++++++------- Source/cmTarget.h | 7 ++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 16c1e05..c4cff52 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -205,6 +205,9 @@ public: std::vector> TLLCommands; cmListFileBacktrace Backtrace; + +public: + std::string ProcessSourceItemCMP0049(const std::string& s); }; cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, @@ -607,7 +610,7 @@ void cmTarget::AddSources(std::vector const& srcs) for (auto filename : srcs) { if (!cmGeneratorExpression::StartsWithGeneratorExpression(filename)) { if (!filename.empty()) { - filename = this->ProcessSourceItemCMP0049(filename); + filename = impl->ProcessSourceItemCMP0049(filename); if (filename.empty()) { return; } @@ -625,18 +628,18 @@ void cmTarget::AddSources(std::vector const& srcs) } } -std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) +std::string cmTargetInternals::ProcessSourceItemCMP0049(const std::string& s) { std::string src = s; // For backwards compatibility replace variables in source names. // This should eventually be removed. - impl->Makefile->ExpandVariablesInString(src); + this->Makefile->ExpandVariablesInString(src); if (src != s) { std::ostringstream e; bool noMessage = false; MessageType messageType = MessageType::AUTHOR_WARNING; - switch (impl->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) { + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0049) << "\n"; break; @@ -650,10 +653,10 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) } if (!noMessage) { e << "Legacy variable expansion in source file \"" << s - << "\" expanded to \"" << src << "\" in target \"" << this->GetName() + << "\" expanded to \"" << src << "\" in target \"" << this->Name << "\". This behavior will be removed in a " "future version of CMake."; - impl->Makefile->IssueMessage(messageType, e.str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == MessageType::FATAL_ERROR) { return ""; } @@ -664,7 +667,7 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) { - std::string src = this->ProcessSourceItemCMP0049(s); + std::string src = impl->ProcessSourceItemCMP0049(s); if (!s.empty() && src.empty()) { return nullptr; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 7937969..a4696c8 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -43,8 +43,7 @@ private: /** \class cmTarget * \brief Represent a library or executable target loaded from a makefile. * - * cmTarget represents a target loaded from - * a makefile. + * cmTarget represents a target loaded from a makefile. */ class cmTarget { @@ -273,9 +272,7 @@ private: private: cmTargetInternalPointer impl; - std::string ProcessSourceItemCMP0049(const std::string& s); - - /** Return whether or not the target has a DLL import library. */ + ///! Return whether or not the target has a DLL import library. bool HasImportLibrary() const; // Internal representation details. -- cgit v0.12 From ff91071a14885b9e031b262e5d576b8f174870a2 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 17:43:41 +0100 Subject: cmTarget: Move member method `CheckImportedLibName` to impl --- Source/cmTarget.cxx | 19 +++++++++++-------- Source/cmTarget.h | 3 --- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c4cff52..a90e1b5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -207,6 +207,9 @@ public: cmListFileBacktrace Backtrace; public: + bool CheckImportedLibName(std::string const& prop, + std::string const& value) const; + std::string ProcessSourceItemCMP0049(const std::string& s); }; @@ -1167,7 +1170,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->GetGlobalGenerator()->IndexTarget(this); } } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") && - !this->CheckImportedLibName(prop, value ? value : "")) { + !impl->CheckImportedLibName(prop, value ? value : "")) { /* error was reported by check method */ } else if (prop == propCUDA_PTX_COMPILATION && this->GetType() != cmStateEnums::OBJECT_LIBRARY) { @@ -1808,12 +1811,12 @@ void cmTarget::SetPropertyDefault(const std::string& property, } } -bool cmTarget::CheckImportedLibName(std::string const& prop, - std::string const& value) const +bool cmTargetInternals::CheckImportedLibName(std::string const& prop, + std::string const& value) const { - if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY || - !this->IsImported()) { - impl->Makefile->IssueMessage( + if (this->TargetType != cmStateEnums::INTERFACE_LIBRARY || + !this->IsImportedTarget) { + this->Makefile->IssueMessage( MessageType::FATAL_ERROR, prop + " property may be set only on imported INTERFACE library targets."); @@ -1821,14 +1824,14 @@ bool cmTarget::CheckImportedLibName(std::string const& prop, } if (!value.empty()) { if (value[0] == '-') { - impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, + this->Makefile->IssueMessage(MessageType::FATAL_ERROR, prop + " property value\n " + value + "\nmay not start with '-'."); return false; } std::string::size_type bad = value.find_first_of(":/\\;"); if (bad != std::string::npos) { - impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, + this->Makefile->IssueMessage(MessageType::FATAL_ERROR, prop + " property value\n " + value + "\nmay not contain '" + value.substr(bad, 1) + "'."); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a4696c8..c0a0cb5 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -266,9 +266,6 @@ private: void SetPropertyDefault(const std::string& property, const char* default_value); - bool CheckImportedLibName(std::string const& prop, - std::string const& value) const; - private: cmTargetInternalPointer impl; -- cgit v0.12 From a65a404186c69fabc61ea87459e22110c998fb1b Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 18:10:28 +0100 Subject: cmTarget: Inline private HasImportLibrary method --- Source/cmTarget.cxx | 11 +++-------- Source/cmTarget.h | 3 --- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a90e1b5..52e8a40 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -545,13 +545,6 @@ bool cmTarget::IsExecutableWithExports() const this->GetPropertyAsBool("ENABLE_EXPORTS")); } -bool cmTarget::HasImportLibrary() const -{ - return (impl->DLLPlatform && - (this->GetType() == cmStateEnums::SHARED_LIBRARY || - this->IsExecutableWithExports())); -} - bool cmTarget::IsFrameworkOnApple() const { return ((this->GetType() == cmStateEnums::SHARED_LIBRARY || @@ -1875,7 +1868,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, // If we needed to find one of the mapped configurations but did not // On a DLL platform there may be only IMPORTED_IMPLIB for a shared // library or an executable with exports. - bool allowImp = this->HasImportLibrary(); + bool allowImp = (impl->DLLPlatform && + (this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->IsExecutableWithExports())); // If a mapping was found, check its configurations. for (std::vector::const_iterator mci = mappedConfigs.begin(); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c0a0cb5..93d8303 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -269,9 +269,6 @@ private: private: cmTargetInternalPointer impl; - ///! Return whether or not the target has a DLL import library. - bool HasImportLibrary() const; - // Internal representation details. friend class cmTargetInternals; friend class cmGeneratorTarget; -- cgit v0.12 From 2bfee8a58b01fc94db56dc0ed8bb5da3f33cf2a6 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 18:19:39 +0100 Subject: cmTarget: Remove obsolete `friend` definitions --- Source/cmTarget.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 93d8303..0ed6450 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -256,6 +256,9 @@ public: cmStateEnums::ArtifactType artifact) const; private: + // Internal representation details. + friend class cmGeneratorTarget; + const char* GetSuffixVariableInternal( cmStateEnums::ArtifactType artifact) const; const char* GetPrefixVariableInternal( @@ -268,11 +271,6 @@ private: private: cmTargetInternalPointer impl; - - // Internal representation details. - friend class cmTargetInternals; - friend class cmGeneratorTarget; - friend class cmTargetTraceDependencies; }; typedef std::unordered_map cmTargets; -- cgit v0.12 From be2764a6576baf4b380cfcf5418284e9bee80dfa Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 19:26:31 +0100 Subject: cmTarget: Make private `SetPropertyDefault` an in code lambda `InitProperty` --- Source/cmTarget.cxx | 254 +++++++++++++++++++++++++--------------------------- Source/cmTarget.h | 5 -- 2 files changed, 124 insertions(+), 135 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 52e8a40..a92bb9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -237,112 +237,120 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->IsAndroid = (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android"); + std::string gKey; + gKey.reserve(128); + gKey += "CMAKE_"; + auto InitProperty = [this, mf, &gKey](const std::string& property, + const char* default_value) { + // Replace everything after "CMAKE_" + gKey.replace(gKey.begin() + 6, gKey.end(), property); + if (const char* value = mf->GetDefinition(gKey)) { + this->SetProperty(property, value); + } else if (default_value) { + this->SetProperty(property, default_value); + } + }; + // Setup default property values. if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("ANDROID_API", nullptr); - this->SetPropertyDefault("ANDROID_API_MIN", nullptr); - this->SetPropertyDefault("ANDROID_ARCH", nullptr); - this->SetPropertyDefault("ANDROID_STL_TYPE", nullptr); - this->SetPropertyDefault("ANDROID_SKIP_ANT_STEP", nullptr); - this->SetPropertyDefault("ANDROID_PROCESS_MAX", nullptr); - this->SetPropertyDefault("ANDROID_PROGUARD", nullptr); - this->SetPropertyDefault("ANDROID_PROGUARD_CONFIG_PATH", nullptr); - this->SetPropertyDefault("ANDROID_SECURE_PROPS_PATH", nullptr); - this->SetPropertyDefault("ANDROID_NATIVE_LIB_DIRECTORIES", nullptr); - this->SetPropertyDefault("ANDROID_NATIVE_LIB_DEPENDENCIES", nullptr); - this->SetPropertyDefault("ANDROID_JAVA_SOURCE_DIR", nullptr); - this->SetPropertyDefault("ANDROID_JAR_DIRECTORIES", nullptr); - this->SetPropertyDefault("ANDROID_JAR_DEPENDENCIES", nullptr); - this->SetPropertyDefault("ANDROID_ASSETS_DIRECTORIES", nullptr); - this->SetPropertyDefault("ANDROID_ANT_ADDITIONAL_OPTIONS", nullptr); - this->SetPropertyDefault("BUILD_RPATH", nullptr); - this->SetPropertyDefault("BUILD_RPATH_USE_ORIGIN", nullptr); - this->SetPropertyDefault("INSTALL_NAME_DIR", nullptr); - this->SetPropertyDefault("INSTALL_RPATH", ""); - this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); - this->SetPropertyDefault("INTERPROCEDURAL_OPTIMIZATION", nullptr); - this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); - this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); - this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", nullptr); - this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", nullptr); - this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", nullptr); - this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", nullptr); - this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", nullptr); - this->SetPropertyDefault("Fortran_FORMAT", nullptr); - this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", nullptr); - this->SetPropertyDefault("Fortran_COMPILER_LAUNCHER", nullptr); - this->SetPropertyDefault("GNUtoMS", nullptr); - this->SetPropertyDefault("OSX_ARCHITECTURES", nullptr); - this->SetPropertyDefault("IOS_INSTALL_COMBINED", nullptr); - this->SetPropertyDefault("AUTOMOC", nullptr); - this->SetPropertyDefault("AUTOUIC", nullptr); - this->SetPropertyDefault("AUTORCC", nullptr); - this->SetPropertyDefault("AUTOGEN_ORIGIN_DEPENDS", nullptr); - this->SetPropertyDefault("AUTOGEN_PARALLEL", nullptr); - this->SetPropertyDefault("AUTOMOC_COMPILER_PREDEFINES", nullptr); - this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", nullptr); - this->SetPropertyDefault("AUTOMOC_MACRO_NAMES", nullptr); - this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", nullptr); - this->SetPropertyDefault("AUTOUIC_OPTIONS", nullptr); - this->SetPropertyDefault("AUTOUIC_SEARCH_PATHS", nullptr); - this->SetPropertyDefault("AUTORCC_OPTIONS", nullptr); - this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", nullptr); - this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", nullptr); - this->SetPropertyDefault("WIN32_EXECUTABLE", nullptr); - this->SetPropertyDefault("MACOSX_BUNDLE", nullptr); - this->SetPropertyDefault("MACOSX_RPATH", nullptr); - this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", nullptr); - this->SetPropertyDefault("BUILD_WITH_INSTALL_NAME_DIR", nullptr); - this->SetPropertyDefault("C_CLANG_TIDY", nullptr); - this->SetPropertyDefault("C_COMPILER_LAUNCHER", nullptr); - this->SetPropertyDefault("C_CPPLINT", nullptr); - this->SetPropertyDefault("C_CPPCHECK", nullptr); - this->SetPropertyDefault("C_INCLUDE_WHAT_YOU_USE", nullptr); - this->SetPropertyDefault("LINK_WHAT_YOU_USE", nullptr); - this->SetPropertyDefault("C_STANDARD", nullptr); - this->SetPropertyDefault("C_STANDARD_REQUIRED", nullptr); - this->SetPropertyDefault("C_EXTENSIONS", nullptr); - this->SetPropertyDefault("CXX_CLANG_TIDY", nullptr); - this->SetPropertyDefault("CXX_COMPILER_LAUNCHER", nullptr); - this->SetPropertyDefault("CXX_CPPLINT", nullptr); - this->SetPropertyDefault("CXX_CPPCHECK", nullptr); - this->SetPropertyDefault("CXX_INCLUDE_WHAT_YOU_USE", nullptr); - this->SetPropertyDefault("CXX_STANDARD", nullptr); - this->SetPropertyDefault("CXX_STANDARD_REQUIRED", nullptr); - this->SetPropertyDefault("CXX_EXTENSIONS", nullptr); - this->SetPropertyDefault("CUDA_STANDARD", nullptr); - this->SetPropertyDefault("CUDA_STANDARD_REQUIRED", nullptr); - this->SetPropertyDefault("CUDA_EXTENSIONS", nullptr); - this->SetPropertyDefault("CUDA_COMPILER_LAUNCHER", nullptr); - this->SetPropertyDefault("CUDA_SEPARABLE_COMPILATION", nullptr); - this->SetPropertyDefault("LINK_SEARCH_START_STATIC", nullptr); - this->SetPropertyDefault("LINK_SEARCH_END_STATIC", nullptr); - this->SetPropertyDefault("FOLDER", nullptr); + InitProperty("ANDROID_API", nullptr); + InitProperty("ANDROID_API_MIN", nullptr); + InitProperty("ANDROID_ARCH", nullptr); + InitProperty("ANDROID_STL_TYPE", nullptr); + InitProperty("ANDROID_SKIP_ANT_STEP", nullptr); + InitProperty("ANDROID_PROCESS_MAX", nullptr); + InitProperty("ANDROID_PROGUARD", nullptr); + InitProperty("ANDROID_PROGUARD_CONFIG_PATH", nullptr); + InitProperty("ANDROID_SECURE_PROPS_PATH", nullptr); + InitProperty("ANDROID_NATIVE_LIB_DIRECTORIES", nullptr); + InitProperty("ANDROID_NATIVE_LIB_DEPENDENCIES", nullptr); + InitProperty("ANDROID_JAVA_SOURCE_DIR", nullptr); + InitProperty("ANDROID_JAR_DIRECTORIES", nullptr); + InitProperty("ANDROID_JAR_DEPENDENCIES", nullptr); + InitProperty("ANDROID_ASSETS_DIRECTORIES", nullptr); + InitProperty("ANDROID_ANT_ADDITIONAL_OPTIONS", nullptr); + InitProperty("BUILD_RPATH", nullptr); + InitProperty("BUILD_RPATH_USE_ORIGIN", nullptr); + InitProperty("INSTALL_NAME_DIR", nullptr); + InitProperty("INSTALL_RPATH", ""); + InitProperty("INSTALL_RPATH_USE_LINK_PATH", "OFF"); + InitProperty("INTERPROCEDURAL_OPTIMIZATION", nullptr); + InitProperty("SKIP_BUILD_RPATH", "OFF"); + InitProperty("BUILD_WITH_INSTALL_RPATH", "OFF"); + InitProperty("ARCHIVE_OUTPUT_DIRECTORY", nullptr); + InitProperty("LIBRARY_OUTPUT_DIRECTORY", nullptr); + InitProperty("RUNTIME_OUTPUT_DIRECTORY", nullptr); + InitProperty("PDB_OUTPUT_DIRECTORY", nullptr); + InitProperty("COMPILE_PDB_OUTPUT_DIRECTORY", nullptr); + InitProperty("Fortran_FORMAT", nullptr); + InitProperty("Fortran_MODULE_DIRECTORY", nullptr); + InitProperty("Fortran_COMPILER_LAUNCHER", nullptr); + InitProperty("GNUtoMS", nullptr); + InitProperty("OSX_ARCHITECTURES", nullptr); + InitProperty("IOS_INSTALL_COMBINED", nullptr); + InitProperty("AUTOMOC", nullptr); + InitProperty("AUTOUIC", nullptr); + InitProperty("AUTORCC", nullptr); + InitProperty("AUTOGEN_ORIGIN_DEPENDS", nullptr); + InitProperty("AUTOGEN_PARALLEL", nullptr); + InitProperty("AUTOMOC_COMPILER_PREDEFINES", nullptr); + InitProperty("AUTOMOC_DEPEND_FILTERS", nullptr); + InitProperty("AUTOMOC_MACRO_NAMES", nullptr); + InitProperty("AUTOMOC_MOC_OPTIONS", nullptr); + InitProperty("AUTOUIC_OPTIONS", nullptr); + InitProperty("AUTOUIC_SEARCH_PATHS", nullptr); + InitProperty("AUTORCC_OPTIONS", nullptr); + InitProperty("LINK_DEPENDS_NO_SHARED", nullptr); + InitProperty("LINK_INTERFACE_LIBRARIES", nullptr); + InitProperty("WIN32_EXECUTABLE", nullptr); + InitProperty("MACOSX_BUNDLE", nullptr); + InitProperty("MACOSX_RPATH", nullptr); + InitProperty("NO_SYSTEM_FROM_IMPORTED", nullptr); + InitProperty("BUILD_WITH_INSTALL_NAME_DIR", nullptr); + InitProperty("C_CLANG_TIDY", nullptr); + InitProperty("C_COMPILER_LAUNCHER", nullptr); + InitProperty("C_CPPLINT", nullptr); + InitProperty("C_CPPCHECK", nullptr); + InitProperty("C_INCLUDE_WHAT_YOU_USE", nullptr); + InitProperty("LINK_WHAT_YOU_USE", nullptr); + InitProperty("C_STANDARD", nullptr); + InitProperty("C_STANDARD_REQUIRED", nullptr); + InitProperty("C_EXTENSIONS", nullptr); + InitProperty("CXX_CLANG_TIDY", nullptr); + InitProperty("CXX_COMPILER_LAUNCHER", nullptr); + InitProperty("CXX_CPPLINT", nullptr); + InitProperty("CXX_CPPCHECK", nullptr); + InitProperty("CXX_INCLUDE_WHAT_YOU_USE", nullptr); + InitProperty("CXX_STANDARD", nullptr); + InitProperty("CXX_STANDARD_REQUIRED", nullptr); + InitProperty("CXX_EXTENSIONS", nullptr); + InitProperty("CUDA_STANDARD", nullptr); + InitProperty("CUDA_STANDARD_REQUIRED", nullptr); + InitProperty("CUDA_EXTENSIONS", nullptr); + InitProperty("CUDA_COMPILER_LAUNCHER", nullptr); + InitProperty("CUDA_SEPARABLE_COMPILATION", nullptr); + InitProperty("LINK_SEARCH_START_STATIC", nullptr); + InitProperty("LINK_SEARCH_END_STATIC", nullptr); + InitProperty("FOLDER", nullptr); #ifdef __APPLE__ if (this->GetGlobalGenerator()->IsXcode()) { - this->SetPropertyDefault("XCODE_GENERATE_SCHEME", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_ADDRESS_SANITIZER", nullptr); - this->SetPropertyDefault( - "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_THREAD_SANITIZER", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_THREAD_SANITIZER_STOP", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER", - nullptr); - this->SetPropertyDefault( - "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER", - nullptr); - this->SetPropertyDefault("XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP", - nullptr); - this->SetPropertyDefault("XCODE_SCHEME_MALLOC_SCRIBBLE", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_MALLOC_GUARD_EDGES", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_GUARD_MALLOC", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_ZOMBIE_OBJECTS", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_MALLOC_STACK", nullptr); - this->SetPropertyDefault("XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE", - nullptr); - this->SetPropertyDefault("XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS", nullptr); + InitProperty("XCODE_GENERATE_SCHEME", nullptr); + InitProperty("XCODE_SCHEME_ADDRESS_SANITIZER", nullptr); + InitProperty("XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN", nullptr); + InitProperty("XCODE_SCHEME_THREAD_SANITIZER", nullptr); + InitProperty("XCODE_SCHEME_THREAD_SANITIZER_STOP", nullptr); + InitProperty("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER", nullptr); + InitProperty("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP", nullptr); + InitProperty("XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER", nullptr); + InitProperty("XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP", nullptr); + InitProperty("XCODE_SCHEME_MALLOC_SCRIBBLE", nullptr); + InitProperty("XCODE_SCHEME_MALLOC_GUARD_EDGES", nullptr); + InitProperty("XCODE_SCHEME_GUARD_MALLOC", nullptr); + InitProperty("XCODE_SCHEME_ZOMBIE_OBJECTS", nullptr); + InitProperty("XCODE_SCHEME_MALLOC_STACK", nullptr); + InitProperty("XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE", nullptr); + InitProperty("XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS", nullptr); } #endif } @@ -370,7 +378,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } std::string property = prop; property += configUpper; - this->SetPropertyDefault(property, nullptr); + InitProperty(property, nullptr); } // Initialize per-configuration name postfix property from the @@ -382,7 +390,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->TargetType != cmStateEnums::INTERFACE_LIBRARY) { std::string property = cmSystemTools::UpperCase(configName); property += "_POSTFIX"; - this->SetPropertyDefault(property, nullptr); + InitProperty(property, nullptr); } } } @@ -420,16 +428,16 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("C_VISIBILITY_PRESET", nullptr); - this->SetPropertyDefault("CXX_VISIBILITY_PRESET", nullptr); - this->SetPropertyDefault("CUDA_VISIBILITY_PRESET", nullptr); - this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", nullptr); + InitProperty("C_VISIBILITY_PRESET", nullptr); + InitProperty("CXX_VISIBILITY_PRESET", nullptr); + InitProperty("CUDA_VISIBILITY_PRESET", nullptr); + InitProperty("VISIBILITY_INLINES_HIDDEN", nullptr); } if (impl->TargetType == cmStateEnums::EXECUTABLE) { - this->SetPropertyDefault("ANDROID_GUI", nullptr); - this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", nullptr); - this->SetPropertyDefault("ENABLE_EXPORTS", nullptr); + InitProperty("ANDROID_GUI", nullptr); + InitProperty("CROSSCOMPILING_EMULATOR", nullptr); + InitProperty("ENABLE_EXPORTS", nullptr); } if (impl->TargetType == cmStateEnums::SHARED_LIBRARY || impl->TargetType == cmStateEnums::MODULE_LIBRARY) { @@ -437,12 +445,12 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } if (impl->TargetType == cmStateEnums::SHARED_LIBRARY || impl->TargetType == cmStateEnums::EXECUTABLE) { - this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", nullptr); + InitProperty("WINDOWS_EXPORT_ALL_SYMBOLS", nullptr); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", nullptr); + InitProperty("POSITION_INDEPENDENT_CODE", nullptr); } // Record current policies for later use. @@ -458,12 +466,12 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetType() != cmStateEnums::UTILITY) { - this->SetPropertyDefault("JOB_POOL_COMPILE", nullptr); - this->SetPropertyDefault("JOB_POOL_LINK", nullptr); + InitProperty("JOB_POOL_COMPILE", nullptr); + InitProperty("JOB_POOL_LINK", nullptr); } if (impl->TargetType <= cmStateEnums::UTILITY) { - this->SetPropertyDefault("DOTNET_TARGET_FRAMEWORK_VERSION", nullptr); + InitProperty("DOTNET_TARGET_FRAMEWORK_VERSION", nullptr); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && @@ -484,7 +492,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (assignment != std::string::npos) { const std::string propName = vsGlobal + i.substr(0, assignment); const std::string propValue = i.substr(assignment + 1); - this->SetPropertyDefault(propName, propValue.c_str()); + InitProperty(propName, propValue.c_str()); } } } @@ -1790,20 +1798,6 @@ std::string cmTarget::ImportedGetFullPath( return result; } -void cmTarget::SetPropertyDefault(const std::string& property, - const char* default_value) -{ - // Compute the name of the variable holding the default value. - std::string var = "CMAKE_"; - var += property; - - if (const char* value = impl->Makefile->GetDefinition(var)) { - this->SetProperty(property, value); - } else if (default_value) { - this->SetProperty(property, default_value); - } -} - bool cmTargetInternals::CheckImportedLibName(std::string const& prop, std::string const& value) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0ed6450..db73375 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -264,11 +264,6 @@ private: const char* GetPrefixVariableInternal( cmStateEnums::ArtifactType artifact) const; - // Use a makefile variable to set a default for the given property. - // If the variable is not defined use the given default instead. - void SetPropertyDefault(const std::string& property, - const char* default_value); - private: cmTargetInternalPointer impl; }; -- cgit v0.12 From ecc782c75d7ce98c03164f616e9adf9760ce0d7f Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 19:51:43 +0100 Subject: cmTarget: Single line comment clanups --- Source/cmTarget.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index db73375..f6ccdb4 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -190,18 +190,16 @@ public: bool GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, std::string& suffix) const; - /** Return whether this target is an executable with symbol exports - enabled. */ + ///! Return whether this target is an executable with symbol exports enabled. bool IsExecutableWithExports() const; - /** Return whether this target is a shared library Framework on - Apple. */ + ///! Return whether this target is a shared library Framework on Apple. bool IsFrameworkOnApple() const; - /** Return whether this target is an executable Bundle on Apple. */ + ///! Return whether this target is an executable Bundle on Apple. bool IsAppBundleOnApple() const; - /** Get a backtrace from the creation of the target. */ + ///! Get a backtrace from the creation of the target. cmListFileBacktrace const& GetBacktrace() const; void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, @@ -247,14 +245,14 @@ public: cmStringRange GetLinkImplementationEntries() const; cmBacktraceRange GetLinkImplementationBacktraces() const; + std::string ImportedGetFullPath(const std::string& config, + cmStateEnums::ArtifactType artifact) const; + struct StrictTargetComparison { bool operator()(cmTarget const* t1, cmTarget const* t2) const; }; - std::string ImportedGetFullPath(const std::string& config, - cmStateEnums::ArtifactType artifact) const; - private: // Internal representation details. friend class cmGeneratorTarget; -- cgit v0.12 From de0d57c97abe88a1025d5a26ed94a82438468349 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 23 Mar 2019 19:38:30 +0100 Subject: cmTarget: Use std::unique_ptr instead of custom smart pointer To manage the lifetime of `cmTargetInternals`, the private implementation of `cmTarget`, use `std::unique_ptr` instead of `cmTargetInternalPointer`, which is removed. `cmTarget` is made non-copyable but movable. --- Source/cmTarget.cxx | 40 ++++++---------------------------------- Source/cmTarget.h | 30 ++++++++++++------------------ 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a92bb9b..38bff1b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -215,6 +215,7 @@ public: cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, Visibility vis, cmMakefile* mf) + : impl(cm::make_unique()) { assert(mf); impl->TargetType = type; @@ -500,6 +501,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } } +cmTarget::cmTarget(cmTarget&&) noexcept = default; +cmTarget::~cmTarget() = default; + +cmTarget& cmTarget::operator=(cmTarget&&) noexcept = default; + cmStateEnums::TargetType cmTarget::GetType() const { return impl->TargetType; @@ -1967,37 +1973,3 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, return true; } - -cmTargetInternalPointer::cmTargetInternalPointer() -{ - this->Pointer = new cmTargetInternals; -} - -cmTargetInternalPointer::cmTargetInternalPointer( - cmTargetInternalPointer const& r) -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (Internals) to be copied. - this->Pointer = new cmTargetInternals(*r.Pointer); -} - -cmTargetInternalPointer::~cmTargetInternalPointer() -{ - delete this->Pointer; -} - -cmTargetInternalPointer& cmTargetInternalPointer::operator=( - cmTargetInternalPointer const& r) -{ - if (this == &r) { - return *this; - } // avoid warning on HP about self check - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (Internals) to be copied. - cmTargetInternals* oldPointer = this->Pointer; - this->Pointer = new cmTargetInternals(*r.Pointer); - delete oldPointer; - return *this; -} diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f6ccdb4..5d90ba7 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -6,6 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include +#include // IWYU pragma: keep #include #include #include @@ -26,20 +27,6 @@ class cmPropertyMap; class cmSourceFile; class cmTargetInternals; -class cmTargetInternalPointer -{ -public: - cmTargetInternalPointer(); - cmTargetInternalPointer(cmTargetInternalPointer const& r); - ~cmTargetInternalPointer(); - cmTargetInternalPointer& operator=(cmTargetInternalPointer const& r); - cmTargetInternals* operator->() const { return this->Pointer; } - cmTargetInternals* Get() const { return this->Pointer; } - -private: - cmTargetInternals* Pointer; -}; - /** \class cmTarget * \brief Represent a library or executable target loaded from a makefile. * @@ -55,9 +42,6 @@ public: VisibilityImportedGlobally }; - cmTarget(std::string const& name, cmStateEnums::TargetType type, - Visibility vis, cmMakefile* mf); - enum CustomCommandType { PRE_BUILD, @@ -65,6 +49,16 @@ public: POST_BUILD }; + cmTarget(std::string const& name, cmStateEnums::TargetType type, + Visibility vis, cmMakefile* mf); + + cmTarget(cmTarget const&) = delete; + cmTarget(cmTarget&&) noexcept; + ~cmTarget(); + + cmTarget& operator=(cmTarget const&) = delete; + cmTarget& operator=(cmTarget&&) noexcept; + ///! Return the type of target. cmStateEnums::TargetType GetType() const; @@ -263,7 +257,7 @@ private: cmStateEnums::ArtifactType artifact) const; private: - cmTargetInternalPointer impl; + std::unique_ptr impl; }; typedef std::unordered_map cmTargets; -- cgit v0.12