mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 04:40:18 -05:00
CMP0049: Remove support for OLD behavior
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
CMP0049
|
CMP0049
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
|
||||||
|
.. include:: REMOVED_PROLOGUE.txt
|
||||||
|
|
||||||
Do not expand variables in target source entries.
|
Do not expand variables in target source entries.
|
||||||
|
|
||||||
CMake 2.8.12 and lower performed an extra layer of variable expansion
|
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.
|
if such variables need to be expanded.
|
||||||
|
|
||||||
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.0
|
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.0
|
||||||
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
|
.. |WARNED_OR_DID_NOT_WARN| replace:: warned
|
||||||
.. include:: STANDARD_ADVICE.txt
|
.. include:: REMOVED_EPILOGUE.txt
|
||||||
|
|
||||||
.. include:: DEPRECATED.txt
|
|
||||||
|
|||||||
+1
-1
@@ -147,7 +147,7 @@ class cmMakefile;
|
|||||||
SELECT(POLICY, CMP0048, "project() command manages VERSION variables.", 3, \
|
SELECT(POLICY, CMP0048, "project() command manages VERSION variables.", 3, \
|
||||||
0, 0, NEW) \
|
0, 0, NEW) \
|
||||||
SELECT(POLICY, CMP0049, \
|
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.", \
|
SELECT(POLICY, CMP0050, "Disallow add_custom_command SOURCE signatures.", \
|
||||||
3, 0, 0, WARN) \
|
3, 0, 0, WARN) \
|
||||||
SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.", \
|
SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.", \
|
||||||
|
|||||||
+1
-50
@@ -682,8 +682,6 @@ public:
|
|||||||
bool CheckImportedLibName(std::string const& prop,
|
bool CheckImportedLibName(std::string const& prop,
|
||||||
std::string const& value) const;
|
std::string const& value) const;
|
||||||
|
|
||||||
std::string ProcessSourceItemCMP0049(const std::string& s) const;
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
void AddDirectoryToFileSet(cmTarget* self, std::string const& fileSetName,
|
void AddDirectoryToFileSet(cmTarget* self, std::string const& fileSetName,
|
||||||
ValueType value, cm::string_view fileSetType,
|
ValueType value, cm::string_view fileSetType,
|
||||||
@@ -1368,14 +1366,8 @@ void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
|
|||||||
void cmTarget::AddSources(std::vector<std::string> const& srcs)
|
void cmTarget::AddSources(std::vector<std::string> const& srcs)
|
||||||
{
|
{
|
||||||
std::vector<std::string> srcFiles;
|
std::vector<std::string> srcFiles;
|
||||||
for (auto filename : srcs) {
|
for (std::string const& filename : srcs) {
|
||||||
if (!cmGeneratorExpression::StartsWithGeneratorExpression(filename)) {
|
if (!cmGeneratorExpression::StartsWithGeneratorExpression(filename)) {
|
||||||
if (!filename.empty()) {
|
|
||||||
filename = this->impl->ProcessSourceItemCMP0049(filename);
|
|
||||||
if (filename.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->impl->Makefile->GetOrCreateSource(filename);
|
this->impl->Makefile->GetOrCreateSource(filename);
|
||||||
}
|
}
|
||||||
srcFiles.emplace_back(filename);
|
srcFiles.emplace_back(filename);
|
||||||
@@ -1383,47 +1375,6 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
|
|||||||
this->AddTracedSources(srcFiles);
|
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
|
struct CreateLocation
|
||||||
{
|
{
|
||||||
cmMakefile const* Makefile;
|
cmMakefile const* Makefile;
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ public:
|
|||||||
//! Add sources to the target.
|
//! Add sources to the target.
|
||||||
void AddSources(std::vector<std::string> const& srcs);
|
void AddSources(std::vector<std::string> const& srcs);
|
||||||
void AddTracedSources(std::vector<std::string> const& srcs);
|
void AddTracedSources(std::vector<std::string> const& srcs);
|
||||||
std::string GetSourceCMP0049(const std::string& src);
|
|
||||||
cmSourceFile* AddSource(const std::string& src, bool before = false);
|
cmSourceFile* AddSource(const std::string& src, bool before = false);
|
||||||
|
|
||||||
//! how we identify a library, by name and type
|
//! how we identify a library, by name and type
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
CMake Error at CMP0049-NEW.cmake:5 \(add_library\):
|
CMake Error at CMP0049-NEW.cmake:[0-9]+ \(add_library\):
|
||||||
Legacy variable expansion in source file "\${tgt_srcs}" expanded to
|
Cannot find source file:
|
||||||
"empty.cpp" in target "tgt". This behavior will be removed in a future
|
|
||||||
version of CMake.
|
\${tgt_srcs}
|
||||||
Call Stack \(most recent call first\):
|
|
||||||
|
Tried extensions ([^
|
||||||
|
]+
|
||||||
|
)+Call Stack \(most recent call first\):
|
||||||
CMakeLists.txt:3 \(include\)
|
CMakeLists.txt:3 \(include\)
|
||||||
|
|||||||
@@ -1,5 +1,2 @@
|
|||||||
|
|
||||||
cmake_policy(SET CMP0049 NEW)
|
|
||||||
|
|
||||||
set(tgt_srcs empty.cpp)
|
set(tgt_srcs empty.cpp)
|
||||||
add_library(tgt \${tgt_srcs})
|
add_library(tgt \${tgt_srcs})
|
||||||
|
|||||||
@@ -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\)$
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
cmake_policy(SET CMP0049 OLD)
|
|
||||||
|
|
||||||
set(tgt_srcs empty.cpp)
|
|
||||||
add_library(tgt \${tgt_srcs})
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
0
|
|
||||||
@@ -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.
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
set(tgt_srcs empty.cpp)
|
|
||||||
add_library(tgt \${tgt_srcs})
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(${RunCMake_TEST} CXX)
|
project(${RunCMake_TEST} CXX)
|
||||||
include(${RunCMake_TEST}.cmake)
|
include(${RunCMake_TEST}.cmake)
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
|
|
||||||
|
|
||||||
run_cmake(CMP0049-OLD)
|
|
||||||
run_cmake(CMP0049-NEW)
|
run_cmake(CMP0049-NEW)
|
||||||
run_cmake(CMP0049-WARN)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user