| 1 |
# |
| 2 |
# Copyright by The HDF Group. |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# This file is part of HDF5. The full HDF5 copyright notice, including |
| 6 |
# terms governing use, modification, and redistribution, is contained in |
| 7 |
# the COPYING file, which can be found at the root of the source code |
| 8 |
# distribution tree, or in https://www.hdfgroup.org/licenses. |
| 9 |
# If you do not have access to either file, you may request a copy from |
| 10 |
# [email protected]. |
| 11 |
# |
| 12 |
|
| 13 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 14 |
message (VERBOSE "Warnings Configuration: default Fortran: ${CMAKE_Fortran_FLAGS}") |
| 15 |
endif () |
| 16 |
|
| 17 |
#----------------------------------------------------------------------------- |
| 18 |
# Option to allow the user to disable compiler warnings |
| 19 |
#----------------------------------------------------------------------------- |
| 20 |
if (HDF5_DISABLE_COMPILER_WARNINGS) |
| 21 |
message (STATUS "....Compiler warnings are suppressed") |
| 22 |
# MSVC uses /w to suppress warnings. It also complains if another |
| 23 |
# warning level is given, so remove it. |
| 24 |
if (MSVC) |
| 25 |
set (HDF5_WARNINGS_BLOCKED 1) |
| 26 |
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") |
| 27 |
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /warn:none") |
| 28 |
endif () |
| 29 |
endif () |
| 30 |
if (WIN32) |
| 31 |
add_definitions (-D_CRT_SECURE_NO_WARNINGS) |
| 32 |
endif () |
| 33 |
# Borland uses -w- to suppress warnings. |
| 34 |
if (BORLAND) |
| 35 |
set (HDF5_WARNINGS_BLOCKED 1) |
| 36 |
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w-") |
| 37 |
endif () |
| 38 |
|
| 39 |
# Most compilers use -w to suppress warnings. |
| 40 |
if (NOT HDF5_WARNINGS_BLOCKED) |
| 41 |
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w") |
| 42 |
endif () |
| 43 |
endif () |
| 44 |
|
| 45 |
#----------------------------------------------------------------------------- |
| 46 |
# HDF5 library compile options |
| 47 |
#----------------------------------------------------------------------------- |
| 48 |
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.0) |
| 49 |
if (HDF5_ENABLE_BUILD_DIAGS) |
| 50 |
message (STATUS "... default color and URL extended diagnostic messages enabled") |
| 51 |
else () |
| 52 |
message (STATUS "... disable color and URL extended diagnostic messages") |
| 53 |
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdiagnostics-urls=never -fno-diagnostics-color") |
| 54 |
endif () |
| 55 |
endif () |
| 56 |
|
| 57 |
#----------------------------------------------------------------------------- |
| 58 |
# CDash is configured to only allow 3000 warnings, so |
| 59 |
# break into groups (from the config/gnu-flags file) |
| 60 |
#----------------------------------------------------------------------------- |
| 61 |
if (NOT MSVC AND NOT MINGW) |
| 62 |
# General flags |
| 63 |
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") |
| 64 |
ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/ifort-general") |
| 65 |
list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand:f03" "-free") |
| 66 |
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") |
| 67 |
ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") |
| 68 |
list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form" "-fimplicit-none") |
| 69 |
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0 AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.6) |
| 70 |
list (APPEND HDF5_CMAKE_Fortran_FLAGS "-std=f2008ts") |
| 71 |
else () |
| 72 |
list (APPEND HDF5_CMAKE_Fortran_FLAGS "-std=f2008") |
| 73 |
endif () |
| 74 |
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") |
| 75 |
list (APPEND HDF5_CMAKE_Fortran_FLAGS "-Mfreeform" "-Mdclchk" "-Mstandard" "-Mallocatable=03") |
| 76 |
endif () |
| 77 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 78 |
message (VERBOSE "HDF5_CMAKE_Fortran_FLAGS=${HDF5_CMAKE_Fortran_FLAGS}") |
| 79 |
endif () |
| 80 |
|
| 81 |
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") |
| 82 |
|
| 83 |
# Append more extra warning flags that only gcc 4.8+ knows about |
| 84 |
if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) |
| 85 |
ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") |
| 86 |
endif () |
| 87 |
|
| 88 |
# Append more extra warning flags that only gcc 4.9+ knows about |
| 89 |
#if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) |
| 90 |
# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") |
| 91 |
#endif () |
| 92 |
|
| 93 |
# Append more extra warning flags that only gcc 5.x+ knows about |
| 94 |
if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) |
| 95 |
ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") |
| 96 |
endif () |
| 97 |
|
| 98 |
# Append more extra warning flags that only gcc 6.x+ knows about |
| 99 |
if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) |
| 100 |
ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") |
| 101 |
endif () |
| 102 |
|
| 103 |
# Append more extra warning flags that only gcc 7.x+ knows about |
| 104 |
#if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) |
| 105 |
# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") |
| 106 |
#endif () |
| 107 |
|
| 108 |
# Append more extra warning flags that only gcc 8.x+ knows about |
| 109 |
if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) |
| 110 |
ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") |
| 111 |
endif () |
| 112 |
|
| 113 |
# Append more extra warning flags that only gcc 9.x+ knows about |
| 114 |
#if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) |
| 115 |
# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") |
| 116 |
#endif () |
| 117 |
endif () |
| 118 |
else () |
| 119 |
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") |
| 120 |
#ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/win-ifort-general") |
| 121 |
list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f03" "/free") |
| 122 |
endif () |
| 123 |
endif () |
| 124 |
|