mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
CMP0040: Remove support for OLD behavior
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
CMP0040
|
||||
-------
|
||||
|
||||
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
|
||||
.. include:: REMOVED_PROLOGUE.txt
|
||||
|
||||
The target in the ``TARGET`` signature of :command:`add_custom_command`
|
||||
must exist and must be defined in the current directory.
|
||||
|
||||
@@ -14,7 +17,5 @@ an error if the target referenced in :command:`add_custom_command` is
|
||||
unknown or was defined outside the current directory.
|
||||
|
||||
.. |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
|
||||
|
||||
@@ -1066,38 +1066,20 @@ cmTarget* cmMakefile::GetCustomCommandTarget(
|
||||
// Find the target to which to add the custom command.
|
||||
auto ti = this->Targets.find(realTarget);
|
||||
if (ti == this->Targets.end()) {
|
||||
MessageType messageType = MessageType::AUTHOR_WARNING;
|
||||
bool issueMessage = false;
|
||||
std::string e;
|
||||
switch (this->GetPolicyStatus(cmPolicies::CMP0040)) {
|
||||
case cmPolicies::WARN:
|
||||
e = cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0040), '\n');
|
||||
issueMessage = true;
|
||||
CM_FALLTHROUGH;
|
||||
case cmPolicies::OLD:
|
||||
break;
|
||||
case cmPolicies::NEW:
|
||||
issueMessage = true;
|
||||
messageType = MessageType::FATAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (issueMessage) {
|
||||
if (cmTarget const* t = this->FindTargetToUse(target)) {
|
||||
if (t->IsImported()) {
|
||||
e += cmStrCat("TARGET '", target,
|
||||
"' is IMPORTED and does not build here.");
|
||||
} else {
|
||||
e += cmStrCat("TARGET '", target,
|
||||
"' was not created in this directory.");
|
||||
}
|
||||
if (cmTarget const* t = this->FindTargetToUse(target)) {
|
||||
if (t->IsImported()) {
|
||||
e += cmStrCat("TARGET '", target,
|
||||
"' is IMPORTED and does not build here.");
|
||||
} else {
|
||||
e += cmStrCat("No TARGET '", target,
|
||||
"' has been created in this directory.");
|
||||
e +=
|
||||
cmStrCat("TARGET '", target, "' was not created in this directory.");
|
||||
}
|
||||
this->GetCMakeInstance()->IssueMessage(messageType, e, lfbt);
|
||||
} else {
|
||||
e += cmStrCat("No TARGET '", target,
|
||||
"' has been created in this directory.");
|
||||
}
|
||||
|
||||
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e, lfbt);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class cmMakefile;
|
||||
SELECT(POLICY, CMP0040, \
|
||||
"The target in the TARGET signature of add_custom_command() must " \
|
||||
"exist and must be defined in the current directory.", \
|
||||
3, 0, 0, WARN) \
|
||||
3, 0, 0, NEW) \
|
||||
SELECT(POLICY, CMP0041, \
|
||||
"Error on relative include with generator expression.", 3, 0, 0, \
|
||||
WARN) \
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
0
|
||||
@@ -1,5 +1,3 @@
|
||||
cmake_policy(SET CMP0040 NEW)
|
||||
|
||||
add_library(foobar empty.cpp)
|
||||
|
||||
add_custom_command(TARGET foobar PRE_BUILD
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CMake Error at CMP0040-NEW-missing-target.cmake:3 \(add_custom_command\):
|
||||
No TARGET 'foobar' has been created in this directory.
|
||||
^CMake Error at CMP0040-NEW-missing-target.cmake:[0-9]+ \(add_custom_command\):
|
||||
No TARGET 'foobar' has been created in this directory\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
CMakeLists\.txt:3 \(include\)$
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
cmake_policy(SET CMP0040 NEW)
|
||||
|
||||
add_custom_command(TARGET foobar PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E hello world
|
||||
)
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
^CMake Deprecation Warning at CMP0040-OLD-existing-target.cmake:1 \(cmake_policy\):
|
||||
The OLD behavior for policy CMP0040 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,7 +0,0 @@
|
||||
cmake_policy(SET CMP0040 OLD)
|
||||
|
||||
add_library(foobar empty.cpp)
|
||||
|
||||
add_custom_command(TARGET foobar PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E echo hello world
|
||||
)
|
||||
@@ -1,10 +0,0 @@
|
||||
^CMake Deprecation Warning at CMP0040-OLD-missing-target.cmake:1 \(cmake_policy\):
|
||||
The OLD behavior for policy CMP0040 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 CMP0040 OLD)
|
||||
|
||||
add_custom_command(TARGET foobar PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E echo hello world
|
||||
)
|
||||
@@ -1 +0,0 @@
|
||||
0
|
||||
@@ -1,10 +0,0 @@
|
||||
CMake Warning \(dev\) at CMP0040-WARN-missing-target.cmake:2 \(add_custom_command\):
|
||||
Policy CMP0040 is not set: The target in the TARGET signature of
|
||||
add_custom_command\(\) must exist and must be defined in the current
|
||||
directory. Run "cmake --help-policy CMP0040" for policy details. Use the
|
||||
cmake_policy command to set the policy and suppress this warning.
|
||||
+
|
||||
No TARGET 'foobar' has been created in this directory.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
add_custom_command(TARGET foobar PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E hello world
|
||||
)
|
||||
@@ -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)
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
include(RunCMake)
|
||||
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
|
||||
|
||||
run_cmake(CMP0040-OLD-missing-target)
|
||||
run_cmake(CMP0040-NEW-missing-target)
|
||||
run_cmake(CMP0040-WARN-missing-target)
|
||||
|
||||
run_cmake(CMP0040-OLD-existing-target)
|
||||
run_cmake(CMP0040-NEW-existing-target)
|
||||
|
||||
Reference in New Issue
Block a user