diff options
author | Brad King <brad.king@kitware.com> | 2019-03-27 17:25:21 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-03-27 17:25:35 (GMT) |
commit | fcfbc01d68aac2eca7435bfa0f01e5d1b3524303 (patch) | |
tree | b2371ac603b2931ef8e0f78256c62b15d21b264a /Source | |
parent | c518f305bb8344e79cb2487f8bc0186a0b0c0336 (diff) | |
parent | de0d57c97abe88a1025d5a26ed94a82438468349 (diff) | |
download | CMake-fcfbc01d68aac2eca7435bfa0f01e5d1b3524303.zip CMake-fcfbc01d68aac2eca7435bfa0f01e5d1b3524303.tar.gz CMake-fcfbc01d68aac2eca7435bfa0f01e5d1b3524303.tar.bz2 |
Merge topic 'cmTarget_pimpl'
de0d57c97a cmTarget: Use std::unique_ptr instead of custom smart pointer
ecc782c75d cmTarget: Single line comment clanups
be2764a657 cmTarget: Make private `SetPropertyDefault` an in code lambda `InitProperty`
2bfee8a58b cmTarget: Remove obsolete `friend` definitions
a65a404186 cmTarget: Inline private HasImportLibrary method
ff91071a14 cmTarget: Move member method `CheckImportedLibName` to impl
afc4612fa5 cmTarget: Move member method `ProcessSourceItemCMP0049()` to impl
72b0eeeb21 cmTarget: Move member booleans to impl
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Merge-request: !3142
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmInstallTargetsCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 1 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmLocalVisualStudioGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 982 | ||||
-rw-r--r-- | Source/cmTarget.h | 223 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 1 |
11 files changed, 627 insertions, 593 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/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/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index d721ca0..7e67d4e 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -40,8 +40,8 @@ bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args, } else { cmTargets::iterator ti = tgts.find(*s); if (ti != tgts.end()) { - ti->second.SetInstallPath(args[0].c_str()); - ti->second.SetRuntimeInstallPath(runtime_dir.c_str()); + ti->second.SetInstallPath(args[0]); + ti->second.SetRuntimeInstallPath(runtime_dir); ti->second.SetHaveInstallRule(true); } else { std::string str = "Cannot find target: \"" + *s + "\" to install."; 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 <utility> #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 <utility> #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 c6a69be..38bff1b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -13,6 +13,7 @@ #include <unordered_set> #include "cmAlgorithms.h" +#include "cmCustomCommand.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -21,6 +22,7 @@ #include "cmMessageType.h" #include "cmMessenger.h" #include "cmProperty.h" +#include "cmPropertyMap.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" @@ -164,6 +166,26 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>( class cmTargetInternals { public: + cmStateEnums::TargetType TargetType; + cmMakefile* Makefile; + cmPolicies::PolicyMap PolicyMap; + std::string Name; + std::string InstallPath; + std::string RuntimeInstallPath; + cmPropertyMap Properties; + bool IsGeneratorProvided; + bool HaveInstallRule; + bool DLLPlatform; + bool IsAndroid; + bool IsImportedTarget; + bool ImportedGloballyVisible; + bool BuildInterfaceIncludesAppended; + std::set<BT<std::string>> Utilities; + std::vector<cmCustomCommand> PreBuildCommands; + std::vector<cmCustomCommand> PreLinkCommands; + std::vector<cmCustomCommand> PostBuildCommands; + std::set<std::string> SystemIncludeDirectories; + cmTarget::LinkLibraryVectorType OriginalLinkLibraries; std::vector<std::string> IncludeDirectoriesEntries; std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces; std::vector<std::string> CompileOptionsEntries; @@ -180,138 +202,156 @@ public: std::vector<cmListFileBacktrace> LinkDirectoriesBacktraces; std::vector<std::string> LinkImplementationPropertyEntries; std::vector<cmListFileBacktrace> LinkImplementationPropertyBacktraces; + std::vector<std::pair<cmTarget::TLLSignature, cmListFileContext>> + TLLCommands; + cmListFileBacktrace Backtrace; + +public: + bool CheckImportedLibName(std::string const& prop, + std::string const& value) const; + + std::string ProcessSourceItemCMP0049(const std::string& s); }; cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, Visibility vis, cmMakefile* mf) + : impl(cm::make_unique<cmTargetInternals>()) { assert(mf); - this->IsGeneratorProvided = false; - this->Name = name; - this->TargetTypeValue = type; - this->Makefile = mf; - this->HaveInstallRule = false; - this->DLLPlatform = false; - this->IsAndroid = false; - this->IsImportedTarget = + impl->TargetType = type; + impl->Makefile = mf; + impl->Name = name; + 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 = - !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); + impl->DLLPlatform = + !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->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 } @@ -333,13 +373,13 @@ 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; } std::string property = prop; property += configUpper; - this->SetPropertyDefault(property, nullptr); + InitProperty(property, nullptr); } // Initialize per-configuration name postfix property from the @@ -347,93 +387,92 @@ 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); + InitProperty(property, nullptr); } } } // Save the backtrace of target construction. - this->Backtrace = this->Makefile->GetBacktrace(); + impl->Backtrace = impl->Makefile->GetBacktrace(); if (!this->IsImported()) { // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: - CApp(this->Internal->IncludeDirectoriesEntries, - this->Makefile->GetIncludeDirectoriesEntries()); - CApp(this->Internal->IncludeDirectoriesBacktraces, - this->Makefile->GetIncludeDirectoriesBacktraces()); + CApp(impl->IncludeDirectoriesEntries, + impl->Makefile->GetIncludeDirectoriesEntries()); + CApp(impl->IncludeDirectoriesBacktraces, + impl->Makefile->GetIncludeDirectoriesBacktraces()); { - auto const& sysInc = this->Makefile->GetSystemIncludeDirectories(); - this->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); + auto const& sysInc = impl->Makefile->GetSystemIncludeDirectories(); + impl->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); } - CApp(this->Internal->CompileOptionsEntries, - this->Makefile->GetCompileOptionsEntries()); - CApp(this->Internal->CompileOptionsBacktraces, - this->Makefile->GetCompileOptionsBacktraces()); + CApp(impl->CompileOptionsEntries, + impl->Makefile->GetCompileOptionsEntries()); + CApp(impl->CompileOptionsBacktraces, + impl->Makefile->GetCompileOptionsBacktraces()); - CApp(this->Internal->LinkOptionsEntries, - this->Makefile->GetLinkOptionsEntries()); - CApp(this->Internal->LinkOptionsBacktraces, - this->Makefile->GetLinkOptionsBacktraces()); + CApp(impl->LinkOptionsEntries, impl->Makefile->GetLinkOptionsEntries()); + CApp(impl->LinkOptionsBacktraces, + impl->Makefile->GetLinkOptionsBacktraces()); - CApp(this->Internal->LinkDirectoriesEntries, - this->Makefile->GetLinkDirectoriesEntries()); - CApp(this->Internal->LinkDirectoriesBacktraces, - this->Makefile->GetLinkDirectoriesBacktraces()); + CApp(impl->LinkDirectoriesEntries, + impl->Makefile->GetLinkDirectoriesEntries()); + CApp(impl->LinkDirectoriesBacktraces, + impl->Makefile->GetLinkDirectoriesBacktraces()); } 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 (this->TargetTypeValue == cmStateEnums::EXECUTABLE) { - this->SetPropertyDefault("ANDROID_GUI", nullptr); - this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", nullptr); - this->SetPropertyDefault("ENABLE_EXPORTS", nullptr); + if (impl->TargetType == cmStateEnums::EXECUTABLE) { + InitProperty("ANDROID_GUI", nullptr); + InitProperty("CROSSCOMPILING_EMULATOR", nullptr); + InitProperty("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) { - this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", nullptr); + if (impl->TargetType == cmStateEnums::SHARED_LIBRARY || + impl->TargetType == cmStateEnums::EXECUTABLE) { + 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. - this->Makefile->RecordPolicies(this->PolicyMap); + impl->Makefile->RecordPolicies(impl->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, // 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 && 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 (this->TargetTypeValue <= cmStateEnums::UTILITY) { - this->SetPropertyDefault("DOTNET_TARGET_FRAMEWORK_VERSION", nullptr); + if (impl->TargetType <= cmStateEnums::UTILITY) { + InitProperty("DOTNET_TARGET_FRAMEWORK_VERSION", nullptr); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && @@ -454,7 +493,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()); } } } @@ -462,20 +501,56 @@ 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; +} + +cmMakefile* cmTarget::GetMakefile() const +{ + return impl->Makefile; +} + +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 +{ + return impl->PolicyMap.Get(policy); +} + cmGlobalGenerator* cmTarget::GetGlobalGenerator() const { - return this->GetMakefile()->GetGlobalGenerator(); + return impl->Makefile->GetGlobalGenerator(); +} + +void cmTarget::AddUtility(std::string const& name, cmMakefile* mf) +{ + impl->Utilities.insert( + BT<std::string>(name, mf ? mf->GetBacktrace() : cmListFileBacktrace())); } -void cmTarget::AddUtility(std::string const& u, cmMakefile* mf) +std::set<BT<std::string>> const& cmTarget::GetUtilities() const { - BT<std::string> util(u, mf ? mf->GetBacktrace() : cmListFileBacktrace()); - this->Utilities.insert(util); + return impl->Utilities; } cmListFileBacktrace const& cmTarget::GetBacktrace() const { - return this->Backtrace; + return impl->Backtrace; } bool cmTarget::IsExecutableWithExports() const @@ -484,34 +559,57 @@ bool cmTarget::IsExecutableWithExports() const this->GetPropertyAsBool("ENABLE_EXPORTS")); } -bool cmTarget::HasImportLibrary() const -{ - return (this->DLLPlatform && - (this->GetType() == cmStateEnums::SHARED_LIBRARY || - this->IsExecutableWithExports())); -} - 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")); } +std::vector<cmCustomCommand> const& cmTarget::GetPreBuildCommands() const +{ + return impl->PreBuildCommands; +} + +void cmTarget::AddPreBuildCommand(cmCustomCommand const& cmd) +{ + impl->PreBuildCommands.push_back(cmd); +} + +std::vector<cmCustomCommand> const& cmTarget::GetPreLinkCommands() const +{ + return impl->PreLinkCommands; +} + +void cmTarget::AddPreLinkCommand(cmCustomCommand const& cmd) +{ + impl->PreLinkCommands.push_back(cmd); +} + +std::vector<cmCustomCommand> const& cmTarget::GetPostBuildCommands() const +{ + return impl->PostBuildCommands; +} + +void cmTarget::AddPostBuildCommand(cmCustomCommand const& cmd) +{ + impl->PostBuildCommands.push_back(cmd); +} + void cmTarget::AddTracedSources(std::vector<std::string> const& srcs) { if (!srcs.empty()) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(cmJoin(srcs, ";")); - this->Internal->SourceBacktraces.push_back(lfbt); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + impl->SourceEntries.push_back(cmJoin(srcs, ";")); + impl->SourceBacktraces.push_back(lfbt); } } @@ -522,25 +620,25 @@ void cmTarget::AddSources(std::vector<std::string> 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; } } - this->Makefile->GetOrCreateSource(filename); + impl->Makefile->GetOrCreateSource(filename); } srcFiles += sep; srcFiles += filename; sep = ";"; } if (!srcFiles.empty()) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(std::move(srcFiles)); - this->Internal->SourceBacktraces.push_back(lfbt); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + impl->SourceEntries.push_back(std::move(srcFiles)); + impl->SourceBacktraces.push_back(lfbt); } } -std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) +std::string cmTargetInternals::ProcessSourceItemCMP0049(const std::string& s) { std::string src = s; @@ -565,7 +663,7 @@ 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."; this->Makefile->IssueMessage(messageType, e.str()); @@ -579,7 +677,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; } @@ -643,26 +741,22 @@ 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(this->Internal->SourceEntries.begin(), - this->Internal->SourceEntries.end(), + if (std::find_if(impl->SourceEntries.begin(), impl->SourceEntries.end(), TargetPropertyEntryFinder(sfl)) == - this->Internal->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.end()) { + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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; } - return this->Makefile->GetOrCreateSource(src, false, + return impl->Makefile->GetOrCreateSource(src, false, cmSourceFileLocationKind::Known); } @@ -682,7 +776,7 @@ std::string cmTarget::GetDebugGeneratorExpressions( // Get the list of configurations considered to be DEBUG. std::vector<std::string> debugConfigs = - this->Makefile->GetCMakeInstance()->GetDebugConfigs(); + impl->Makefile->GetCMakeInstance()->GetDebugConfigs(); std::string configString = "$<CONFIG:" + debugConfigs[0] + ">"; @@ -708,13 +802,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; } @@ -724,18 +818,63 @@ 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(); - for (auto const& cmd : this->TLLCommands) { + cmStateDirectory cmDir = impl->Makefile->GetStateSnapshot().GetDirectory(); + for (auto const& cmd : impl->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; } } } +std::string const& cmTarget::GetInstallPath() const +{ + return impl->InstallPath; +} + +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; +} + +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 +{ + return impl->OriginalLinkLibraries; +} + void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib, cmTargetLinkLibraryType llt) { @@ -763,11 +902,11 @@ 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; } - 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 @@ -777,11 +916,11 @@ 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; + std::string targetEntry = impl->Name; targetEntry += "_LIB_DEPENDS"; std::string dependencies; const char* old_val = mf.GetDefinition(targetEntry); @@ -809,94 +948,99 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, void cmTarget::AddSystemIncludeDirectories(const std::set<std::string>& incs) { - this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); + impl->SystemIncludeDirectories.insert(incs.begin(), incs.end()); +} + +std::set<std::string> const& cmTarget::GetSystemIncludeDirectories() const +{ + return impl->SystemIncludeDirectories; } 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) { 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 @@ -918,133 +1062,133 @@ 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->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"; - 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->Name << "\")\n"; + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } 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); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); + impl->IncludeDirectoriesEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileOptionsBacktraces.push_back(lfbt); + impl->CompileOptionsEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileFeaturesBacktraces.push_back(lfbt); + impl->CompileFeaturesEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); + impl->CompileDefinitionsEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkOptionsBacktraces.push_back(lfbt); + impl->LinkOptionsEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkDirectoriesBacktraces.push_back(lfbt); + impl->LinkDirectoriesEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + impl->SourceEntries.emplace_back(value); + impl->SourceBacktraces.push_back(lfbt); } } else if (prop == propIMPORTED_GLOBAL) { if (!cmSystemTools::IsOn(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->Name << "\")\n"; + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); 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") && - !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) { std::ostringstream e; e << "CUDA_PTX_COMPILATION property can only be applied to OBJECT " "targets (\"" - << this->Name << "\")\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + << impl->Name << "\")\n"; + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } else { - this->Properties.SetProperty(prop, value); + impl->Properties.SetProperty(prop, value); } } @@ -1052,89 +1196,89 @@ 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->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"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == "IMPORTED_GLOBAL") { std::ostringstream e; 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->Name << "\")\n"; + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; } if (prop == "INCLUDE_DIRECTORIES") { if (value && *value) { - this->Internal->IncludeDirectoriesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); + impl->IncludeDirectoriesEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + impl->IncludeDirectoriesBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_OPTIONS") { if (value && *value) { - this->Internal->CompileOptionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileOptionsBacktraces.push_back(lfbt); + impl->CompileOptionsEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + impl->CompileOptionsBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_FEATURES") { if (value && *value) { - this->Internal->CompileFeaturesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileFeaturesBacktraces.push_back(lfbt); + impl->CompileFeaturesEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + impl->CompileFeaturesBacktraces.push_back(lfbt); } } else if (prop == "COMPILE_DEFINITIONS") { if (value && *value) { - this->Internal->CompileDefinitionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); + impl->CompileDefinitionsEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + impl->CompileDefinitionsBacktraces.push_back(lfbt); } } else if (prop == "LINK_OPTIONS") { if (value && *value) { - this->Internal->LinkOptionsEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkOptionsBacktraces.push_back(lfbt); + impl->LinkOptionsEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + impl->LinkOptionsBacktraces.push_back(lfbt); } } else if (prop == "LINK_DIRECTORIES") { if (value && *value) { - this->Internal->LinkDirectoriesEntries.emplace_back(value); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->LinkDirectoriesBacktraces.push_back(lfbt); + impl->LinkDirectoriesEntries.emplace_back(value); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); + cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); + 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); + 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); + impl->Properties.AppendProperty(prop, value, asString); } } @@ -1147,17 +1291,17 @@ void cmTarget::AppendBuildInterfaceIncludes() !this->IsExecutableWithExports()) { return; } - if (this->BuildInterfaceIncludesAppended) { + if (impl->BuildInterfaceIncludesAppended) { return; } - this->BuildInterfaceIncludesAppended = true; + impl->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", ("$<BUILD_INTERFACE:" + dirs + ">").c_str()); @@ -1169,67 +1313,66 @@ void cmTarget::InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before) { std::vector<std::string>::iterator position = before - ? this->Internal->IncludeDirectoriesEntries.begin() - : this->Internal->IncludeDirectoriesEntries.end(); + ? impl->IncludeDirectoriesEntries.begin() + : impl->IncludeDirectoriesEntries.end(); std::vector<cmListFileBacktrace>::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<std::string>::iterator position = before - ? this->Internal->CompileOptionsEntries.begin() - : this->Internal->CompileOptionsEntries.end(); + ? impl->CompileOptionsEntries.begin() + : impl->CompileOptionsEntries.end(); std::vector<cmListFileBacktrace>::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<std::string>::iterator position = before - ? this->Internal->LinkOptionsEntries.begin() - : this->Internal->LinkOptionsEntries.end(); + std::vector<std::string>::iterator position = + before ? impl->LinkOptionsEntries.begin() : impl->LinkOptionsEntries.end(); std::vector<cmListFileBacktrace>::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<std::string>::iterator position = before - ? this->Internal->LinkDirectoriesEntries.begin() - : this->Internal->LinkDirectoriesEntries.end(); + ? impl->LinkDirectoriesEntries.begin() + : impl->LinkDirectoriesEntries.end(); std::vector<cmListFileBacktrace>::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 +1523,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,67 +1536,67 @@ 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(); } 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) { @@ -1466,27 +1609,25 @@ 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(); } } - const char* retVal = this->Properties.GetPropertyValue(prop); + const char* retVal = impl->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); } } @@ -1507,6 +1648,21 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const return cmSystemTools::IsOn(this->GetProperty(prop)); } +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 { @@ -1534,7 +1690,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: @@ -1574,7 +1730,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: @@ -1648,25 +1804,11 @@ 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 = this->Makefile->GetDefinition(var)) { - this->SetProperty(property, value); - } else if (default_value) { - this->SetProperty(property, default_value); - } -} - -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()) { + if (this->TargetType != cmStateEnums::INTERFACE_LIBRARY || + !this->IsImportedTarget) { this->Makefile->IssueMessage( MessageType::FATAL_ERROR, prop + @@ -1726,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<std::string>::const_iterator mci = mappedConfigs.begin(); @@ -1829,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 24b3742..5d90ba7 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -6,6 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> +#include <memory> // IWYU pragma: keep #include <set> #include <string> #include <unordered_map> @@ -13,38 +14,23 @@ #include <vector> #include "cmAlgorithms.h" -#include "cmCustomCommand.h" #include "cmListFileCache.h" #include "cmPolicies.h" -#include "cmPropertyMap.h" #include "cmStateTypes.h" #include "cmTargetLinkLibraryType.h" +class cmCustomCommand; class cmGlobalGenerator; class cmMakefile; class cmMessenger; +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. * - * cmTarget represents a target loaded from - * a makefile. + * cmTarget represents a target loaded from a makefile. */ class cmTarget { @@ -56,9 +42,6 @@ public: VisibilityImportedGlobally }; - cmTarget(std::string const& name, cmStateEnums::TargetType type, - Visibility vis, cmMakefile* mf); - enum CustomCommandType { PRE_BUILD, @@ -66,77 +49,68 @@ public: POST_BUILD }; - /** - * Return the type of target. - */ - cmStateEnums::TargetType GetType() const { return this->TargetTypeValue; } + 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; + + ///! 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; } + const std::string& GetName() const; - /** Get the cmMakefile that owns this target. */ - cmMakefile* GetMakefile() const { return this->Makefile; } + ///! 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) #undef DECLARE_TARGET_POLICY - /** - * Get the list of the custom commands for this target - */ - std::vector<cmCustomCommand> const& GetPreBuildCommands() const - { - return this->PreBuildCommands; - } - std::vector<cmCustomCommand> const& GetPreLinkCommands() const - { - return this->PreLinkCommands; - } - std::vector<cmCustomCommand> 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<cmCustomCommand> const& GetPreBuildCommands() const; + void AddPreBuildCommand(cmCustomCommand const& cmd); - /** - * Add sources to the target. - */ + ///! Get the list of the PRE_LINK custom commands for this target + std::vector<cmCustomCommand> const& GetPreLinkCommands() const; + void AddPreLinkCommand(cmCustomCommand const& cmd); + + ///! Get the list of the POST_BUILD custom commands for this target + std::vector<cmCustomCommand> const& GetPostBuildCommands() const; + void AddPostBuildCommand(cmCustomCommand const& cmd); + + ///! Add sources to the target. void AddSources(std::vector<std::string> const& srcs); void AddTracedSources(std::vector<std::string> 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<std::string, cmTargetLinkLibraryType> LibraryID; - typedef std::vector<LibraryID> 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, @@ -157,44 +131,36 @@ 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 * 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. */ - 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 + /** + * 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<BT<std::string>> const& GetUtilities() const - { - return this->Utilities; - } + std::set<BT<std::string>> const& GetUtilities() const; ///! Set/Get a property of this target file void SetProperty(const std::string& prop, const char* value); @@ -209,31 +175,25 @@ 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 - { - return this->ImportedGloballyVisible; - } - - // Get the properties - cmPropertyMap const& GetProperties() const { return this->Properties; } + bool IsImported() const; + bool IsImportedGloballyVisible() const; 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, @@ -252,11 +212,8 @@ public: std::string GetDebugGeneratorExpressions(const std::string& value, cmTargetLinkLibraryType llt) const; - void AddSystemIncludeDirectories(const std::set<std::string>& incs); - std::set<std::string> const& GetSystemIncludeDirectories() const - { - return this->SystemIncludeDirectories; - } + void AddSystemIncludeDirectories(std::set<std::string> const& incs); + std::set<std::string> const& GetSystemIncludeDirectories() const; cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const; @@ -282,63 +239,25 @@ 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; + const char* GetSuffixVariableInternal( cmStateEnums::ArtifactType artifact) const; 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); - - bool CheckImportedLibName(std::string const& prop, - std::string const& value) const; - private: - bool IsGeneratorProvided; - cmPropertyMap Properties; - std::set<std::string> SystemIncludeDirectories; - std::set<BT<std::string>> Utilities; - cmPolicies::PolicyMap PolicyMap; - std::string Name; - std::string InstallPath; - std::string RuntimeInstallPath; - std::vector<cmCustomCommand> PreBuildCommands; - std::vector<cmCustomCommand> PreLinkCommands; - std::vector<cmCustomCommand> PostBuildCommands; - std::vector<std::pair<TLLSignature, cmListFileContext>> TLLCommands; - LinkLibraryVectorType OriginalLinkLibraries; - cmMakefile* Makefile; - cmTargetInternalPointer Internal; - cmStateEnums::TargetType TargetTypeValue; - bool HaveInstallRule; - bool DLLPlatform; - bool IsAndroid; - bool IsImportedTarget; - bool ImportedGloballyVisible; - bool BuildInterfaceIncludesAppended; - - std::string ProcessSourceItemCMP0049(const std::string& s); - - /** Return whether or not the target has a DLL import library. */ - bool HasImportLibrary() const; - - // Internal representation details. - friend class cmTargetInternals; - friend class cmGeneratorTarget; - friend class cmTargetTraceDependencies; - - cmListFileBacktrace Backtrace; + std::unique_ptr<cmTargetInternals> impl; }; typedef std::unordered_map<std::string, cmTarget> cmTargets; 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" |