diff --git a/Help/policy/CMP0049.rst b/Help/policy/CMP0049.rst index d12ef8832e..c2500cd60a 100644 --- a/Help/policy/CMP0049.rst +++ b/Help/policy/CMP0049.rst @@ -1,6 +1,9 @@ CMP0049 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + Do not expand variables in target source entries. CMake 2.8.12 and lower performed an extra layer of variable expansion @@ -18,7 +21,5 @@ the target sources. The ``NEW`` behavior for this policy is to issue an error if such variables need to be expanded. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.0 -.. |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/cmPolicies.h b/Source/cmPolicies.h index 62c21f48c0..53d0683b4e 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -147,7 +147,7 @@ class cmMakefile; SELECT(POLICY, CMP0048, "project() command manages VERSION variables.", 3, \ 0, 0, NEW) \ SELECT(POLICY, CMP0049, \ - "Do not expand variables in target source entries.", 3, 0, 0, WARN) \ + "Do not expand variables in target source entries.", 3, 0, 0, NEW) \ SELECT(POLICY, CMP0050, "Disallow add_custom_command SOURCE signatures.", \ 3, 0, 0, WARN) \ SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.", \ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a95665f0f8..c75462820f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -682,8 +682,6 @@ public: bool CheckImportedLibName(std::string const& prop, std::string const& value) const; - std::string ProcessSourceItemCMP0049(const std::string& s) const; - template void AddDirectoryToFileSet(cmTarget* self, std::string const& fileSetName, ValueType value, cm::string_view fileSetType, @@ -1368,14 +1366,8 @@ void cmTarget::AddTracedSources(std::vector const& srcs) void cmTarget::AddSources(std::vector const& srcs) { std::vector srcFiles; - for (auto filename : srcs) { + for (std::string const& filename : srcs) { if (!cmGeneratorExpression::StartsWithGeneratorExpression(filename)) { - if (!filename.empty()) { - filename = this->impl->ProcessSourceItemCMP0049(filename); - if (filename.empty()) { - return; - } - } this->impl->Makefile->GetOrCreateSource(filename); } srcFiles.emplace_back(filename); @@ -1383,47 +1375,6 @@ void cmTarget::AddSources(std::vector const& srcs) this->AddTracedSources(srcFiles); } -std::string cmTargetInternals::ProcessSourceItemCMP0049( - const std::string& s) const -{ - std::string src = s; - - // For backwards compatibility replace variables in source names. - // This should eventually be removed. - this->Makefile->ExpandVariablesInString(src); - if (src != s) { - std::ostringstream e; - bool noMessage = false; - MessageType messageType = MessageType::AUTHOR_WARNING; - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0049) << "\n"; - break; - case cmPolicies::OLD: - noMessage = true; - break; - case cmPolicies::NEW: - messageType = MessageType::FATAL_ERROR; - } - if (!noMessage) { - e << "Legacy variable expansion in source file \"" << s - << "\" expanded to \"" << src << "\" in target \"" << this->Name - << "\". This behavior will be removed in a " - "future version of CMake."; - this->Makefile->IssueMessage(messageType, e.str()); - if (messageType == MessageType::FATAL_ERROR) { - return ""; - } - } - } - return src; -} - -std::string cmTarget::GetSourceCMP0049(const std::string& s) -{ - return this->impl->ProcessSourceItemCMP0049(s); -} - struct CreateLocation { cmMakefile const* Makefile; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3a515d5b50..246e184515 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -113,7 +113,6 @@ public: //! Add sources to the target. void AddSources(std::vector const& srcs); void AddTracedSources(std::vector const& srcs); - std::string GetSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src, bool before = false); //! how we identify a library, by name and type diff --git a/Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt b/Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt index ff787e8476..b22cc4e96b 100644 --- a/Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt @@ -1,6 +1,9 @@ -CMake Error at CMP0049-NEW.cmake:5 \(add_library\): - Legacy variable expansion in source file "\${tgt_srcs}" expanded to - "empty.cpp" in target "tgt". This behavior will be removed in a future - version of CMake. -Call Stack \(most recent call first\): +CMake Error at CMP0049-NEW.cmake:[0-9]+ \(add_library\): + Cannot find source file: + + \${tgt_srcs} + + Tried extensions ([^ +]+ +)+Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0049/CMP0049-NEW.cmake b/Tests/RunCMake/CMP0049/CMP0049-NEW.cmake index 85b5aa8546..ce4cded68b 100644 --- a/Tests/RunCMake/CMP0049/CMP0049-NEW.cmake +++ b/Tests/RunCMake/CMP0049/CMP0049-NEW.cmake @@ -1,5 +1,2 @@ - -cmake_policy(SET CMP0049 NEW) - set(tgt_srcs empty.cpp) add_library(tgt \${tgt_srcs}) diff --git a/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt b/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt deleted file mode 100644 index b3739705bd..0000000000 --- a/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt +++ /dev/null @@ -1,10 +0,0 @@ -^CMake Deprecation Warning at CMP0049-OLD.cmake:2 \(cmake_policy\): - The OLD behavior for policy CMP0049 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:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0049/CMP0049-OLD.cmake b/Tests/RunCMake/CMP0049/CMP0049-OLD.cmake deleted file mode 100644 index ae6fd3bcdf..0000000000 --- a/Tests/RunCMake/CMP0049/CMP0049-OLD.cmake +++ /dev/null @@ -1,5 +0,0 @@ - -cmake_policy(SET CMP0049 OLD) - -set(tgt_srcs empty.cpp) -add_library(tgt \${tgt_srcs}) diff --git a/Tests/RunCMake/CMP0049/CMP0049-WARN-result.txt b/Tests/RunCMake/CMP0049/CMP0049-WARN-result.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tests/RunCMake/CMP0049/CMP0049-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/CMP0049/CMP0049-WARN-stderr.txt b/Tests/RunCMake/CMP0049/CMP0049-WARN-stderr.txt deleted file mode 100644 index 0cf5ce354a..0000000000 --- a/Tests/RunCMake/CMP0049/CMP0049-WARN-stderr.txt +++ /dev/null @@ -1,11 +0,0 @@ -CMake Warning \(dev\) at CMP0049-WARN.cmake:3 \(add_library\): - Policy CMP0049 is not set: Do not expand variables in target source - entries. Run "cmake --help-policy CMP0049" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - Legacy variable expansion in source file "\${tgt_srcs}" expanded to - "empty.cpp" in target "tgt". This behavior will be removed in a future - version of CMake. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0049/CMP0049-WARN.cmake b/Tests/RunCMake/CMP0049/CMP0049-WARN.cmake deleted file mode 100644 index ada082e610..0000000000 --- a/Tests/RunCMake/CMP0049/CMP0049-WARN.cmake +++ /dev/null @@ -1,3 +0,0 @@ - -set(tgt_srcs empty.cpp) -add_library(tgt \${tgt_srcs}) diff --git a/Tests/RunCMake/CMP0049/CMakeLists.txt b/Tests/RunCMake/CMP0049/CMakeLists.txt index a06591c31f..c814f14935 100644 --- a/Tests/RunCMake/CMP0049/CMakeLists.txt +++ b/Tests/RunCMake/CMP0049/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0049/RunCMakeTest.cmake b/Tests/RunCMake/CMP0049/RunCMakeTest.cmake index e71f31e87b..70b2b44dd5 100644 --- a/Tests/RunCMake/CMP0049/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0049/RunCMakeTest.cmake @@ -1,6 +1,3 @@ include(RunCMake) -set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON) -run_cmake(CMP0049-OLD) run_cmake(CMP0049-NEW) -run_cmake(CMP0049-WARN)