diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-02-01 16:58:30 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-03-01 11:23:28 (GMT) |
commit | ede33f30cfef9e03ecccdb9ce4c7fdf1e8208d75 (patch) | |
tree | 338052612b36c9394f6f0ad71bab57109cf60957 /Source/cmTarget.cxx | |
parent | fcbd723a5085c11c57ec966f8aea605a55d0bdd5 (diff) | |
download | CMake-ede33f30cfef9e03ecccdb9ce4c7fdf1e8208d75.zip CMake-ede33f30cfef9e03ecccdb9ce4c7fdf1e8208d75.tar.gz CMake-ede33f30cfef9e03ecccdb9ce4c7fdf1e8208d75.tar.bz2 |
Apple: Handle generation and comsuption of text-based stubs (.tbd files)
Fixes: #24123
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9ae2576..f4e859c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -445,7 +445,7 @@ TargetProperty const StaticTargetProperties[] = { { "AUTORCC_OPTIONS"_s, IC::CanCompileSources }, // Linking properties - { "ENABLE_EXPORTS"_s, IC::ExecutableTarget }, + { "ENABLE_EXPORTS"_s, IC::TargetWithSymbolExports }, { "LINK_LIBRARIES_ONLY_TARGETS"_s, IC::NormalNonImportedTarget }, { "LINK_SEARCH_START_STATIC"_s, IC::CanCompileSources }, { "LINK_SEARCH_END_STATIC"_s, IC::CanCompileSources }, @@ -1031,6 +1031,31 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, defKey += "CMAKE_"; auto initProperty = [this, mf, &defKey](const std::string& property, const char* default_value) { + // special init for ENABLE_EXPORTS + // For SHARED_LIBRARY, only CMAKE_SHARED_LIBRARY_ENABLE_EXPORTS variable + // is used + // For EXECUTABLE, CMAKE_EXECUTABLE_ENABLE_EXPORTS or else + // CMAKE_ENABLE_EXPORTS variables are used + if (property == "ENABLE_EXPORTS"_s) { + // Replace everything after "CMAKE_" + defKey.replace( + defKey.begin() + 6, defKey.end(), + cmStrCat(this->impl->TargetType == cmStateEnums::EXECUTABLE + ? "EXECUTABLE" + : "SHARED_LIBRARY", + '_', property)); + if (cmValue value = mf->GetDefinition(defKey)) { + this->SetProperty(property, value); + return; + } + if (this->impl->TargetType == cmStateEnums::SHARED_LIBRARY) { + if (default_value) { + this->SetProperty(property, default_value); + } + return; + } + } + // Replace everything after "CMAKE_" defKey.replace(defKey.begin() + 6, defKey.end(), property); if (cmValue value = mf->GetDefinition(defKey)) { @@ -1205,6 +1230,12 @@ bool cmTarget::IsExecutableWithExports() const this->GetPropertyAsBool("ENABLE_EXPORTS")); } +bool cmTarget::IsSharedLibraryWithExports() const +{ + return (this->GetType() == cmStateEnums::SHARED_LIBRARY && + this->GetPropertyAsBool("ENABLE_EXPORTS")); +} + bool cmTarget::IsFrameworkOnApple() const { return ((this->GetType() == cmStateEnums::SHARED_LIBRARY || @@ -2657,7 +2688,8 @@ const char* cmTarget::GetSuffixVariableInternal( case cmStateEnums::RuntimeBinaryArtifact: return "CMAKE_SHARED_LIBRARY_SUFFIX"; case cmStateEnums::ImportLibraryArtifact: - return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + return this->IsApple() ? "CMAKE_APPLE_IMPORT_FILE_SUFFIX" + : "CMAKE_IMPORT_LIBRARY_SUFFIX"; } break; case cmStateEnums::MODULE_LIBRARY: @@ -2698,7 +2730,8 @@ const char* cmTarget::GetPrefixVariableInternal( case cmStateEnums::RuntimeBinaryArtifact: return "CMAKE_SHARED_LIBRARY_PREFIX"; case cmStateEnums::ImportLibraryArtifact: - return "CMAKE_IMPORT_LIBRARY_PREFIX"; + return this->IsApple() ? "CMAKE_APPLE_IMPORT_FILE_PREFIX" + : "CMAKE_IMPORT_LIBRARY_PREFIX"; } break; case cmStateEnums::MODULE_LIBRARY: |