diff options
author | Brad King <brad.king@kitware.com> | 2014-01-09 14:37:20 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-01-09 14:37:20 (GMT) |
commit | 15562c11efa3c3a9e0f28f9ad52b71623c254b05 (patch) | |
tree | 24dfd93e75c0fb8bf618394d379d45cf2f458c49 /Tests | |
parent | 69c366a28178027a5cf2629c0240d1709ae9ab55 (diff) | |
parent | 73e93400e2efab2096618ff58a5ad68236cd04aa (diff) | |
download | CMake-15562c11efa3c3a9e0f28f9ad52b71623c254b05.zip CMake-15562c11efa3c3a9e0f28f9ad52b71623c254b05.tar.gz CMake-15562c11efa3c3a9e0f28f9ad52b71623c254b05.tar.bz2 |
Merge topic 'policies'
73e9340 get_target_property: Error on non-existent target.
ab9f58f FindQt4: Ensure target exists before calling get_target_property.
37ebeb9 FindQt4: Fix use of get_target_property to use actual target name.
6aabb6a Genex: Use case-sensitive comparison for COMPILER_ID.
5bb53f6 cmTarget: Deprecate COMPILE_DEFINITIONS_ properties with a policy.
Diffstat (limited to 'Tests')
34 files changed, 178 insertions, 0 deletions
diff --git a/Tests/CompileDefinitions/compiletest.c b/Tests/CompileDefinitions/compiletest.c index d7883af..8871750 100644 --- a/Tests/CompileDefinitions/compiletest.c +++ b/Tests/CompileDefinitions/compiletest.c @@ -13,6 +13,10 @@ #error Unexpected LINK_LANGUAGE_IS_CXX #endif +#ifdef DEBUG_MODE +#error Unexpected DEBUG_MODE +#endif + int main(void) { return 0; diff --git a/Tests/CompileDefinitions/target_prop/CMakeLists.txt b/Tests/CompileDefinitions/target_prop/CMakeLists.txt index a0d3f4e..2ca2869 100644 --- a/Tests/CompileDefinitions/target_prop/CMakeLists.txt +++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt @@ -35,6 +35,9 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS add_executable(target_prop_c_executable ../compiletest.c) +cmake_policy(SET CMP0043 NEW) +set_property(TARGET target_prop_c_executable APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG_MODE) + set_property(TARGET target_prop_c_executable APPEND PROPERTY COMPILE_DEFINITIONS "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>" "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>" diff --git a/Tests/GeneratorExpression/CMP0044/CMakeLists.txt b/Tests/GeneratorExpression/CMP0044/CMakeLists.txt new file mode 100644 index 0000000..309a8cc --- /dev/null +++ b/Tests/GeneratorExpression/CMP0044/CMakeLists.txt @@ -0,0 +1,19 @@ + +string(TOLOWER ${CMAKE_C_COMPILER_ID} lc_test) +if (lc_test STREQUAL CMAKE_C_COMPILER_ID) + string(TOUPPER ${CMAKE_C_COMPILER_ID} lc_test) + if (lc_test STREQUAL CMAKE_C_COMPILER_ID) + message(SEND_ERROR "Try harder.") + endif() +endif() + +if (CMP0044_TYPE) + cmake_policy(SET CMP0044 ${CMP0044_TYPE}) +endif() + +add_library(cmp0044-check-${CMP0044_TYPE} cmp0044-check.cpp) +target_compile_definitions(cmp0044-check-${CMP0044_TYPE} + PRIVATE + Result=$<C_COMPILER_ID:${lc_test}> + Type_Is_${CMP0044_TYPE} +) diff --git a/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp new file mode 100644 index 0000000..2356bc4 --- /dev/null +++ b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp @@ -0,0 +1,26 @@ + +#ifdef Type_Is_ +# if !Result +# error Result should be 1 in WARN mode +# endif +#endif + +#ifdef Type_Is_NEW +# if Result +# error Result should be 0 in NEW mode +# endif +#endif + +#ifdef Type_Is_OLD +# if !Result +# error Result should be 1 in OLD mode +# endif +#endif + +#if !defined(Type_Is_) && !defined(Type_Is_OLD) && !defined(Type_Is_NEW) +#error No expected definition present +#endif + +void foo(void) +{ +} diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 3b85dc3..a0e34ef 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -252,3 +252,9 @@ endforeach() add_test(echo-old-style echo "\$<CONFIGURATION>") set_property(TEST echo-old-style PROPERTY PASS_REGULAR_EXPRESSION "^\\$<CONFIGURATION>\n$") + +add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-WARN) +set(CMP0044_TYPE NEW) +add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-NEW) +set(CMP0044_TYPE OLD) +add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-OLD) diff --git a/Tests/RunCMake/CMP0043/CMP0043-NEW-result.txt b/Tests/RunCMake/CMP0043/CMP0043-NEW-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-NEW-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0043/CMP0043-NEW-stderr.txt b/Tests/RunCMake/CMP0043/CMP0043-NEW-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-NEW-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0043/CMP0043-NEW.cmake b/Tests/RunCMake/CMP0043/CMP0043-NEW.cmake new file mode 100644 index 0000000..857153d --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-NEW.cmake @@ -0,0 +1,7 @@ + +cmake_policy(SET CMP0043 NEW) + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY COMPILE_DEFINITIONS_DEBUG "DEBUG_MODE" +) diff --git a/Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt b/Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt b/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0043/CMP0043-OLD.cmake b/Tests/RunCMake/CMP0043/CMP0043-OLD.cmake new file mode 100644 index 0000000..f379430 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-OLD.cmake @@ -0,0 +1,7 @@ + +cmake_policy(SET CMP0043 OLD) + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY COMPILE_DEFINITIONS_DEBUG "DEBUG_MODE" +) diff --git a/Tests/RunCMake/CMP0043/CMP0043-WARN-result.txt b/Tests/RunCMake/CMP0043/CMP0043-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0043/CMP0043-WARN-stderr.txt b/Tests/RunCMake/CMP0043/CMP0043-WARN-stderr.txt new file mode 100644 index 0000000..4769a63 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-WARN-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties. + Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0043/CMP0043-WARN.cmake b/Tests/RunCMake/CMP0043/CMP0043-WARN.cmake new file mode 100644 index 0000000..161a60d --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-WARN.cmake @@ -0,0 +1,5 @@ + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY COMPILE_DEFINITIONS_DEBUG "DEBUG_MODE" +) diff --git a/Tests/RunCMake/CMP0043/CMakeLists.txt b/Tests/RunCMake/CMP0043/CMakeLists.txt new file mode 100644 index 0000000..b465c88 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) + +if(CMAKE_BUILD_TYPE) + # Dummy variable use +endif() diff --git a/Tests/RunCMake/CMP0043/RunCMakeTest.cmake b/Tests/RunCMake/CMP0043/RunCMakeTest.cmake new file mode 100644 index 0000000..7f9572e --- /dev/null +++ b/Tests/RunCMake/CMP0043/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + +run_cmake(CMP0043-OLD) +run_cmake(CMP0043-NEW) +run_cmake(CMP0043-WARN) diff --git a/Tests/RunCMake/CMP0043/empty.cpp b/Tests/RunCMake/CMP0043/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0043/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMP0045/CMP0045-NEW-result.txt b/Tests/RunCMake/CMP0045/CMP0045-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0045/CMP0045-NEW-stderr.txt b/Tests/RunCMake/CMP0045/CMP0045-NEW-stderr.txt new file mode 100644 index 0000000..805a85e --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-NEW-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0045-NEW.cmake:4 \(get_target_property\): + get_target_property\(\) called with non-existent target "tgt". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0045/CMP0045-NEW.cmake b/Tests/RunCMake/CMP0045/CMP0045-NEW.cmake new file mode 100644 index 0000000..7b2a3cd --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0045 NEW) + +get_target_property(result tgt TYPE) diff --git a/Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt b/Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt b/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0045/CMP0045-OLD.cmake b/Tests/RunCMake/CMP0045/CMP0045-OLD.cmake new file mode 100644 index 0000000..90201a3 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0045 OLD) + +get_target_property(result tgt TYPE) diff --git a/Tests/RunCMake/CMP0045/CMP0045-WARN-result.txt b/Tests/RunCMake/CMP0045/CMP0045-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0045/CMP0045-WARN-stderr.txt b/Tests/RunCMake/CMP0045/CMP0045-WARN-stderr.txt new file mode 100644 index 0000000..4c53224 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-WARN-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0045-WARN.cmake:2 \(get_target_property\): + Policy CMP0045 is not set: Error on non-existent target in + get_target_property. Run "cmake --help-policy CMP0045" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. + + get_target_property\(\) called with non-existent target "tgt". +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/CMP0045/CMP0045-WARN.cmake b/Tests/RunCMake/CMP0045/CMP0045-WARN.cmake new file mode 100644 index 0000000..86a99a0 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-WARN.cmake @@ -0,0 +1,2 @@ + +get_target_property(result tgt TYPE) diff --git a/Tests/RunCMake/CMP0045/CMakeLists.txt b/Tests/RunCMake/CMP0045/CMakeLists.txt new file mode 100644 index 0000000..11ea636 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0045/RunCMakeTest.cmake b/Tests/RunCMake/CMP0045/RunCMakeTest.cmake new file mode 100644 index 0000000..7c0e8a2 --- /dev/null +++ b/Tests/RunCMake/CMP0045/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0045-OLD) +run_cmake(CMP0045-NEW) +run_cmake(CMP0045-WARN) diff --git a/Tests/RunCMake/CMP0045/empty.cpp b/Tests/RunCMake/CMP0045/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0045/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 50c1f61..77700d7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -64,6 +64,8 @@ add_RunCMake_test(CMP0041) if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) add_RunCMake_test(CMP0042) endif() +add_RunCMake_test(CMP0043) +add_RunCMake_test(CMP0045) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) diff --git a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-result.txt b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-stderr.txt b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-stderr.txt new file mode 100644 index 0000000..2079c12 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at CMP0044-WARN.cmake:13 \(target_compile_definitions\): + Policy CMP0044 is not set: Case sensitive <LANG>_COMPILER_ID generator + expressions. Run "cmake --help-policy CMP0044" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. +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/GeneratorExpression/CMP0044-WARN.cmake b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake new file mode 100644 index 0000000..d5b85c9 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake @@ -0,0 +1,17 @@ + +project(CMP0044-WARN) + +string(TOLOWER ${CMAKE_C_COMPILER_ID} lc_test) +if (lc_test STREQUAL CMAKE_C_COMPILER_ID) + string(TOUPPER ${CMAKE_C_COMPILER_ID} lc_test) + if (lc_test STREQUAL CMAKE_C_COMPILER_ID) + message(SEND_ERROR "Try harder.") + endif() +endif() + +add_library(cmp0044-check empty.c) +target_compile_definitions(cmp0044-check + PRIVATE + Result=$<C_COMPILER_ID:${lc_test}> + Type_Is_${CMP0044_TYPE} +) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 54d5064..f3f99ed 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -9,3 +9,4 @@ run_cmake(BadZero) run_cmake(BadTargetName) run_cmake(BadTargetTypeObject) run_cmake(BadInstallPrefix) +run_cmake(CMP0044-WARN) |