Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4d22501fa4d64070771546329bc859f0a9cb52ee
[simgrid.git] / buildtools / Cmake / Modules / FindF2c.cmake
1 find_program(F2C_EXE
2   NAME f2c
3   PATH_SUFFIXES bin/
4   PATHS
5   /opt
6   /opt/local
7   /opt/csw
8   /sw
9   /usr
10   )
11
12 if(F2C_EXE)
13   message(STATUS "Looking for bin f2c - found: ${F2C_EXE}")
14 else()
15   message(STATUS "Looking for bin f2c - not found (http://www.netlib.org/f2c/)")
16 endif()
17
18 find_library(HAVE_F2C_LIB
19   NAME f2c
20   HINTS
21   ENV LD_LIBRARY_PATH
22   PATH_SUFFIXES lib/
23   PATHS
24   /opt
25   /opt/local
26   /opt/csw
27   /sw
28   /usr
29   )
30
31 if(HAVE_F2C_LIB)
32   message(STATUS "Looking for lib f2c - found: ${HAVE_F2C_LIB}")
33 else()
34   message(STATUS "Looking for lib f2c - not found")
35 endif()
36
37 get_filename_component(F2C_HINT ${HAVE_F2C_LIB} PATH)
38 find_path(HAVE_F2C_H f2c.h
39   HINTS
40   ${F2C_HINT}/..
41   PATH_SUFFIXES include/
42   PATHS
43   /opt
44   /opt/local
45   /opt/csw
46   /sw
47   /usr
48   )
49
50 if(HAVE_F2C_H)
51   message(STATUS "Looking for f2c.h - found: ${HAVE_F2C_H}")
52 else()
53   message(STATUS "Looking for f2c.h - not found")
54 endif()
55
56 if(HAVE_F2C_H)
57   set(HAVE_SMPI_F2C_H 1)
58 endif()
59
60 mark_as_advanced(HAVE_F2C_H)
61 mark_as_advanced(F2C_EXE)
62 mark_as_advanced(HAVE_F2C_LIB)
63
64 if(HAVE_F2C_LIB)
65   get_filename_component(F2C_LIBRARY_PATH "${HAVE_F2C_LIB}" PATH)
66   file(TO_NATIVE_PATH "${F2C_LIBRARY_PATH}" F2C_LIBRARY_PATH)
67 endif()
68
69 #Some old versions of 64 bits systems seem to have a different size between C and Fortran Datatypes
70 #Deactivate F2C with these versions, in order to avoid breaking test cases in legacy systems (as Fedora 13)
71 set(COMPILER_OK 1)
72 if(PROCESSOR_x86_64 AND "${CMAKE_SYSTEM}" MATCHES "Linux" AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU" AND "4.5" STRGREATER "${COMPILER_C_VERSION_MAJOR_MINOR}" )
73     set(COMPILER_OK 0)
74     message("Your C compiler is a bit old and Fortran support is quite problematic on 64 bit platforms, F2C has been deactivated")
75 endif()
76
77 set(SMPI_F2C 0)
78 if(HAVE_F2C_H AND F2C_EXE AND HAVE_F2C_LIB AND COMPILER_OK)
79   set(SMPI_F2C 1)
80 endif()
81
82 if(SMPI_F2C)
83   include_directories(${HAVE_F2C_H})
84 else()
85   message("-- Fortran 77 support for smpi is disabled.")
86 endif()