summaryrefslogtreecommitdiff
path: root/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
blob: 0c761585105777825c0946d64bf6acd8b7fcdbe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
cmake_minimum_required (VERSION 3.5)
project(CheckLanguage NONE)
include(CheckLanguage)

set(langs )
set(expect_C 1)
set(expect_CXX 1)

if(APPLE)
  set(expect_OBJC 1)
  set(expect_OBJCXX 1)
endif()
unset(expect_Fortran)
set(expect_NoSuchLanguage 0)

set(LANGUAGES C CXX Fortran CUDA NoSuchLanguage)
if(APPLE)
  list(APPEND LANGUAGES OBJC OBJCXX)
endif()

foreach(test_lang ${LANGUAGES})
  check_language(${test_lang})
  if(NOT DEFINED CMAKE_${test_lang}_COMPILER)
    message(FATAL_ERROR "check_language(${test_lang}) did not set result")
  endif()
  if(DEFINED expect_${test_lang})
    if(expect_${test_lang} AND NOT CMAKE_${test_lang}_COMPILER)
      message(FATAL_ERROR "check_language(${test_lang}) should not fail!")
    elseif(NOT expect_${test_lang} AND CMAKE_${test_lang}_COMPILER)
      message(FATAL_ERROR "check_language(${test_lang}) should not succeed!")
    endif()
  endif()
endforeach()