Revert "add_custom_command: Diagnose MAIN_DEPENDENCY limitation."

This reverts commit 242c3966 (add_custom_command: Diagnose
MAIN_DEPENDENCY limitation, 2015-03-09) and the follow up commit
b372a99a (UseSWIG: Do not use MAIN_DEPENDENCY on custom commands,
2015-03-26).

I misdiagnosed the underlying issue that prompted creation of policy CMP0057.
The actual issue surfaces when a single custom command's MAIN_DEPENDENCY
is listed in more than one target; this issue will have to be addressed
independently.
This commit is contained in:
Nils Gladitz 2015-04-29 15:09:24 +02:00 committed by Brad King
parent d1a74bba1b
commit 32a2f41402
17 changed files with 3 additions and 129 deletions

View File

@ -1,21 +1,4 @@
CMP0057 CMP0057
------- -------
Disallow multiple ``MAIN_DEPENDENCY`` specifications for the same file. This policy is reserved for future use.
CMake 3.3 and above no longer allow the same input file to be used
as a ``MAIN_DEPENDENCY`` in more than one custom command.
Listing the same input file more than once in this context has not been
supported by earlier versions either and would lead to build time issues
but was not diagnosed.
The ``OLD`` behavior for this policy is to allow using the same input file
in a ``MAIN_DEPENDENCY`` specfication more than once.
The ``NEW`` behavior is to disallow using the same input file in a
``MAIN_DEPENDENCY`` specification more than once.
This policy was introduced in CMake version 3.3.
CMake version |release| warns when the policy is not set and uses
``OLD`` behavior. Use the :command:`cmake_policy` command to set
it to ``OLD`` or ``NEW`` explicitly.

View File

@ -1,6 +0,0 @@
main_dependency_diagnostic
--------------------------
* Listing the same input file as a MAIN_DEPENDENCY of a custom command
can lead to broken build time behavior. This is now diagnosed.
See policy :policy:`CMP0057`.

View File

@ -204,7 +204,8 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
${swig_include_dirs} ${swig_include_dirs}
-o "${swig_generated_file_fullname}" -o "${swig_generated_file_fullname}"
"${swig_source_file_fullname}" "${swig_source_file_fullname}"
DEPENDS "${swig_source_file_fullname}" ${SWIG_MODULE_${name}_EXTRA_DEPS} MAIN_DEPENDENCY "${swig_source_file_fullname}"
DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS}
COMMENT "Swig source") COMMENT "Swig source")
set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files} set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files}
PROPERTIES GENERATED 1) PROPERTIES GENERATED 1)

View File

@ -877,33 +877,6 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
} }
else else
{ {
std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
bool issueMessage = false;
switch(this->GetPolicyStatus(cmPolicies::CMP0057))
{
case cmPolicies::WARN:
e << (this->GetPolicies()->
GetPolicyWarning(cmPolicies::CMP0057)) << "\n";
issueMessage = true;
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
issueMessage = true;
messageType = cmake::FATAL_ERROR;
break;
}
if(issueMessage)
{
e << "\"" << main_dependency << "\" can only be specified as a "
"custom command MAIN_DEPENDENCY once.";
IssueMessage(messageType, e.str());
}
// The existing custom command is different. We need to // The existing custom command is different. We need to
// generate a rule file for this new command. // generate a rule file for this new command.
file = 0; file = 0;

View File

@ -376,11 +376,6 @@ cmPolicies::cmPolicies()
"Honor link flags in try_compile() source-file signature.", "Honor link flags in try_compile() source-file signature.",
3,2,0, cmPolicies::WARN); 3,2,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0057, "CMP0057",
"Disallow multiple MAIN_DEPENDENCY specifications for the same file.",
3,3,0, cmPolicies::WARN);
this->DefinePolicy( this->DefinePolicy(
CMP0058, "CMP0058", CMP0058, "CMP0058",
"Ninja requires custom command byproducts to be explicit.", "Ninja requires custom command byproducts to be explicit.",

View File

@ -113,8 +113,6 @@ public:
/// or keywords when unquoted. /// or keywords when unquoted.
CMP0055, ///< Strict checking for break() command. CMP0055, ///< Strict checking for break() command.
CMP0056, ///< Honor link flags in try_compile() source-file signature. CMP0056, ///< Honor link flags in try_compile() source-file signature.
CMP0057, ///< Disallow multiple MAIN_DEPENDENCY specifications
/// for the same file.
CMP0058, ///< Ninja requires custom command byproducts to be explicit CMP0058, ///< Ninja requires custom command byproducts to be explicit
CMP0059, ///< Do not treat ``DEFINITIONS`` as a built-in directory CMP0059, ///< Do not treat ``DEFINITIONS`` as a built-in directory
/// property. /// property.

View File

@ -1 +0,0 @@
1

View File

@ -1,4 +0,0 @@
CMake Error at CMP0057-NEW.cmake:8 \(add_custom_command\):
"input.txt" can only be specified as a custom command MAIN_DEPENDENCY once.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -1,13 +0,0 @@
cmake_policy(SET CMP0057 NEW)
add_custom_command(OUTPUT out1
COMMAND ${CMAKE_COMMAND} -E echo out1
MAIN_DEPENDENCY input.txt
)
add_custom_command(OUTPUT out2
COMMAND ${CMAKE_COMMAND} -E echo out2
MAIN_DEPENDENCY input.txt
)
add_custom_target(mytarget1 ALL DEPENDS out1 out2)

View File

@ -1,13 +0,0 @@
cmake_policy(SET CMP0057 OLD)
add_custom_command(OUTPUT out1
COMMAND ${CMAKE_COMMAND} -E echo out1
MAIN_DEPENDENCY input.txt
)
add_custom_command(OUTPUT out2
COMMAND ${CMAKE_COMMAND} -E echo out2
MAIN_DEPENDENCY input.txt
)
add_custom_target(mytarget1 ALL DEPENDS out1 out2)

View File

@ -1,9 +0,0 @@
CMake Warning \(dev\) at CMP0057-WARN.cmake:6 \(add_custom_command\):
Policy CMP0057 is not set: Disallow multiple MAIN_DEPENDENCY specifications
for the same file. Run "cmake --help-policy CMP0057" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
"input.txt" can only be specified as a custom command MAIN_DEPENDENCY once.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,11 +0,0 @@
add_custom_command(OUTPUT out1
COMMAND ${CMAKE_COMMAND} -E echo out1
MAIN_DEPENDENCY input.txt
)
add_custom_command(OUTPUT out2
COMMAND ${CMAKE_COMMAND} -E echo out2
MAIN_DEPENDENCY input.txt
)
add_custom_target(mytarget1 ALL DEPENDS out1 out2)

View File

@ -1,8 +0,0 @@
cmake_policy(SET CMP0057 NEW)
add_custom_command(OUTPUT out1
COMMAND ${CMAKE_COMMAND} -E echo out1
MAIN_DEPENDENCY input.txt
)
add_custom_target(mytarget1 ALL DEPENDS out1)

View File

@ -1,3 +0,0 @@
cmake_minimum_required(VERSION 3.1)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -1,7 +0,0 @@
include(RunCMake)
run_cmake(CMP0057-OLD)
run_cmake(CMP0057-NEW)
run_cmake(CMP0057-WARN)
run_cmake(CMP0057-once_is_ok)

View File

@ -63,7 +63,6 @@ add_RunCMake_test(CMP0051)
add_RunCMake_test(CMP0053) add_RunCMake_test(CMP0053)
add_RunCMake_test(CMP0054) add_RunCMake_test(CMP0054)
add_RunCMake_test(CMP0055) add_RunCMake_test(CMP0055)
add_RunCMake_test(CMP0057)
add_RunCMake_test(CMP0059) add_RunCMake_test(CMP0059)
add_RunCMake_test(CMP0060) add_RunCMake_test(CMP0060)
if(CMAKE_GENERATOR STREQUAL "Ninja") if(CMAKE_GENERATOR STREQUAL "Ninja")