summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeOnly/CheckLanguage
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-02-08 15:48:34 (GMT)
committerBrad King <brad.king@kitware.com>2012-02-08 15:48:34 (GMT)
commit5db99e8708c7d329620186e4cfb6e059f400dfcc (patch)
tree033ea7ef29feb3b8f59abc3607375765f437b4c6 /Tests/CMakeOnly/CheckLanguage
parent7dcfd9aaf621672b3006fd5b084a17409d4435b2 (diff)
downloadCMake-5db99e8708c7d329620186e4cfb6e059f400dfcc.zip
CMake-5db99e8708c7d329620186e4cfb6e059f400dfcc.tar.gz
CMake-5db99e8708c7d329620186e4cfb6e059f400dfcc.tar.bz2
Add CheckLanguage module
Define a "check_language(<lang>)" macro to test whether <lang> can be enabled. Cache the result in CMAKE_<lang>_COMPILER. Add a test case covering expected results.
Diffstat (limited to 'Tests/CMakeOnly/CheckLanguage')
-rw-r--r--Tests/CMakeOnly/CheckLanguage/CMakeLists.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
new file mode 100644
index 0000000..f5336dc
--- /dev/null
+++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required (VERSION 2.8)
+project(CheckLanguage NONE)
+include(CheckLanguage)
+
+set(langs )
+set(expect_C 1)
+set(expect_CXX 1)
+unset(expect_Fortran)
+set(expect_NoSuchLanguage 0)
+foreach(lang C CXX Fortran NoSuchLanguage)
+ check_language(${lang})
+ if(NOT DEFINED CMAKE_${lang}_COMPILER)
+ message(FATAL_ERROR "check_language(${lang}) did not set result")
+ endif()
+ if(DEFINED expect_${lang})
+ if(expect_${lang} AND NOT CMAKE_${lang}_COMPILER)
+ message(FATAL_ERROR "check_language(${lang}) should not fail!")
+ elseif(NOT expect_${lang} AND CMAKE_${lang}_COMPILER)
+ message(FATAL_ERROR "check_language(${lang}) should not succeed!")
+ endif()
+ endif()
+endforeach()