diff options
author | Brad King <brad.king@kitware.com> | 2018-03-29 14:21:36 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-03-29 14:21:48 (GMT) |
commit | 3272677e634629628a6293614fd169ff66d72e0d (patch) | |
tree | d98a0edb3ee4258c5926307bdb8f2e9d400f60e6 /Tests | |
parent | a03105ac8c821bd8a2fe269671b49862ae354db8 (diff) | |
parent | 7b173a29332af37eb285d8cf5924a44be3a944dd (diff) | |
download | CMake-3272677e634629628a6293614fd169ff66d72e0d.zip CMake-3272677e634629628a6293614fd169ff66d72e0d.tar.gz CMake-3272677e634629628a6293614fd169ff66d72e0d.tar.bz2 |
Merge topic 'genex-TARGET_NAME_IF_EXISTS'
7b173a2933 genex: Add TARGET_NAME_IF_EXISTS expression
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1890
Diffstat (limited to 'Tests')
11 files changed, 43 insertions, 0 deletions
diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index f9a5cae..5636d00 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -38,6 +38,10 @@ run_cmake(TARGET_EXISTS-no-arg) run_cmake(TARGET_EXISTS-empty-arg) run_cmake(TARGET_EXISTS) run_cmake(TARGET_EXISTS-not-a-target) +run_cmake(TARGET_NAME_IF_EXISTS-no-arg) +run_cmake(TARGET_NAME_IF_EXISTS-empty-arg) +run_cmake(TARGET_NAME_IF_EXISTS) +run_cmake(TARGET_NAME_IF_EXISTS-not-a-target) run_cmake(ImportedTarget-TARGET_BUNDLE_DIR) run_cmake(ImportedTarget-TARGET_BUNDLE_CONTENT_DIR) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake new file mode 100644 index 0000000..2f57430 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_NAME_IF_EXISTS-generated.txt" content) + +set(expected "foo") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt new file mode 100644 index 0000000..5ee13b7 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at TARGET_NAME_IF_EXISTS-empty-arg.cmake:2 \(file\): + Error evaluating generator expression: + + \$<TARGET_NAME_IF_EXISTS:> + + \$<TARGET_NAME_IF_EXISTS:tgt> expression requires a non-empty valid target + name. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake new file mode 100644 index 0000000..f5034f4 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:${empty}>") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt new file mode 100644 index 0000000..4122425 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at TARGET_NAME_IF_EXISTS-no-arg.cmake:2 \(file\): + Error evaluating generator expression: + + \$<TARGET_NAME_IF_EXISTS> + + \$<TARGET_NAME_IF_EXISTS> expression requires exactly one parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake new file mode 100644 index 0000000..3293094 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS>") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake new file mode 100644 index 0000000..2085c16 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake @@ -0,0 +1,5 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_NAME_IF_EXISTS-not-a-target-generated.txt" content) + +if(content) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected an empty string") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake new file mode 100644 index 0000000..a054e6c --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-not-a-target-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:just-random-string>") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake new file mode 100644 index 0000000..0ce3b1d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0070 NEW) +add_custom_target(foo) +file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:foo>") |