diff options
author | Brad King <brad.king@kitware.com> | 2017-10-31 12:19:21 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-10-31 12:19:27 (GMT) |
commit | 6341596e2996a86d58deeb3469c8a82c21c84b8f (patch) | |
tree | 93657887d12184858efc6f3e7d7743c8489e119e /Tests | |
parent | 8c6fa52515a0d3ad9190f6f6cb9e00ce564a7012 (diff) | |
parent | ae5f40696ef6efc62b663457b72184f682a23fe2 (diff) | |
download | CMake-6341596e2996a86d58deeb3469c8a82c21c84b8f.zip CMake-6341596e2996a86d58deeb3469c8a82c21c84b8f.tar.gz CMake-6341596e2996a86d58deeb3469c8a82c21c84b8f.tar.bz2 |
Merge topic 'cmp0037-conditional-targets'
ae5f4069 CMP0037: Allow test and package targets when features are not enabled
409527a0 CMP0037: De-duplicate check and message generation
a2611d81 Tests: Add RunCMake.CMP0037 case for WARN on reserved targets
103501c4 Tests: Do not enable languages in all cases of RunCMake.CMP0037
2d0b3e6e cmGlobalGenerator: Refactor test and package target conditions
Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !1417
Diffstat (limited to 'Tests')
33 files changed, 173 insertions, 8 deletions
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake index f4c070d..fd56e75 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 NEW) add_library("lib:colon" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake index e9f6404..83a7119 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 NEW) add_library(all empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake index 9227986..2a288cc 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 NEW) add_library("lib with spaces" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake index 870a286..f52e4d2 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 OLD) add_library(all empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake index 46193a1..c9fb6c8 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 OLD) add_library("lib with spaces" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake index 445e3b2..1b1a405 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) add_library("lib:colon" empty.cpp) add_executable("exe:colon" empty.cpp) add_custom_target("custom:colon") diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved-stderr.txt new file mode 100644 index 0000000..2d556a7 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved-stderr.txt @@ -0,0 +1,36 @@ +CMake Warning \(dev\) at CMP0037-WARN-reserved.cmake:2 \(add_library\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "all" is reserved or not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-reserved.cmake:3 \(add_executable\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "clean" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-reserved.cmake:4 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "help" is reserved or not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved.cmake new file mode 100644 index 0000000..a5e0f10 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) +add_library(all empty.cpp) +add_executable(clean empty.cpp) +add_custom_target(help) diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake index e50a64d..e01b8e5 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) add_library("lib with spaces" empty.cpp) add_executable("exe with spaces" empty.cpp) add_custom_target("custom with spaces") diff --git a/Tests/RunCMake/CMP0037/CMakeLists.txt b/Tests/RunCMake/CMP0037/CMakeLists.txt index f452db1..12cd3c7 100644 --- a/Tests/RunCMake/CMP0037/CMakeLists.txt +++ b/Tests/RunCMake/CMP0037/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 2.8.4) -project(${RunCMake_TEST} CXX) +project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package-result.txt b/Tests/RunCMake/CMP0037/NEW-cond-package-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-package-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package-stderr.txt b/Tests/RunCMake/CMP0037/NEW-cond-package-stderr.txt new file mode 100644 index 0000000..270fa6d --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-package-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at NEW-cond-package.cmake:4 \(add_custom_target\): + The target name "package" is reserved when CPack packaging is enabled. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package.cmake b/Tests/RunCMake/CMP0037/NEW-cond-package.cmake new file mode 100644 index 0000000..ceea907 --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-package.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0037 NEW) +file(WRITE "${CMAKE_BINARY_DIR}/CPackConfig.cmake" "") +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package_source-result.txt b/Tests/RunCMake/CMP0037/NEW-cond-package_source-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-package_source-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package_source-stderr.txt b/Tests/RunCMake/CMP0037/NEW-cond-package_source-stderr.txt new file mode 100644 index 0000000..2d32147 --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-package_source-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at NEW-cond-package_source.cmake:5 \(add_custom_target\): + The target name "package_source" is reserved when CPack source packaging is + enabled. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package_source.cmake b/Tests/RunCMake/CMP0037/NEW-cond-package_source.cmake new file mode 100644 index 0000000..3f8883b --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-package_source.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0037 NEW) +file(WRITE "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake" "") +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/NEW-cond-test-result.txt b/Tests/RunCMake/CMP0037/NEW-cond-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/NEW-cond-test-stderr.txt b/Tests/RunCMake/CMP0037/NEW-cond-test-stderr.txt new file mode 100644 index 0000000..44b4741 --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at NEW-cond-test.cmake:3 \(add_custom_target\): + The target name "test" is reserved when CTest testing is enabled. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0037/NEW-cond-test.cmake b/Tests/RunCMake/CMP0037/NEW-cond-test.cmake new file mode 100644 index 0000000..7eeaffc --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond-test.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0037 NEW) +enable_testing() +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/NEW-cond.cmake b/Tests/RunCMake/CMP0037/NEW-cond.cmake new file mode 100644 index 0000000..d0dc77af --- /dev/null +++ b/Tests/RunCMake/CMP0037/NEW-cond.cmake @@ -0,0 +1,4 @@ +cmake_policy(SET CMP0037 NEW) +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/OLD-cond-package.cmake b/Tests/RunCMake/CMP0037/OLD-cond-package.cmake new file mode 100644 index 0000000..7a0afbe --- /dev/null +++ b/Tests/RunCMake/CMP0037/OLD-cond-package.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0037 OLD) +file(WRITE "${CMAKE_BINARY_DIR}/CPackConfig.cmake" "") +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/OLD-cond-package_source.cmake b/Tests/RunCMake/CMP0037/OLD-cond-package_source.cmake new file mode 100644 index 0000000..95616b6 --- /dev/null +++ b/Tests/RunCMake/CMP0037/OLD-cond-package_source.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0037 OLD) +file(WRITE "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake" "") +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/OLD-cond-test.cmake b/Tests/RunCMake/CMP0037/OLD-cond-test.cmake new file mode 100644 index 0000000..bfa32a9 --- /dev/null +++ b/Tests/RunCMake/CMP0037/OLD-cond-test.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0037 OLD) +enable_testing() +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/OLD-cond.cmake b/Tests/RunCMake/CMP0037/OLD-cond.cmake new file mode 100644 index 0000000..abad680 --- /dev/null +++ b/Tests/RunCMake/CMP0037/OLD-cond.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0037 OLD) + +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake index b7d8d7b..98274f0 100644 --- a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake @@ -9,5 +9,22 @@ if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make")) run_cmake(CMP0037-WARN-colon) endif() +run_cmake(CMP0037-WARN-reserved) run_cmake(CMP0037-OLD-reserved) run_cmake(CMP0037-NEW-reserved) + +run_cmake(NEW-cond) +run_cmake(NEW-cond-test) +run_cmake(NEW-cond-package) +run_cmake(OLD-cond) +run_cmake(OLD-cond-test) +run_cmake(OLD-cond-package) +run_cmake(WARN-cond) +run_cmake(WARN-cond-test) +run_cmake(WARN-cond-package) + +if(RunCMake_GENERATOR MATCHES "Make|Ninja") + run_cmake(NEW-cond-package_source) + run_cmake(OLD-cond-package_source) + run_cmake(WARN-cond-package_source) +endif() diff --git a/Tests/RunCMake/CMP0037/WARN-cond-package-stderr.txt b/Tests/RunCMake/CMP0037/WARN-cond-package-stderr.txt new file mode 100644 index 0000000..5960e51 --- /dev/null +++ b/Tests/RunCMake/CMP0037/WARN-cond-package-stderr.txt @@ -0,0 +1,11 @@ +^CMake Warning \(dev\) at WARN-cond-package.cmake:4 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "package" is reserved when CPack packaging is enabled. It + may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0037/WARN-cond-package.cmake b/Tests/RunCMake/CMP0037/WARN-cond-package.cmake new file mode 100644 index 0000000..61cdc68 --- /dev/null +++ b/Tests/RunCMake/CMP0037/WARN-cond-package.cmake @@ -0,0 +1,5 @@ + +file(WRITE "${CMAKE_BINARY_DIR}/CPackConfig.cmake" "") +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/WARN-cond-package_source-stderr.txt b/Tests/RunCMake/CMP0037/WARN-cond-package_source-stderr.txt new file mode 100644 index 0000000..ae72909 --- /dev/null +++ b/Tests/RunCMake/CMP0037/WARN-cond-package_source-stderr.txt @@ -0,0 +1,11 @@ +^CMake Warning \(dev\) at WARN-cond-package_source.cmake:5 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "package_source" is reserved when CPack source packaging is + enabled. It may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0037/WARN-cond-package_source.cmake b/Tests/RunCMake/CMP0037/WARN-cond-package_source.cmake new file mode 100644 index 0000000..468380c --- /dev/null +++ b/Tests/RunCMake/CMP0037/WARN-cond-package_source.cmake @@ -0,0 +1,5 @@ + +file(WRITE "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake" "") +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/WARN-cond-test-stderr.txt b/Tests/RunCMake/CMP0037/WARN-cond-test-stderr.txt new file mode 100644 index 0000000..e7a3ee5 --- /dev/null +++ b/Tests/RunCMake/CMP0037/WARN-cond-test-stderr.txt @@ -0,0 +1,11 @@ +^CMake Warning \(dev\) at WARN-cond-test.cmake:3 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "test" is reserved when CTest testing is enabled. It may + result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0037/WARN-cond-test.cmake b/Tests/RunCMake/CMP0037/WARN-cond-test.cmake new file mode 100644 index 0000000..982af36 --- /dev/null +++ b/Tests/RunCMake/CMP0037/WARN-cond-test.cmake @@ -0,0 +1,5 @@ + +enable_testing() +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/CMP0037/WARN-cond.cmake b/Tests/RunCMake/CMP0037/WARN-cond.cmake new file mode 100644 index 0000000..04a7f9d --- /dev/null +++ b/Tests/RunCMake/CMP0037/WARN-cond.cmake @@ -0,0 +1,4 @@ + +add_custom_target(test) +add_custom_target(package) +add_custom_target(package_source) diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 5f6be87..8d5139d 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -12,6 +12,7 @@ \* CMP0021 \* CMP0022 \* CMP0027 + \* CMP0037 \* CMP0038 \* CMP0041 \* CMP0042 |