File: detect_test_features.cmake

package info (click to toggle)
gridtools 2.3.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,480 kB
  • sloc: cpp: 228,792; python: 17,561; javascript: 9,164; ansic: 4,101; sh: 850; makefile: 231; f90: 201
file content (33 lines) | stat: -rw-r--r-- 1,452 bytes parent folder | download | duplicates (3)
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
include(CMakeDependentOption)

macro(detect_fortran_compiler)
    # Enable Fortran here, as enabling locally might be undefined,
    # see https://cmake.org/cmake/help/v3.12/command/enable_language.html
    # "... it must be called in the highest directory common to all targets using the named language..."
    CMAKE_DEPENDENT_OPTION(GT_TESTS_REQUIRE_FORTRAN_COMPILER "CMake will abort if no fortran compiler can be found"
        OFF "BUILD_TESTING" OFF)

    include(CheckLanguage)
    check_language(Fortran)
    if(CMAKE_Fortran_COMPILER OR GT_TESTS_REQUIRE_FORTRAN_COMPILER)
        enable_language(Fortran)
    else()
        message(WARNING "Fortran Compiler has not been found. Tests using fortran will not be built!")
    endif()
endmacro(detect_fortran_compiler)

macro(detect_c_compiler)
    # Enable C here, as enabling locally might be undefined,
    # see https://cmake.org/cmake/help/v3.12/command/enable_language.html
    # "... it must be called in the highest directory common to all targets using the named language..."
    CMAKE_DEPENDENT_OPTION(GT_TESTS_REQUIRE_C_COMPILER "CMake will abort if no C compiler can be found"
        OFF "BUILD_TESTING" OFF)

    include(CheckLanguage)
    check_language(C)
    if(CMAKE_C_COMPILER OR GT_TESTS_REQUIRE_C_COMPILER)
        enable_language(C)
    else()
        message(WARNING "C Compiler has not been found. Tests using C will not be built!")
    endif()
endmacro(detect_c_compiler)