File: setup_f77.cmake

package info (click to toggle)
openmpi 1.6.5-9.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 91,628 kB
  • ctags: 44,305
  • sloc: ansic: 408,966; cpp: 44,454; sh: 27,828; makefile: 10,486; asm: 3,882; python: 1,239; lex: 805; perl: 549; csh: 253; fortran: 232; f90: 126; tcl: 12
file content (170 lines) | stat: -rw-r--r-- 7,379 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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Copyright (c) 2008-2010 High Performance Computing Center Stuttgart, 
#                         University of Stuttgart.  All rights reserved.
#
# $COPYRIGHT$
# 
# Additional copyrights may follow
# 
# $HEADER$
#

# first try to find a f77 compiler, will be checked when f77 support is enabled.

# There might be a bug in CMake, the CMAKE_GENERATOR_FC is set to "ifort" by default,
# which causes CMake can't find the correct Fortran compiler.
# We have to set CMAKE_GENERATOR_FC empty.
SET(CMAKE_GENERATOR_FC "")
include(CMakeDetermineFortranCompiler)
include(CMakeFortranInformation)

IF(OMPI_WANT_F77_BINDINGS AND NOT F77_SETUP_DONE)

  # Get the size of a C size_t; that's the size of the Fortran
  # MPI_OFFSET_KIND
  MESSAGE( STATUS "Checking size of C size_t...")
  FILE (WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_sizeof_sizet.c"
        "#include <stddef.h>
       int main() {return sizeof(size_t);}
      ")
  TRY_RUN(SIZEOF_C_SIZE_T COMPILE_RESULT "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
        "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_sizeof_sizet.c")
  SET(OMPI_MPI_OFFSET_KIND ${SIZEOF_C_SIZE_T} CACHE INTERNAL "MPI_OFFSET_KIND")

  # MPI_INTEGER_KIND is always 4
  SET(OMPI_MPI_INTEGER_KIND 4 CACHE INTERNAL "MPI_INTEGER_KIND") 

  # MPI_ADDRESS_KIND is the size of a C (void*), which is built-in to
  # Cmake.
  SET(OMPI_MPI_ADDRESS_KIND ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "MPI_ADDRESS_KIND") 

  # Finally, set the number of integers in MPI_STATUS_SIZE (it's 4
  # integers plus 1 size_t).
  MATH( EXPR __ompi_f_status "(4+(${SIZEOF_C_SIZE_T}/4))")
  SET(OMPI_FORTRAN_STATUS_SIZE ${__ompi_f_status} CACHE INTERNAL "MPI_STATUS_SIZE") 

  GET_FILENAME_COMPONENT(F77_NAME ${CMAKE_Fortran_COMPILER} NAME)
  GET_FILENAME_COMPONENT(F77_PATH ${CMAKE_Fortran_COMPILER} PATH)

  SET(F77 ${F77_NAME} CACHE INTERNAL "Name of the fortran compiler.")

  # Default compiler settings.
  IF(${F77} STREQUAL "ifort.exe")
    #settings for Intel Fortran
    SET(F77_OPTION_COMPILE "/c" CACHE INTERNAL
      "Fortran compiler option for compiling without linking.")
    SET(F77_OUTPUT_OBJ "/Fo" CACHE INTERNAL
      "Fortran compiler option for setting object file name.")
    SET(F77_OUTPUT_EXE "/Fe" CACHE INTERNAL
      "Fortran compiler option for setting executable file name.")
    SET(F77_DYNAMIC_FLAG_DEBUG "/MDd" CACHE INTERNAL
      "Compile flag for using dynamically-loaded, multithread C runtime (Debug).")
    SET(F77_DYNAMIC_FLAG "/MD" CACHE INTERNAL
      "Compile flag for using dynamically-loaded, multithread C runtime.")

    IF(NOT "$ENV{IFORT_COMPILER11}" STREQUAL "")
      SET(IFORT_LIB_PATH "$ENV{IFORT_COMPILER11}/lib/")
    ELSEIF(NOT "$ENV{IFORT_COMPILER12}" STREQUAL "")
      SET(IFORT_LIB_PATH "$ENV{IFORT_COMPILER12}/compiler/lib/")
    ENDIF(NOT "$ENV{IFORT_COMPILER11}" STREQUAL "")

    IF(CMAKE_CL_64)
      SET(F77_LIB_PATH "${IFORT_LIB_PATH}/intel64")
    ELSE(CMAKE_CL_64)
      SET(F77_LIB_PATH "${IFORT_LIB_PATH}/ia32")
    ENDIF(CMAKE_CL_64)

    IF(NOT F77_LIB_PATH)
      IF(CMAKE_CL_64)
        FIND_LIBRARY(F77_IFCONSOL_LIB ifconsol.lib PATHS ${F77_PATH}/../../intel64)
      ELSE(CMAKE_CL_64)
        FIND_LIBRARY(F77_IFCONSOL_LIB ifconsol.lib PATHS ${F77_PATH}/../../ia32)
      ENDIF(CMAKE_CL_64)
      GET_FILENAME_COMPONENT(F77_LIB_PATH ${F77_IFCONSOL_LIB} PATH)
      UNSET(F77_IFCONSOL_LIB CACHE)
    ELSE(NOT F77_LIB_PATH)
      STRING(REPLACE "\\" "/" F77_LIB_PATH ${F77_LIB_PATH})
    ENDIF(NOT F77_LIB_PATH)
  ELSEIF(${F77} STREQUAL "g95.exe")
    #settings for G95
    SET(F77_OPTION_COMPILE "-c" CACHE INTERNAL
      "Fortran compiler option for compiling without linking.")
    SET(F77_OUTPUT_OBJ "-o" CACHE INTERNAL
      "Fortran compiler option for setting object file name.")
    SET(F77_OUTPUT_EXE "-o" CACHE INTERNAL
      "Fortran compiler option for setting executable file name.")
  ELSE(${F77} STREQUAL "ifort.exe")
    # in other case, let user specify their fortran configrations.
    SET(F77_OPTION_COMPILE "-c" CACHE STRING
      "Fortran compiler option for compiling without linking.")
    SET(F77_OUTPUT_OBJ "-o" CACHE STRING
      "Fortran compiler option for setting object file name.")
    SET(F77_OUTPUT_EXE "-o" CACHE STRING
      "Fortran compiler option for setting executable file name.")
    SET(F77_LIB_PATH "" CACHE PATH
      "Library path for the fortran compiler")
    SET(F77_INCLUDE_PATH "" CACHE PATH
      "Include path for the fortran compiler")
  ENDIF(${F77} STREQUAL "ifort.exe")

  # Export env variables for fortran compiler.
  SET(ENV{PATH} "${C_COMPILER_PATH};${F77_PATH};$ENV{PATH}")
  SET(ENV{LIB} "${C_COMPILER_LIB};${F77_LIB_PATH};$ENV{LIB}")
  SET(ENV{INCLUDE} "${C_COMPILER_INCLUDE};${F77_INCLUDE_PATH};$ENV{INCLUDE}")
  SET(ENV{LIBPATH} "${C_COMPILER_LIBPATH};$ENV{LIBPATH}")

  # make sure the compiler actually works, if not cross-compiling
  MESSAGE(STATUS "Checking for working Fortran compiler...")
  FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
       "\t PROGRAM TESTFortran \n"
       "\t PRINT *, 'Hello' \n"
       "\t END \n")

  # lets use execute_process to run the compile test
  EXECUTE_PROCESS(COMMAND ${F77} testFortranCompiler.f
                  WORKING_DIRECTORY  ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
                  OUTPUT_VARIABLE    OUTPUT
                  RESULT_VARIABLE    RESULT
                  ERROR_VARIABLE     ERROR)


  IF(RESULT)
    SET(F77_SETUP_DONE FALSE CACHE INTERNAL "f77 setup done.")
    MESSAGE(STATUS "${OUTPUT}\n${ERROR}")
    MESSAGE(STATUS "Fortran compiler ${F77} can't compile a simple fortran program.")
    MESSAGE(FATAL_ERROR "Cannot continue. Please check Fortran compiler installation, or disable Fortran 77 support.")
  ELSE(RESULT)
    MESSAGE(STATUS "Checking for working Fortran compiler...${F77}")
    SET(F77_SETUP_DONE TRUE CACHE INTERNAL "f77 setup done.")
  ENDIF(RESULT)

  INCLUDE(F77_find_ext_symbol_convention)
  # make sure we know the linking convention
  # this macro will also test linking with C code
  OMPI_F77_FIND_EXT_SYMBOL_CONVENTION()

ELSEIF(NOT OMPI_WANT_F77_BINDINGS)
    SET(OMPI_F77_DOUBLE_UNDERSCORE 0
      CACHE INTERNAL "external symbol convention - double underscore")
    SET(OMPI_F77_SINGLE_UNDERSCORE 0
      CACHE INTERNAL "external symbol convention - single underscore")
    SET(OMPI_F77_CAPS 0
      CACHE INTERNAL "external symbol convention - captital")
    SET(OMPI_F77_PLAIN 0
      CACHE INTERNAL "external symbol convention - plain")
    
    UNSET(SYMBOL_CONVENTION_CHECK_DONE CACHE)
    UNSET(F77_OPTION_COMPILE CACHE)
    UNSET(F77_OUTPUT_OBJ CACHE)
    UNSET(F77_OUTPUT_EXE CACHE)
    UNSET(F77_LIB_PATH CACHE)
    UNSET(F77_INCLUDE_PATH CACHE)
    UNSET(F77_IFCONSOL_LIB CACHE)
    UNSET(F77_SETUP_DONE CACHE)
ENDIF(OMPI_WANT_F77_BINDINGS AND NOT F77_SETUP_DONE)

# a few definitions needed by OMPI_F77_FIND_EXT_SYMBOL_CONVENTION check.
OMPI_DEF_VAR(OMPI_F77_DOUBLE_UNDERSCORE "Whether fortran symbols have a trailing double underscore or not." 0 1)
OMPI_DEF_VAR(OMPI_F77_SINGLE_UNDERSCORE "Whether fortran symbols have a trailing single underscore or not." 0 1)
OMPI_DEF_VAR(OMPI_F77_CAPS "Whether fortran symbols are all caps or not." 0 1)
OMPI_DEF_VAR(OMPI_F77_PLAIN "Whether fortran symbols have no trailing underscore or not." 0 1)