|
| 1 | +# ------------------------------------------------------------------------------------------------------------------------- |
| 2 | +# Le contenu de ce fichier permet de gérer des options de compilation indispensables à une bonne utilisation de Lima. |
| 3 | +# Ces options de compilation définissent la taille d'encodage des entiers et réels. |
| 4 | +# C'est par exemple indispensable à des codes fortran dont les arguments transmis lors des appels Lima sont de type |
| 5 | +# INTEGER ou REAL. |
| 6 | +# ------------------------------------------------------------------------------------------------------------------------- |
| 7 | + |
| 8 | +# --------------------------------- |
| 9 | +# manage integer |
| 10 | +# --------------------------------- |
| 11 | +# |
| 12 | +# I4 |
| 13 | +# C and C++ |
| 14 | +# Fortran if Intel |
| 15 | +# Fortran if GNU |
| 16 | +# Fortran if ARM |
| 17 | +# Fortran if FLANG |
| 18 | +# Fortran if IBM |
| 19 | +# Fortran if PGI |
| 20 | +# I8 |
| 21 | +# C and C++ |
| 22 | +# Fortran if Intel |
| 23 | +# Fortran if GNU |
| 24 | +# Fortran if ARM |
| 25 | +# Fortran if FLANG |
| 26 | +# Fortran if IBM |
| 27 | +# Fortran if PGI |
| 28 | +# --------------------------------- |
| 29 | +if (NOT INT_8) |
| 30 | + set (LIMA_INT_SIZE "INTEGER_32") |
| 31 | +else() # I8 |
| 32 | + set (LIMA_INT_SIZE "INTEGER_64") |
| 33 | +endif() |
| 34 | + |
| 35 | + |
| 36 | +# --------------------------------- |
| 37 | +# manage real |
| 38 | +# --------------------------------- |
| 39 | +# |
| 40 | +# R4 |
| 41 | +# C and C++ |
| 42 | +# Fortran if Intel |
| 43 | +# Fortran if GNU |
| 44 | +# Fortran if ARM |
| 45 | +# Fortran if FLANG |
| 46 | +# Fortran if IBM |
| 47 | +# Fortran if PGI |
| 48 | +# R8 |
| 49 | +# C and C++ |
| 50 | +# Fortran if Intel |
| 51 | +# Fortran if GNU |
| 52 | +# Fortran if ARM |
| 53 | +# Fortran if FLANG |
| 54 | +# Fortran if IBM |
| 55 | +# Fortran if PGI |
| 56 | +# --------------------------------- |
| 57 | +if (NOT REAL_8) |
| 58 | + set (LIMA_REAL_SIZE "REAL_32") |
| 59 | +else() # R8 |
| 60 | + set (LIMA_REAL_SIZE "REAL_64") |
| 61 | +endif() |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +if (DEFINED CMAKE_Fortran_COMPILER_ID) |
| 66 | + if(CMAKE_Fortran_COMPILER_ID STREQUAL "ARM" OR CMAKE_Fortran_COMPILER MATCHES "armflang") # cmake does always have proper COMPILER_ID for arm compiler |
| 67 | + set(i4_opt "") # -i4 does not exists, but it's the default |
| 68 | + set(i8_opt -i8) |
| 69 | + set(r4_opt "") # -r4 does not exists, but it's the default |
| 70 | + set(r8_opt -r8) |
| 71 | + set(r16_opt -r16) # future ? |
| 72 | + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") # gnu (gcc) gfortran |
| 73 | + set(i4_opt "") # -fdefault-integer-4 does not exists, but it's the default |
| 74 | + set(i8_opt -fdefault-integer-8) |
| 75 | + set(r4_opt "") # -fdefault-real-4 does not exists, but it's default |
| 76 | + set(r8_opt -fdefault-real-8) |
| 77 | + set(r16_opt -fdefault-real-16) # future ? |
| 78 | + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" OR CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") # intel (icc/icx) ifort/ifx |
| 79 | + set(i4_opt -i4) |
| 80 | + set(i8_opt -i8) |
| 81 | + set(r4_opt "") # -r4 does not exists, but it's the default |
| 82 | + set(r8_opt -r8) |
| 83 | + set(r16_opt -r16) |
| 84 | + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Flang") # llvm (clang) flang |
| 85 | + set(i4_opt "") |
| 86 | + set(i8_opt -i8) |
| 87 | + set(r4_opt "") |
| 88 | + set(r8_opt -r8) |
| 89 | + set(r16_opt -r16) # future ? |
| 90 | + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "XL" OR CMAKE_Fortran_COMPILER_NAME MATCHES "xlf*") # VisualAge (ibm) xlfortran |
| 91 | + # set(i2_opt -qintsize=2) # available but not used |
| 92 | + set(i4_opt -qintsize=4) # (default) |
| 93 | + set(i8_opt -qintsize=8) |
| 94 | + set(r4_opt -qrealsize=4) # (default) |
| 95 | + set(r8_opt -qrealsize=8) |
| 96 | + set(r16_opt -qrealsize=16) # not present in xlf (xlf_r) 16.1 |
| 97 | + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" OR CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") # PGI (portland group) pgf[77,90,95] = pgfortran |
| 98 | + # set(i2_opt -i2) # available but not used |
| 99 | + set(i4_opt -i4) # (default) |
| 100 | + set(i8_opt -i8) |
| 101 | + set(r4_opt -r4) # (default) |
| 102 | + set(r8_opt -r8) |
| 103 | + set(r16_opt -r16) # not present in pgfortran 20.9-0 |
| 104 | + else() |
| 105 | + message(FATAL_ERROR |
| 106 | + "Unknown Fortran compiler '${CMAKE_Fortran_COMPILER_ID}' ('${CMAKE_Fortran_COMPILER}'), " |
| 107 | + "IR flags not implemented.") |
| 108 | + endif() |
| 109 | + |
| 110 | + set(FORTRAN_FLAGS "") |
| 111 | + set(FORTRAN_FLAGS_LIST "") |
| 112 | + if (NOT INT_8) |
| 113 | + string (APPEND FORTRAN_FLAGS " ${i4_opt}") |
| 114 | + list (APPEND FORTRAN_FLAGS_LIST "${i4_opt}") |
| 115 | + else() |
| 116 | + string (APPEND FORTRAN_FLAGS " ${i8_opt}") |
| 117 | + list (APPEND FORTRAN_FLAGS_LIST "${i8_opt}") |
| 118 | + endif() |
| 119 | + |
| 120 | + if (NOT REAL_8) |
| 121 | + string (APPEND FORTRAN_FLAGS " ${r4_opt}") |
| 122 | + list (APPEND FORTRAN_FLAGS_LIST "${r4_opt}") |
| 123 | + else() |
| 124 | + string (APPEND FORTRAN_FLAGS " ${r8_opt}") |
| 125 | + list (APPEND FORTRAN_FLAGS_LIST "${r8_opt}") |
| 126 | + endif() |
| 127 | + set(FORTRAN_FLAGS "") |
| 128 | + string (REPLACE ";" " " FORTRAN_FLAGS "${FORTRAN_FLAGS_LIST}") |
| 129 | + # set compile flags |
| 130 | + |
| 131 | + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FORTRAN_FLAGS}" CACHE FILEPATH "" FORCE) |
| 132 | + |
| 133 | +endif() |
0 commit comments