diff --git a/Help/policy/CMP0019.rst b/Help/policy/CMP0019.rst index f3fa46ac0a..004316f74e 100644 --- a/Help/policy/CMP0019.rst +++ b/Help/policy/CMP0019.rst @@ -1,6 +1,9 @@ CMP0019 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + Do not re-expand variables in include and link information. CMake 2.8.10 and lower re-evaluated values given to the @@ -16,7 +19,5 @@ strict compatibility. The ``NEW`` behavior for this policy is to leave the values untouched. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.11 -.. |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/cmMakefile.cxx b/Source/cmMakefile.cxx index b22d9b23a3..50ef9458bb 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1007,9 +1007,6 @@ void cmMakefile::GeneratorAction::operator()(cmLocalGenerator& lg, void cmMakefile::DoGenerate(cmLocalGenerator& lg) { - // do all the variable expansions here - this->ExpandVariablesCMP0019(); - // give all the commands a chance to do something // after the file has been parsed before generation for (auto& action : this->GeneratorActions) { @@ -2303,94 +2300,6 @@ cmSourceGroup* cmMakefile::FindSourceGroup( } #endif -static bool mightExpandVariablesCMP0019(const char* s) -{ - return s && *s && strstr(s, "${") && strchr(s, '}'); -} - -void cmMakefile::ExpandVariablesCMP0019() -{ - // Drop this ancient compatibility behavior with a policy. - cmPolicies::PolicyStatus pol = this->GetPolicyStatus(cmPolicies::CMP0019); - if (pol != cmPolicies::OLD && pol != cmPolicies::WARN) { - return; - } - - std::string e; - - cmValue includeDirs = this->GetProperty("INCLUDE_DIRECTORIES"); - if (includeDirs && mightExpandVariablesCMP0019(includeDirs->c_str())) { - std::string dirs = *includeDirs; - this->ExpandVariablesInString(dirs, true, true); - if (pol == cmPolicies::WARN && dirs != *includeDirs) { - e = cmStrCat("Evaluated directory INCLUDE_DIRECTORIES\n ", *includeDirs, - "\nas\n ", dirs, '\n'); - } - this->SetProperty("INCLUDE_DIRECTORIES", dirs); - } - - // Also for each target's INCLUDE_DIRECTORIES property: - for (auto& target : this->Targets) { - cmTarget& t = target.second; - if (t.GetType() == cmStateEnums::INTERFACE_LIBRARY || - t.GetType() == cmStateEnums::GLOBAL_TARGET) { - continue; - } - includeDirs = t.GetProperty("INCLUDE_DIRECTORIES"); - if (includeDirs && mightExpandVariablesCMP0019(includeDirs->c_str())) { - std::string dirs = *includeDirs; - this->ExpandVariablesInString(dirs, true, true); - if (pol == cmPolicies::WARN && dirs != *includeDirs) { - e += cmStrCat("Evaluated target ", t.GetName(), - " INCLUDE_DIRECTORIES\n ", *includeDirs, "\nas\n ", - dirs, '\n'); - } - t.SetProperty("INCLUDE_DIRECTORIES", dirs); - } - } - - if (cmValue linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) { - if (mightExpandVariablesCMP0019(linkDirsProp->c_str())) { - std::string d = *linkDirsProp; - const std::string orig = d; - this->ExpandVariablesInString(d, true, true); - if (pol == cmPolicies::WARN && d != orig) { - e += cmStrCat("Evaluated link directories\n ", orig, "\nas\n ", d, - '\n'); - } - } - } - - if (cmValue linkLibsProp = this->GetProperty("LINK_LIBRARIES")) { - cmList linkLibs{ *linkLibsProp }; - - for (auto l = linkLibs.begin(); l != linkLibs.end(); ++l) { - std::string libName = *l; - if (libName == "optimized"_s || libName == "debug"_s) { - ++l; - libName = *l; - } - if (mightExpandVariablesCMP0019(libName.c_str())) { - const std::string orig = libName; - this->ExpandVariablesInString(libName, true, true); - if (pol == cmPolicies::WARN && libName != orig) { - e += cmStrCat("Evaluated link library\n ", orig, "\nas\n ", - libName, '\n'); - } - } - } - } - - if (!e.empty()) { - auto m = cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0019), - "\n" - "The following variable evaluations were encountered:\n", - e); - this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING, m, - this->Backtrace); - } -} - bool cmMakefile::IsOn(const std::string& name) const { return this->GetDefinition(name).IsOn(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 620917f2c4..4a7650b0b0 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -717,11 +717,6 @@ public: */ void RemoveVariablesInString(std::string& source, bool atOnly = false) const; - /** - * Expand variables in the makefiles ivars such as link directories etc - */ - void ExpandVariablesCMP0019(); - /** * Replace variables and #cmakedefine lines in the given string. * See cmConfigureFileCommand for details. diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 1a840ad7bd..0f4275ad43 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -69,7 +69,7 @@ class cmMakefile; "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) \ + 11, NEW) \ SELECT(POLICY, CMP0020, \ "Automatically link Qt executables to qtmain target on Windows.", 2, \ 8, 11, WARN) \ diff --git a/Tests/RunCMake/CMP0019/CMP0019-NEW.cmake b/Tests/RunCMake/CMP0019/CMP0019-NEW.cmake index 3091e66ac7..a419f309e3 100644 --- a/Tests/RunCMake/CMP0019/CMP0019-NEW.cmake +++ b/Tests/RunCMake/CMP0019/CMP0019-NEW.cmake @@ -1,2 +1 @@ -cmake_policy(SET CMP0019 NEW) include(CMP0019-code.cmake) diff --git a/Tests/RunCMake/CMP0019/CMP0019-OLD-stderr.txt b/Tests/RunCMake/CMP0019/CMP0019-OLD-stderr.txt deleted file mode 100644 index dc0341453a..0000000000 --- a/Tests/RunCMake/CMP0019/CMP0019-OLD-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -^CMake Deprecation Warning at CMP0019-OLD\.cmake:[0-9]+ \(cmake_policy\): - The OLD behavior for policy CMP0019 will be removed from a future version - of CMake\. - - The cmake-policies\(7\) manual explains that the OLD behaviors of all - policies are deprecated and that a policy should be set to OLD only under - specific short-term circumstances. Projects should be ported to the NEW - behavior and not rely on setting a policy to OLD. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0019/CMP0019-OLD.cmake b/Tests/RunCMake/CMP0019/CMP0019-OLD.cmake deleted file mode 100644 index 0f02f9ce57..0000000000 --- a/Tests/RunCMake/CMP0019/CMP0019-OLD.cmake +++ /dev/null @@ -1,2 +0,0 @@ -cmake_policy(SET CMP0019 OLD) -include(CMP0019-code.cmake) diff --git a/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt b/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt deleted file mode 100644 index 6eee437b2e..0000000000 --- a/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt +++ /dev/null @@ -1,40 +0,0 @@ -^CMake Warning \(dev\) in CMakeLists\.txt: - Policy CMP0019 is not set: Do not re-expand variables in include and link - information. Run "cmake --help-policy CMP0019" for policy details. Use - the cmake_policy command to set the policy and suppress this warning. - - The following variable evaluations were encountered: - - Evaluated directory INCLUDE_DIRECTORIES - - /usr/include/\${VAR_INCLUDE};/usr/include/normal - - as - - /usr/include/VAL_INCLUDE;/usr/include/normal - - Evaluated target some_target INCLUDE_DIRECTORIES - - /usr/include/\${VAR_INCLUDE};/usr/include/normal - - as - - /usr/include/VAL_INCLUDE;/usr/include/normal - - Evaluated link directories - - /usr/lib/\${VAR_LINK_DIRS};/usr/lib/normal - - as - - /usr/lib/VAL_LINK_DIRS;/usr/lib/normal - - Evaluated link library - - \${VAR_LINK_LIBS} - - as - - VAL_LINK_LIBS - -This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0019/CMP0019-WARN.cmake b/Tests/RunCMake/CMP0019/CMP0019-WARN.cmake deleted file mode 100644 index a419f309e3..0000000000 --- a/Tests/RunCMake/CMP0019/CMP0019-WARN.cmake +++ /dev/null @@ -1 +0,0 @@ -include(CMP0019-code.cmake) diff --git a/Tests/RunCMake/CMP0019/CMakeLists.txt b/Tests/RunCMake/CMP0019/CMakeLists.txt index 129b75c0ab..bf2ef1506e 100644 --- a/Tests/RunCMake/CMP0019/CMakeLists.txt +++ b/Tests/RunCMake/CMP0019/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.10) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} NONE) -include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0019/RunCMakeTest.cmake b/Tests/RunCMake/CMP0019/RunCMakeTest.cmake index fcd080ff4a..a6b4527c44 100644 --- a/Tests/RunCMake/CMP0019/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0019/RunCMakeTest.cmake @@ -1,6 +1,3 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) -run_cmake(CMP0019-WARN) -run_cmake(CMP0019-OLD) run_cmake(CMP0019-NEW)