mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 04:40:56 -06:00
CMP0018: Remove support for OLD behavior
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
CMP0018
|
||||
-------
|
||||
|
||||
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
|
||||
.. include:: REMOVED_PROLOGUE.txt
|
||||
|
||||
Ignore ``CMAKE_SHARED_LIBRARY_<Lang>_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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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*/,
|
||||
|
||||
@@ -591,8 +591,6 @@ public:
|
||||
|
||||
virtual bool SupportsLinkerDependencyFile() const { return false; }
|
||||
|
||||
std::string GetSharedLibFlagsForLanguage(std::string const& lang) const;
|
||||
|
||||
/** Generate an <output>.rule file path for a given command output. */
|
||||
virtual std::string GenerateRuleFile(std::string const& output) const;
|
||||
|
||||
@@ -826,7 +824,6 @@ private:
|
||||
std::map<std::string, std::string> LanguageToOutputExtension;
|
||||
std::map<std::string, std::string> ExtensionToLanguage;
|
||||
std::map<std::string, int> LanguageToLinkerPreference;
|
||||
std::map<std::string, std::string> LanguageToOriginalSharedLibFlags;
|
||||
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
std::unique_ptr<Json::StreamWriter> JsonWriter;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1749,7 +1749,7 @@ std::vector<BT<std::string>> 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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class cmMakefile;
|
||||
"there.", \
|
||||
2, 8, 4, NEW) \
|
||||
SELECT(POLICY, CMP0018, \
|
||||
"Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", 2, 8, 9, WARN) \
|
||||
"Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", 2, 8, 9, NEW) \
|
||||
SELECT(POLICY, CMP0019, \
|
||||
"Do not re-expand variables in include and link information.", 2, 8, \
|
||||
11, WARN) \
|
||||
|
||||
Reference in New Issue
Block a user