Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
f2eee72f
Commit
f2eee72f
authored
Feb 11, 2014
by
Stephen Kelly
Committed by
Brad King
Feb 12, 2014
Browse files
add_custom_command: Disallow use of SOURCE signatures.
Add CMP0050 to control this behavior.
parent
c248a437
Changes
20
Hide whitespace changes
Inline
Side-by-side
Help/manual/cmake-policies.7.rst
View file @
f2eee72f
...
...
@@ -101,3 +101,4 @@ All Policies
/policy/CMP0047
/policy/CMP0048
/policy/CMP0049
/policy/CMP0050
Help/policy/CMP0050.rst
0 → 100644
View file @
f2eee72f
CMP0050
-------
Disallow add_custom_command SOURCE signatures.
CMake 2.8.12 and lower allowed a signature for :command:`add_custom_command`
which specified an input to a command. This was undocumented behavior.
Modern use of CMake associates custom commands with their output, rather
than their input.
The OLD behavior for this policy is to allow the use of
:command:`add_custom_command` SOURCE signatures. The NEW behavior for this
policy is to issue an error if such a signature is used.
This policy was introduced in CMake version 3.0.
CMake version |release| warns when the policy is not set and uses
OLD behavior. Use the cmake_policy command to set it to OLD or
NEW explicitly.
Help/release/3.0.rst
View file @
f2eee72f
...
...
@@ -327,6 +327,9 @@ New Diagnostics
require an undocumented extra layer of variable expansion.
See policy :policy:`CMP0049`.
* Use of :command:`add_custom_command` undocumented ``SOURCE``
signatures now results in an error. See policy :policy:`CMP0050`.
Deprecated and Removed Features
===============================
...
...
Source/cmAddCustomCommandCommand.cxx
View file @
f2eee72f
...
...
@@ -344,6 +344,36 @@ bool cmAddCustomCommandCommand
}
else
{
bool
issueMessage
=
true
;
cmOStringStream
e
;
cmake
::
MessageType
messageType
=
cmake
::
AUTHOR_WARNING
;
switch
(
this
->
Makefile
->
GetPolicyStatus
(
cmPolicies
::
CMP0050
))
{
case
cmPolicies
::
WARN
:
e
<<
(
this
->
Makefile
->
GetPolicies
()
->
GetPolicyWarning
(
cmPolicies
::
CMP0050
))
<<
"
\n
"
;
break
;
case
cmPolicies
::
OLD
:
issueMessage
=
false
;
break
;
case
cmPolicies
::
REQUIRED_ALWAYS
:
case
cmPolicies
::
REQUIRED_IF_USED
:
case
cmPolicies
::
NEW
:
messageType
=
cmake
::
FATAL_ERROR
;
break
;
}
if
(
issueMessage
)
{
e
<<
"The SOURCE signatures of add_custom_command are no longer "
"supported."
;
this
->
Makefile
->
IssueMessage
(
messageType
,
e
.
str
().
c_str
());
if
(
messageType
==
cmake
::
FATAL_ERROR
)
{
return
false
;
}
}
// Use the old-style mode for backward compatibility.
this
->
Makefile
->
AddCustomCommandOldStyle
(
target
.
c_str
(),
outputs
,
depends
,
source
.
c_str
(),
commandLines
,
...
...
Source/cmPolicies.cxx
View file @
f2eee72f
...
...
@@ -338,6 +338,11 @@ cmPolicies::cmPolicies()
CMP0049
,
"CMP0049"
,
"Do not expand variables in target source entries."
,
3
,
0
,
0
,
cmPolicies
::
WARN
);
this
->
DefinePolicy
(
CMP0050
,
"CMP0050"
,
"Disallow add_custom_command SOURCE signatures."
,
3
,
0
,
0
,
cmPolicies
::
WARN
);
}
cmPolicies
::~
cmPolicies
()
...
...
Source/cmPolicies.h
View file @
f2eee72f
...
...
@@ -103,6 +103,7 @@ public:
CMP0047
,
///< Use QCC compiler id for the qcc drivers on QNX.
CMP0048
,
///< project() command manages VERSION variables
CMP0049
,
///< Do not expand variables in target source entries
CMP0050
,
///< Disallow add_custom_command SOURCE signatures
/** \brief Always the last entry.
*
...
...
Tests/RunCMake/CMP0050/CMP0050-NEW-result.txt
0 → 100644
View file @
f2eee72f
1
Tests/RunCMake/CMP0050/CMP0050-NEW-stderr.txt
0 → 100644
View file @
f2eee72f
CMake Error at CMP0050-NEW.cmake:5 \(add_custom_command\):
The SOURCE signatures of add_custom_command are no longer supported.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
Tests/RunCMake/CMP0050/CMP0050-NEW.cmake
0 → 100644
View file @
f2eee72f
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
}
)
Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt
0 → 100644
View file @
f2eee72f
0
Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt
0 → 100644
View file @
f2eee72f
^$
Tests/RunCMake/CMP0050/CMP0050-OLD.cmake
0 → 100644
View file @
f2eee72f
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
}
)
Tests/RunCMake/CMP0050/CMP0050-WARN-result.txt
0 → 100644
View file @
f2eee72f
0
Tests/RunCMake/CMP0050/CMP0050-WARN-stderr.txt
0 → 100644
View file @
f2eee72f
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.
Tests/RunCMake/CMP0050/CMP0050-WARN.cmake
0 → 100644
View file @
f2eee72f
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
}
)
Tests/RunCMake/CMP0050/CMakeLists.txt
0 → 100644
View file @
f2eee72f
cmake_minimum_required
(
VERSION 2.8.12
)
project
(
${
RunCMake_TEST
}
CXX
)
include
(
${
RunCMake_TEST
}
.cmake NO_POLICY_SCOPE
)
Tests/RunCMake/CMP0050/RunCMakeTest.cmake
0 → 100644
View file @
f2eee72f
include
(
RunCMake
)
run_cmake
(
CMP0050-OLD
)
run_cmake
(
CMP0050-NEW
)
run_cmake
(
CMP0050-WARN
)
Tests/RunCMake/CMP0050/empty.cpp
0 → 100644
View file @
f2eee72f
#include
"input.h"
#ifdef _WIN32
__declspec
(
dllexport
)
#endif
int
empty
()
{
return
0
;
}
Tests/RunCMake/CMP0050/input.h.in
0 → 100644
View file @
f2eee72f
#define INPUT
Tests/RunCMake/CMakeLists.txt
View file @
f2eee72f
...
...
@@ -33,6 +33,7 @@ add_RunCMake_test(CMP0043)
add_RunCMake_test
(
CMP0045
)
add_RunCMake_test
(
CMP0046
)
add_RunCMake_test
(
CMP0049
)
add_RunCMake_test
(
CMP0050
)
add_RunCMake_test
(
CTest
)
if
(
UNIX AND
"
${
CMAKE_TEST_GENERATOR
}
"
MATCHES
"Unix Makefiles"
)
add_RunCMake_test
(
CompilerChange
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment