diff options
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 1052 |
1 files changed, 569 insertions, 483 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 93cdd46ce..cd675865a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5,6 +5,7 @@ #include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> +#include <initializer_list> #include <iterator> #include <set> #include <sstream> @@ -12,6 +13,7 @@ #include <unordered_set> #include "cmAlgorithms.h" +#include "cmCustomCommand.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -20,6 +22,8 @@ #include "cmMessageType.h" #include "cmMessenger.h" #include "cmProperty.h" +#include "cmPropertyMap.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" #include "cmSourceFileLocationKind.h" @@ -155,6 +159,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; @@ -171,166 +195,188 @@ 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("FRAMEWORK", 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("MSVC_RUNTIME_LIBRARY", 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); + InitProperty("Swift_MODULE_DIRECTORY", nullptr); + InitProperty("VS_JUST_MY_CODE_DEBUGGING", nullptr); #ifdef __APPLE__ if (this->GetGlobalGenerator()->IsXcode()) { - 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 } - // Collect the set of configuration types. - std::vector<std::string> configNames; - mf->GetConfigurations(configNames); - // Setup per-configuration property default values. if (this->GetType() != cmStateEnums::UTILITY) { - const char* configProps[] = { + static const auto configProps = { /* clang-format needs this comment to break after the opening brace */ "ARCHIVE_OUTPUT_DIRECTORY_", "LIBRARY_OUTPUT_DIRECTORY_", "RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_", "COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_", - "INTERPROCEDURAL_OPTIMIZATION_", nullptr + "INTERPROCEDURAL_OPTIMIZATION_" }; + // Collect the set of configuration types. + std::vector<std::string> configNames; + mf->GetConfigurations(configNames); for (std::string const& configName : configNames) { std::string configUpper = cmSystemTools::UpperCase(configName); - for (const char** p = configProps; *p; ++p) { + for (auto const& prop : configProps) { // Interface libraries have no output locations, so honor only // the configuration map. - if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY && - strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) { + if (impl->TargetType == cmStateEnums::INTERFACE_LIBRARY && + strcmp(prop, "MAP_IMPORTED_CONFIG_") != 0) { continue; } - std::string property = *p; + std::string property = prop; property += configUpper; - this->SetPropertyDefault(property, nullptr); + InitProperty(property, nullptr); } // Initialize per-configuration name postfix property from the @@ -338,122 +384,93 @@ 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: - const cmStringRange parentIncludes = - this->Makefile->GetIncludeDirectoriesEntries(); - const cmBacktraceRange parentIncludesBts = - this->Makefile->GetIncludeDirectoriesBacktraces(); - - this->Internal->IncludeDirectoriesEntries.insert( - this->Internal->IncludeDirectoriesEntries.end(), parentIncludes.begin(), - parentIncludes.end()); - this->Internal->IncludeDirectoriesBacktraces.insert( - this->Internal->IncludeDirectoriesBacktraces.end(), - parentIncludesBts.begin(), parentIncludesBts.end()); - - const std::set<std::string> parentSystemIncludes = - this->Makefile->GetSystemIncludeDirectories(); - - this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(), - parentSystemIncludes.end()); - - const cmStringRange parentCompileOptions = - this->Makefile->GetCompileOptionsEntries(); - const cmBacktraceRange parentCompileOptionsBts = - this->Makefile->GetCompileOptionsBacktraces(); - - this->Internal->CompileOptionsEntries.insert( - this->Internal->CompileOptionsEntries.end(), - parentCompileOptions.begin(), parentCompileOptions.end()); - this->Internal->CompileOptionsBacktraces.insert( - this->Internal->CompileOptionsBacktraces.end(), - parentCompileOptionsBts.begin(), parentCompileOptionsBts.end()); - - const cmStringRange parentLinkOptions = - this->Makefile->GetLinkOptionsEntries(); - const cmBacktraceRange parentLinkOptionsBts = - this->Makefile->GetLinkOptionsBacktraces(); - - this->Internal->LinkOptionsEntries.insert( - this->Internal->LinkOptionsEntries.end(), parentLinkOptions.begin(), - parentLinkOptions.end()); - this->Internal->LinkOptionsBacktraces.insert( - this->Internal->LinkOptionsBacktraces.end(), - parentLinkOptionsBts.begin(), parentLinkOptionsBts.end()); - - const cmStringRange parentLinkDirectories = - this->Makefile->GetLinkDirectoriesEntries(); - const cmBacktraceRange parentLinkDirectoriesBts = - this->Makefile->GetLinkDirectoriesBacktraces(); - - this->Internal->LinkDirectoriesEntries.insert( - this->Internal->LinkDirectoriesEntries.end(), - parentLinkDirectories.begin(), parentLinkDirectories.end()); - this->Internal->LinkDirectoriesBacktraces.insert( - this->Internal->LinkDirectoriesBacktraces.end(), - parentLinkDirectoriesBts.begin(), parentLinkDirectoriesBts.end()); + cmAppend(impl->IncludeDirectoriesEntries, + impl->Makefile->GetIncludeDirectoriesEntries()); + cmAppend(impl->IncludeDirectoriesBacktraces, + impl->Makefile->GetIncludeDirectoriesBacktraces()); + + { + auto const& sysInc = impl->Makefile->GetSystemIncludeDirectories(); + impl->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); + } + + cmAppend(impl->CompileOptionsEntries, + impl->Makefile->GetCompileOptionsEntries()); + cmAppend(impl->CompileOptionsBacktraces, + impl->Makefile->GetCompileOptionsBacktraces()); + + cmAppend(impl->LinkOptionsEntries, + impl->Makefile->GetLinkOptionsEntries()); + cmAppend(impl->LinkOptionsBacktraces, + impl->Makefile->GetLinkOptionsBacktraces()); + + cmAppend(impl->LinkDirectoriesEntries, + impl->Makefile->GetLinkDirectoriesEntries()); + cmAppend(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 && @@ -474,7 +491,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()); } } } @@ -482,20 +499,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 @@ -504,34 +557,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); } } @@ -542,25 +618,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; @@ -585,7 +661,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()); @@ -599,7 +675,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; } @@ -663,26 +739,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); } @@ -702,15 +774,13 @@ 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] + ">"; if (debugConfigs.size() > 1) { - for (std::vector<std::string>::const_iterator li = - debugConfigs.begin() + 1; - li != debugConfigs.end(); ++li) { - configString += ",$<CONFIG:" + *li + ">"; + for (std::string const& conf : cmMakeRange(debugConfigs).advance(1)) { + configString += ",$<CONFIG:" + conf + ">"; } configString = "$<OR:" + configString + ">"; } @@ -730,13 +800,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; } @@ -746,18 +816,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) { @@ -785,11 +900,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 @@ -799,11 +914,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); @@ -831,94 +946,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 @@ -940,133 +1060,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); } } @@ -1074,89 +1194,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); } } @@ -1169,17 +1289,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()); @@ -1191,67 +1311,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, @@ -1402,12 +1521,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 @@ -1415,67 +1534,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) { @@ -1488,27 +1607,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); } } @@ -1529,6 +1646,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 { @@ -1556,7 +1688,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: @@ -1596,7 +1728,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: @@ -1670,25 +1802,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 + @@ -1748,7 +1866,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(); @@ -1851,37 +1971,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; -} |