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
12 macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
13 if(NOT DEFINED ${VARIABLE})
14 message(STATUS "Looking for Fortran ${FUNCTION}")
15 if(CMAKE_REQUIRED_LIBRARIES)
16 set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
17 "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
18 else(CMAKE_REQUIRED_LIBRARIES)
19 set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
20 endif(CMAKE_REQUIRED_LIBRARIES)
22 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
27 end program TESTFortran
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
36 # message(STATUS "${OUTPUT}")
38 set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}")
39 message(STATUS "Looking for Fortran ${FUNCTION} - found")
40 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
41 "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n"
44 message(STATUS "Looking for Fortran ${FUNCTION} - not found")
45 set(${VARIABLE} "" CACHE INTERNAL "Have Fortran function ${FUNCTION}")
46 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
47 "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n"
50 endif(NOT DEFINED ${VARIABLE})
51 endmacro(CHECK_FORTRAN_FUNCTION_EXISTS)