File: CheckCFortranFunctionExists.cmake

package info (click to toggle)
madness 0.10.1%2Bgit20200818.eee5fd9f-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 34,980 kB
  • sloc: cpp: 280,841; ansic: 12,626; python: 4,961; fortran: 4,245; xml: 1,053; makefile: 714; sh: 276; perl: 244; yacc: 227; lex: 188; asm: 141; csh: 55
file content (28 lines) | stat: -rw-r--r-- 992 bytes parent folder | download | duplicates (2)
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
include(CheckFunctionExists)

macro(check_c_fortran_function_exists _func_base _result)
  string(TOLOWER "${_func_base}" _func_base_lower)
  string(TOUPPER "${_func_base}" _func_base_upper)
  set(${_result} FALSE)
  foreach(_func ${_func_base_lower}_;${_func_base_lower};${_func_base_lower}__;${_func_base_upper};${_func_base_upper}_)
    check_function_exists(${_func} _${_func}_found)
    if(_${_func}_found)
      set(${_result} ${_func})
      break()
    else()  # try appending c++ libs if depend on c++ runtime
      foreach(_cxxlib -lstdc++;-lc++)
        cmake_push_check_state()
        set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};${_cxxlib}")
        check_function_exists(${_func} _${_func}_found_with_${_cxxlib})
        cmake_pop_check_state()
        if(_${_func}_found_with_${_cxxlib})
          set(${_result} ${_func})
          break()
        endif()
      endforeach()
      if(${_result})
        break()
      endif()
    endif()
  endforeach()
endmacro()