File: detect_features.cmake

package info (click to toggle)
gridtools 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 21,728 kB
  • sloc: cpp: 45,263; python: 9,383; javascript: 8,445; ansic: 2,564; sh: 509; f90: 370; makefile: 216
file content (68 lines) | stat: -rw-r--r-- 2,405 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
if(NOT DEFINED CPP_BINDGEN_ENABLE_COMPILER_DETECTION)
    if(${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
        set(CPP_BINDGEN_ENABLE_COMPILER_DETECTION ON)
    else()
        # If turned OFF, it will still use the compilers,
        # - if they are available from a super-project, or
        # - if compilers are forced to on via other options.
        set(CPP_BINDGEN_ENABLE_COMPILER_DETECTION OFF)
    endif()
endif()

macro(detect_cuda)
    if(CPP_BINDGEN_ENABLE_COMPILER_DETECTION)
        if(NOT DEFINED CPP_BINDGEN_TEST_CUDA)
            # detect CUDA support
            include(CheckLanguage)
            check_language(CUDA)

            if(CMAKE_CUDA_COMPILER)
                enable_language (CUDA)
                message(STATUS "Enable CUDA tests")
                set(CUDA_AVAILABLE ON)
            else()
                message(STATUS "Disable CUDA tests")
                set(CUDA_AVAILABLE OFF)
            endif()
        elseif(CPP_BINDGEN_TEST_CUDA)
            enable_language(CUDA)
            message(STATUS "Enable CUDA tests")
            set(CUDA_AVAILABLE ON)
        else()
            message(STATUS "Disable CUDA tests")
            set(CUDA_AVAILABLE OFF)
        endif()
    endif()
endmacro(detect_cuda)

include (CMakeDependentOption)

macro(detect_fortran_compiler)
    if(CPP_BINDGEN_ENABLE_COMPILER_DETECTION)
        CMAKE_DEPENDENT_OPTION (CPP_BINDGEN_REQUIRE_TEST_Fortran "CMake will abort if no Fortran compiler can be found"
            OFF "BUILD_TESTING" OFF)

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

macro(detect_c_compiler)
    if(CPP_BINDGEN_ENABLE_COMPILER_DETECTION)
        CMAKE_DEPENDENT_OPTION (CPP_BINDGEN_REQUIRE_TEST_C "CMake will abort if no C compiler can be found"
            OFF "BUILD_TESTING" OFF)

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