Add policy CMP0040 to disallow custom commands on missing targets

This commit is contained in:
Nils Gladitz
2013-11-20 09:53:06 +01:00
committed by Brad King
parent a61025135b
commit a02f3d2de0
24 changed files with 149 additions and 24 deletions
@@ -0,0 +1 @@
0
@@ -0,0 +1 @@
^$
@@ -0,0 +1,7 @@
cmake_policy(SET CMP0040 NEW)
add_library(foobar empty.cpp)
add_custom_command(TARGET foobar PRE_BUILD
COMMAND "${CMAKE_COMMAND} -E echo hello world"
)
@@ -0,0 +1 @@
1
@@ -0,0 +1,9 @@
CMake Error at CMP0040-NEW-missing-target.cmake:3 \(add_custom_command\):
Policy CMP0040 is not set: The target in the TARGET signature of
add_custom_command\(\) must exist. Run "cmake --help-policy CMP0040" for
policy details. Use the cmake_policy command to set the policy and
suppress this warning.
+
The target name "foobar" is unknown in this context.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
@@ -0,0 +1,5 @@
cmake_policy(SET CMP0040 NEW)
add_custom_command(TARGET foobar PRE_BUILD
COMMAND "${CMAKE_COMMAND} -E hello world"
)
@@ -0,0 +1 @@
0
@@ -0,0 +1 @@
^$
@@ -0,0 +1,7 @@
cmake_policy(SET CMP0040 OLD)
add_library(foobar empty.cpp)
add_custom_command(TARGET foobar PRE_BUILD
COMMAND "${CMAKE_COMMAND} -E echo hello world"
)
@@ -0,0 +1 @@
0
@@ -0,0 +1 @@
^$
@@ -0,0 +1,5 @@
cmake_policy(SET CMP0040 OLD)
add_custom_command(TARGET foobar PRE_BUILD
COMMAND "${CMAKE_COMMAND} -E echo hello world"
)
@@ -0,0 +1 @@
0
@@ -0,0 +1,10 @@
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. Run "cmake --help-policy CMP0040" for
policy details. Use the cmake_policy command to set the policy and
suppress this warning.
+
The target name "foobar" is unknown in this context.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
@@ -0,0 +1,4 @@
add_custom_command(TARGET foobar PRE_BUILD
COMMAND "${CMAKE_COMMAND} -E hello world"
)
+3
View File
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
project(${RunCMake_TEST} CXX)
include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
@@ -0,0 +1,8 @@
include(RunCMake)
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)
+7
View File
@@ -0,0 +1,7 @@
#ifdef _WIN32
__declspec(dllexport)
#endif
int empty()
{
return 0;
}
+1
View File
@@ -59,6 +59,7 @@ add_RunCMake_test(CMP0028)
add_RunCMake_test(CMP0037)
add_RunCMake_test(CMP0038)
add_RunCMake_test(CMP0039)
add_RunCMake_test(CMP0040)
add_RunCMake_test(CTest)
if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
add_RunCMake_test(CompilerChange)