1 # - Check if the Fortran function exists.
2 # CHECK_FORTRAN_FUNCTION_EXISTS(FUNCTION VARIABLE)
3 # - macro which checks if the Fortran function exists
4 # FUNCTION - the name of the Fortran function
5 # VARIABLE - variable to store the result
7 # The following variables may be set before calling this macro to
8 # modify the way the check is run:
10 # CMAKE_REQUIRED_LIBRARIES = list of libraries to link
13 macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
14 if(NOT DEFINED ${VARIABLE})
15 message(STATUS "Looking for Fortran ${FUNCTION}")
16 if(CMAKE_REQUIRED_LIBRARIES)
17 set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
18 "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
19 else(CMAKE_REQUIRED_LIBRARIES)
20 set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
21 endif(CMAKE_REQUIRED_LIBRARIES)
23 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
30 try_compile(${VARIABLE}
32 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
33 CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}"
34 OUTPUT_VARIABLE OUTPUT
37 set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}")
38 message(STATUS "Looking for Fortran ${FUNCTION} - found")
39 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
40 "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n"
43 message(STATUS "Looking for Fortran ${FUNCTION} - not found")
44 set(${VARIABLE} "" CACHE INTERNAL "Have Fortran function ${FUNCTION}")
45 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
46 "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n"
49 endif(NOT DEFINED ${VARIABLE})
50 endmacro(CHECK_FORTRAN_FUNCTION_EXISTS)