diff --git a/Help/policy/CMP0018.rst b/Help/policy/CMP0018.rst index e4cd1849bb..c3ae66fc84 100644 --- a/Help/policy/CMP0018.rst +++ b/Help/policy/CMP0018.rst @@ -1,6 +1,9 @@ CMP0018 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + Ignore ``CMAKE_SHARED_LIBRARY__FLAGS`` variable. CMake 2.8.8 and lower compiled sources in ``SHARED`` and ``MODULE`` libraries @@ -28,7 +31,5 @@ The ``NEW`` behavior for this policy is to ignore honor the :prop_tgt:`POSITION_INDEPENDENT_CODE` target property. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.9 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 60679baea7..4b1e8959b4 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -203,7 +203,7 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config, std::string flags; this->LocalGenerator->AddLanguageFlags( flags, this->GeneratorTarget, cmBuildStep::Compile, language, config); - this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, + this->LocalGenerator->AddFeatureFlags(flags, this->GeneratorTarget, language, config); this->LocalGenerator->AddVisibilityPresetFlags( flags, this->GeneratorTarget, language); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index eed22d331f..5b02484476 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -981,12 +981,6 @@ void cmGlobalGenerator::EnableLanguage( } } - // Store the shared library flags so that we can satisfy CMP0018 - std::string sharedLibFlagsVar = - cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS"); - this->LanguageToOriginalSharedLibFlags[lang] = - mf->GetSafeDefinition(sharedLibFlagsVar); - // Translate compiler ids for compatibility. this->CheckCompilerIdCompatibility(mf, lang); } // end for each language @@ -3475,16 +3469,6 @@ bool cmGlobalGenerator::ShouldStripResourcePath(cmMakefile* mf) const return mf->PlatformIsAppleEmbedded(); } -std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( - std::string const& l) const -{ - auto const it = this->LanguageToOriginalSharedLibFlags.find(l); - if (it != this->LanguageToOriginalSharedLibFlags.end()) { - return it->second; - } - return ""; -} - void cmGlobalGenerator::AppendDirectoryForConfig(const std::string& /*unused*/, const std::string& /*unused*/, const std::string& /*unused*/, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index c0f0fdf998..d4be86d642 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -591,8 +591,6 @@ public: virtual bool SupportsLinkerDependencyFile() const { return false; } - std::string GetSharedLibFlagsForLanguage(std::string const& lang) const; - /** Generate an .rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; @@ -826,7 +824,6 @@ private: std::map LanguageToOutputExtension; std::map ExtensionToLanguage; std::map LanguageToLinkerPreference; - std::map LanguageToOriginalSharedLibFlags; #if !defined(CMAKE_BOOTSTRAP) std::unique_ptr JsonWriter; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index daef82163b..9305627ec4 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2421,8 +2421,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CurrentLocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); } - // Add shared-library flags if needed. - this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt, lang, + this->CurrentLocalGenerator->AddFeatureFlags(flags, gtgt, lang, configName); this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, gtgt, lang); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f2a65da1c1..861210c4d5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1749,7 +1749,7 @@ std::vector> cmLocalGenerator::GetTargetCompileFlags( } } - this->AddCMP0018Flags(compileFlags, target, lang, config); + this->AddFeatureFlags(compileFlags, target, lang, config); this->AddVisibilityPresetFlags(compileFlags, target, lang); this->AddColorDiagnosticsFlags(compileFlags, lang); this->AppendFlags(compileFlags, mf->GetDefineFlags()); @@ -2423,19 +2423,6 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, return true; } -void cmLocalGenerator::AddSharedFlags(std::string& flags, - const std::string& lang, bool shared) -{ - std::string flagsVar; - - // Add flags for dealing with shared libraries for this language. - if (shared) { - this->AppendFlags(flags, - this->Makefile->GetSafeDefinition( - cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS"))); - } -} - static void AddVisibilityCompileOption(std::string& flags, cmGeneratorTarget const* target, cmLocalGenerator* lg, @@ -2540,7 +2527,7 @@ void cmLocalGenerator::AddVisibilityPresetFlags( } } -void cmLocalGenerator::AddCMP0018Flags(std::string& flags, +void cmLocalGenerator::AddFeatureFlags(std::string& flags, cmGeneratorTarget const* target, std::string const& lang, const std::string& config) @@ -2550,54 +2537,13 @@ void cmLocalGenerator::AddCMP0018Flags(std::string& flags, bool shared = ((targetType == cmStateEnums::SHARED_LIBRARY) || (targetType == cmStateEnums::MODULE_LIBRARY)); - if (this->GetShouldUseOldFlags(shared, lang)) { - this->AddSharedFlags(flags, lang, shared); - } else { - if (target->GetLinkInterfaceDependentBoolProperty( - "POSITION_INDEPENDENT_CODE", config)) { - this->AddPositionIndependentFlags(flags, lang, targetType); - } - if (shared) { - this->AppendFeatureOptions(flags, lang, "DLL"); - } + if (target->GetLinkInterfaceDependentBoolProperty( + "POSITION_INDEPENDENT_CODE", config)) { + this->AddPositionIndependentFlags(flags, lang, targetType); } -} - -bool cmLocalGenerator::GetShouldUseOldFlags(bool shared, - const std::string& lang) const -{ - std::string originalFlags = - this->GlobalGenerator->GetSharedLibFlagsForLanguage(lang); if (shared) { - std::string flagsVar = cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS"); - std::string const& flags = this->Makefile->GetSafeDefinition(flagsVar); - - if (flags != originalFlags) { - switch (this->GetPolicyStatus(cmPolicies::CMP0018)) { - case cmPolicies::WARN: { - std::ostringstream e; - e << "Variable " << flagsVar - << " has been modified. CMake " - "will ignore the POSITION_INDEPENDENT_CODE target property " - "for " - "shared libraries and will use the " - << flagsVar - << " variable " - "instead. This may cause errors if the original content of " - << flagsVar << " was removed.\n" - << cmPolicies::GetPolicyWarning(cmPolicies::CMP0018); - - this->IssueMessage(MessageType::AUTHOR_WARNING, e.str()); - CM_FALLTHROUGH; - } - case cmPolicies::OLD: - return true; - case cmPolicies::NEW: - return false; - } - } + this->AppendFeatureOptions(flags, lang, "DLL"); } - return false; } void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f51b298e5e..3382675775 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -141,7 +141,7 @@ public: cmGeneratorTarget const* target, const std::string& lang, const std::string& config); - void AddCMP0018Flags(std::string& flags, cmGeneratorTarget const* target, + void AddFeatureFlags(std::string& flags, cmGeneratorTarget const* target, std::string const& lang, const std::string& config); void AddVisibilityPresetFlags(std::string& flags, cmGeneratorTarget const* target, @@ -629,9 +629,6 @@ private: OutputRole role, cmListFileBacktrace const& bt, cmCommandOrigin origin); - void AddSharedFlags(std::string& flags, const std::string& lang, - bool shared); - bool GetShouldUseOldFlags(bool shared, const std::string& lang) const; void AddPositionIndependentFlags(std::string& flags, std::string const& l, int targetType); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index bd2071290a..1a840ad7bd 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -66,7 +66,7 @@ class cmMakefile; "there.", \ 2, 8, 4, NEW) \ SELECT(POLICY, CMP0018, \ - "Ignore CMAKE_SHARED_LIBRARY__FLAGS variable.", 2, 8, 9, WARN) \ + "Ignore CMAKE_SHARED_LIBRARY__FLAGS variable.", 2, 8, 9, NEW) \ SELECT(POLICY, CMP0019, \ "Do not re-expand variables in include and link information.", 2, 8, \ 11, WARN) \