mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
CMP0050: Remove support for OLD behavior
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
CMP0050
|
||||
-------
|
||||
|
||||
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
|
||||
.. include:: REMOVED_PROLOGUE.txt
|
||||
|
||||
Disallow add_custom_command SOURCE signatures.
|
||||
|
||||
CMake 2.8.12 and lower allowed a signature for :command:`add_custom_command`
|
||||
@@ -13,7 +16,5 @@ The ``OLD`` behavior for this policy is to allow the use of
|
||||
policy is to issue an error if such a signature is used.
|
||||
|
||||
.. |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
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
@@ -590,44 +589,10 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
|
||||
cc->SetImplicitDepends(implicit_depends);
|
||||
mf.AddCustomCommandToOutput(std::move(cc));
|
||||
} else {
|
||||
if (!byproducts.empty()) {
|
||||
status.SetError(
|
||||
"BYPRODUCTS may not be specified with SOURCE signatures");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uses_terminal) {
|
||||
status.SetError("USES_TERMINAL may not be used with SOURCE signatures");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool issueMessage = true;
|
||||
std::ostringstream e;
|
||||
MessageType messageType = MessageType::AUTHOR_WARNING;
|
||||
switch (mf.GetPolicyStatus(cmPolicies::CMP0050)) {
|
||||
case cmPolicies::WARN:
|
||||
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n";
|
||||
break;
|
||||
case cmPolicies::OLD:
|
||||
issueMessage = false;
|
||||
break;
|
||||
case cmPolicies::NEW:
|
||||
messageType = MessageType::FATAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (issueMessage) {
|
||||
e << "The SOURCE signatures of add_custom_command are no longer "
|
||||
"supported.";
|
||||
mf.IssueMessage(messageType, e.str());
|
||||
if (messageType == MessageType::FATAL_ERROR) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Use the old-style mode for backward compatibility.
|
||||
mf.AddCustomCommandOldStyle(target, outputs, depends, source, commandLines,
|
||||
comment);
|
||||
mf.IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"The SOURCE signatures of add_custom_command are no longer supported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1180,72 +1180,6 @@ void cmMakefile::AddCustomCommandToOutput(
|
||||
});
|
||||
}
|
||||
|
||||
void cmMakefile::AddCustomCommandOldStyle(
|
||||
const std::string& target, const std::vector<std::string>& outputs,
|
||||
const std::vector<std::string>& depends, const std::string& source,
|
||||
const cmCustomCommandLines& commandLines, const char* comment)
|
||||
{
|
||||
auto cc = cm::make_unique<cmCustomCommand>();
|
||||
cc->SetDepends(depends);
|
||||
cc->SetCommandLines(commandLines);
|
||||
cc->SetComment(comment);
|
||||
|
||||
// Translate the old-style signature to one of the new-style
|
||||
// signatures.
|
||||
if (source == target) {
|
||||
// In the old-style signature if the source and target were the
|
||||
// same then it added a post-build rule to the target. Preserve
|
||||
// this behavior.
|
||||
this->AddCustomCommandToTarget(target, cmCustomCommandType::POST_BUILD,
|
||||
std::move(cc));
|
||||
return;
|
||||
}
|
||||
|
||||
auto ti = this->Targets.find(target);
|
||||
cmTarget* t = ti != this->Targets.end() ? &ti->second : nullptr;
|
||||
|
||||
auto addRuleFileToTarget = [=](cmSourceFile* sf) {
|
||||
// If the rule was added to the source (and not a .rule file),
|
||||
// then add the source to the target to make sure the rule is
|
||||
// included.
|
||||
if (!sf->GetPropertyAsBool("__CMAKE_RULE")) {
|
||||
if (t) {
|
||||
t->AddSource(sf->ResolveFullPath());
|
||||
} else {
|
||||
cmSystemTools::Error("Attempt to add a custom rule to a target "
|
||||
"that does not exist yet for target " +
|
||||
target);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Each output must get its own copy of this rule.
|
||||
cmsys::RegularExpression sourceFiles(
|
||||
"\\.(C|M|c|c\\+\\+|cc|cpp|cxx|mpp|ixx|cppm|ccm|cxxm|c\\+\\+m|cu|m|mm|"
|
||||
"rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|"
|
||||
"hm|hpp|hxx|in|txx|inl)$");
|
||||
|
||||
// Choose whether to use a main dependency.
|
||||
if (sourceFiles.find(source)) {
|
||||
// The source looks like a real file. Use it as the main dependency.
|
||||
for (std::string const& output : outputs) {
|
||||
auto cc1 = cm::make_unique<cmCustomCommand>(*cc);
|
||||
cc1->SetOutputs(output);
|
||||
cc1->SetMainDependency(source);
|
||||
this->AddCustomCommandToOutput(std::move(cc1), addRuleFileToTarget);
|
||||
}
|
||||
} else {
|
||||
cc->AppendDepends({ source });
|
||||
|
||||
// The source may not be a real file. Do not use a main dependency.
|
||||
for (std::string const& output : outputs) {
|
||||
auto cc1 = cm::make_unique<cmCustomCommand>(*cc);
|
||||
cc1->SetOutputs(output);
|
||||
this->AddCustomCommandToOutput(std::move(cc1), addRuleFileToTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmMakefile::AppendCustomCommandToOutput(
|
||||
const std::string& output, const std::vector<std::string>& depends,
|
||||
const cmImplicitDependsList& implicit_depends,
|
||||
|
||||
@@ -235,12 +235,6 @@ public:
|
||||
void AddCustomCommandToOutput(
|
||||
std::unique_ptr<cmCustomCommand> cc,
|
||||
const CommandSourceCallback& callback = nullptr, bool replace = false);
|
||||
void AddCustomCommandOldStyle(const std::string& target,
|
||||
const std::vector<std::string>& outputs,
|
||||
const std::vector<std::string>& depends,
|
||||
const std::string& source,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
const char* comment);
|
||||
void AppendCustomCommandToOutput(
|
||||
const std::string& output, const std::vector<std::string>& depends,
|
||||
const cmImplicitDependsList& implicit_depends,
|
||||
|
||||
@@ -149,7 +149,7 @@ class cmMakefile;
|
||||
SELECT(POLICY, CMP0049, \
|
||||
"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) \
|
||||
3, 0, 0, NEW) \
|
||||
SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.", \
|
||||
3, 1, 0, WARN) \
|
||||
SELECT(POLICY, CMP0052, \
|
||||
|
||||
@@ -19,16 +19,6 @@ function(message)
|
||||
endfunction()
|
||||
message("message")
|
||||
|
||||
# It is not recommended to set a policy to OLD, but this test
|
||||
# covers the OLD behavior of some policies.
|
||||
foreach(p
|
||||
CMP0050
|
||||
)
|
||||
if(POLICY ${p})
|
||||
cmake_policy(SET ${p} OLD)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Test building without per-rule echo lines in Makefiles.
|
||||
set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
|
||||
|
||||
|
||||
@@ -110,14 +110,14 @@ set_source_files_properties(complex
|
||||
)
|
||||
set_target_properties(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG")
|
||||
add_custom_command(
|
||||
TARGET complex
|
||||
SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
|
||||
MAIN_DEPENDENCY ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
|
||||
${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||
OUTPUTS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||
OUTPUT ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||
DEPENDS ${CMAKE_COMMAND}
|
||||
)
|
||||
target_sources(complex PRIVATE ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h)
|
||||
|
||||
# Test creating an executable that is not built by default.
|
||||
add_executable(notInAllExe EXCLUDE_FROM_ALL notInAllExe.cxx)
|
||||
|
||||
@@ -12,16 +12,6 @@ string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -DCOMPLEX_NDEBUG")
|
||||
string(APPEND CMAKE_C_FLAGS_MINSIZEREL " -DCOMPLEX_NDEBUG")
|
||||
string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -DCOMPLEX_NDEBUG")
|
||||
|
||||
# It is not recommended to set a policy to OLD, but this test
|
||||
# covers the OLD behavior of some policies.
|
||||
foreach(p
|
||||
CMP0050
|
||||
)
|
||||
if(POLICY ${p})
|
||||
cmake_policy(SET ${p} OLD)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Test building without per-rule echo lines in Makefiles.
|
||||
set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
|
||||
|
||||
|
||||
@@ -110,14 +110,14 @@ set_source_files_properties(complex
|
||||
)
|
||||
set_target_properties(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG")
|
||||
add_custom_command(
|
||||
TARGET complex
|
||||
SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
|
||||
MAIN_DEPENDENCY ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
|
||||
${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||
OUTPUTS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||
OUTPUT ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||
DEPENDS ${CMAKE_COMMAND}
|
||||
)
|
||||
target_sources(complex PRIVATE ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h)
|
||||
|
||||
# Test creating an executable that is not built by default.
|
||||
add_executable(notInAllExe EXCLUDE_FROM_ALL notInAllExe.cxx)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
cmake_policy(SET CMP0050 NEW)
|
||||
|
||||
add_library(empty empty.cpp)
|
||||
add_custom_command(
|
||||
TARGET empty
|
||||
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input.h
|
||||
OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/input.h
|
||||
DEPENDS ${CMAKE_COMMAND}
|
||||
)
|
||||
@@ -1,10 +0,0 @@
|
||||
^CMake Deprecation Warning at CMP0050-OLD.cmake:2 \(cmake_policy\):
|
||||
The OLD behavior for policy CMP0050 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,13 +0,0 @@
|
||||
|
||||
cmake_policy(SET CMP0050 OLD)
|
||||
|
||||
add_library(empty empty.cpp)
|
||||
add_custom_command(
|
||||
TARGET empty
|
||||
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input.h
|
||||
OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/input.h
|
||||
DEPENDS ${CMAKE_COMMAND}
|
||||
)
|
||||
@@ -1 +0,0 @@
|
||||
0
|
||||
@@ -1,9 +0,0 @@
|
||||
CMake Warning \(dev\) at CMP0050-WARN.cmake:3 \(add_custom_command\):
|
||||
Policy CMP0050 is not set: Disallow add_custom_command SOURCE signatures.
|
||||
Run "cmake --help-policy CMP0050" for policy details. Use the cmake_policy
|
||||
command to set the policy and suppress this warning.
|
||||
|
||||
The SOURCE signatures of add_custom_command are no longer supported.
|
||||
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 @@
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(${RunCMake_TEST} CXX)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
@@ -1,6 +0,0 @@
|
||||
include(RunCMake)
|
||||
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
|
||||
|
||||
run_cmake(CMP0050-OLD)
|
||||
run_cmake(CMP0050-NEW)
|
||||
run_cmake(CMP0050-WARN)
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
#include "input.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int empty()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
#define INPUT
|
||||
@@ -113,7 +113,6 @@ endif()
|
||||
add_RunCMake_test(CMP0045)
|
||||
add_RunCMake_test(CMP0046)
|
||||
add_RunCMake_test(CMP0049)
|
||||
add_RunCMake_test(CMP0050)
|
||||
add_RunCMake_test(CMP0051)
|
||||
add_RunCMake_test(CMP0053)
|
||||
add_RunCMake_test(CMP0054)
|
||||
|
||||
@@ -16,8 +16,7 @@ run_cmake(LiteralQuotes)
|
||||
run_cmake(NoArguments)
|
||||
run_cmake(NoOutputOrTarget)
|
||||
run_cmake(OutputAndTarget)
|
||||
run_cmake(SourceByproducts)
|
||||
run_cmake(SourceUsesTerminal)
|
||||
run_cmake(SOURCE)
|
||||
run_cmake(TargetImported)
|
||||
run_cmake(TargetLiteralQuotes)
|
||||
run_cmake(TargetNotInDir)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CMake Error at CMP0050-NEW.cmake:5 \(add_custom_command\):
|
||||
CMake Error at SOURCE.cmake:[0-9]+ \(add_custom_command\):
|
||||
The SOURCE signatures of add_custom_command are no longer supported.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
add_library(empty empty.cpp)
|
||||
add_custom_command(
|
||||
TARGET empty
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,4 +0,0 @@
|
||||
CMake Error at SourceByproducts.cmake:1 \(add_custom_command\):
|
||||
add_custom_command BYPRODUCTS may not be specified with SOURCE signatures
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
@@ -1 +0,0 @@
|
||||
add_custom_command(SOURCE t TARGET t BYPRODUCTS b)
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,4 +0,0 @@
|
||||
CMake Error at SourceUsesTerminal.cmake:1 \(add_custom_command\):
|
||||
add_custom_command USES_TERMINAL may not be used with SOURCE signatures
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
@@ -1 +0,0 @@
|
||||
add_custom_command(SOURCE t TARGET t USES_TERMINAL)
|
||||
Reference in New Issue
Block a user