diff options
author | Matt McCormick <matt.mccormick@kitware.com> | 2014-12-29 20:47:48 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-08-03 09:22:25 -0400 |
commit | 14e49ed15615e7f2bcb58aa4540683250006f5c7 (patch) | |
tree | fad463f1cb96d9da2ee65bee42e8e6a251aec971 /Tests/RunCMake/if | |
parent | 623dcc85a447b9ce0f09cffa8cd296cd8a51ad9d (diff) | |
download | cmake-14e49ed15615e7f2bcb58aa4540683250006f5c7.tar.gz |
if: Add "TEST <test>" condition
if(TEST TestNameThatExists) will return true if a test with the name
TestNameThatExists has been added with add_test. The syntax is similar
to if(TARGET TargetName). Since use of "TEST" as an argument to if()
could previously be interpreted as a non-keyword argument, add policy
CMP0064 to treat it as a keyword as NEW behavior.
Diffstat (limited to 'Tests/RunCMake/if')
-rw-r--r-- | Tests/RunCMake/if/RunCMakeTest.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/if/TestNameThatDoesNotExist.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/if/TestNameThatExists-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/if/TestNameThatExists.cmake | 7 |
5 files changed, 18 insertions, 0 deletions
diff --git a/Tests/RunCMake/if/RunCMakeTest.cmake b/Tests/RunCMake/if/RunCMakeTest.cmake index 2c0c4d7fca..3f4d2a24d0 100644 --- a/Tests/RunCMake/if/RunCMakeTest.cmake +++ b/Tests/RunCMake/if/RunCMakeTest.cmake @@ -4,3 +4,6 @@ run_cmake(InvalidArgument1) run_cmake(IsDirectory) run_cmake(IsDirectoryLong) run_cmake(elseif-message) + +run_cmake(TestNameThatExists) +run_cmake(TestNameThatDoesNotExist) diff --git a/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt b/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt new file mode 100644 index 0000000000..8874ca894a --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt @@ -0,0 +1 @@ +TestThatDoesNotExist is false diff --git a/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake b/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake new file mode 100644 index 0000000000..74bc8b02fb --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake @@ -0,0 +1,6 @@ +cmake_policy(SET CMP0064 NEW) +if(TEST TestThatDoesNotExist) + message(FATAL_ERROR "if TestThatDoesNotExist is true") +else() + message(STATUS "if TestThatDoesNotExist is false") +endif() diff --git a/Tests/RunCMake/if/TestNameThatExists-stdout.txt b/Tests/RunCMake/if/TestNameThatExists-stdout.txt new file mode 100644 index 0000000000..54911bc5b0 --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatExists-stdout.txt @@ -0,0 +1 @@ +TestThatExists is true diff --git a/Tests/RunCMake/if/TestNameThatExists.cmake b/Tests/RunCMake/if/TestNameThatExists.cmake new file mode 100644 index 0000000000..65c2b462c1 --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatExists.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0064 NEW) +add_test(NAME TestThatExists COMMAND ${CMAKE_COMMAND} -E echo "A CMake Test") +if(TEST TestThatExists) + message(STATUS "if TestThatExists is true") +else() + message(FATAL_ERROR "if TestThatExists is false") +endif() |