|
70 | 70 | # This will require SUITESPARSE_C_TO_FORTRAN to be |
71 | 71 | # defined explicitly, if the defaults are not appropriate |
72 | 72 | # for your system. |
73 | | -# Default: OFF |
| 73 | +# Default: ON |
74 | 74 | # |
75 | | -# This setting was ON by default in SuiteSparse 7.10.0 and earlier. |
76 | | -# Note that Fortran is now disabled by default, with the default setting |
77 | | -# of SUITESPARSE_USE_FORTRAN changed from ON to OFF. If the icx compiler |
78 | | -# and the Intel MKL BLAS are available but ifx is not, then loading the |
79 | | -# GNU Fortran compiler causes the cmake FindBLAS to link the Intel MKL |
80 | | -# against libgomp, but at the same time cmake links the application with |
81 | | -# libiomp. Including two OpenMP libraries, libiomp and libgomp, in one |
82 | | -# application can cause serious performance issues. To avoid this issue, |
83 | | -# SUITESPARSE_USE_FORTRAN has been set to OFF. This has little impact on |
84 | | -# SuiteSparse (it disables the AMD Fortran routines, and removes the |
85 | | -# Fortran interface to UMFPACK). If you wish to use those features, |
86 | | -# re-enable the SUITESPARSE_USE_FORTRAN, but be sure to use either gcc |
87 | | -# and gfortran together, or icx and ifx together. Do not mix-and-match |
88 | | -# the compilers. |
| 75 | +# *** WARNING: Using the Intel icx compiler, the Intel MKL BLAS, and the |
| 76 | +# GNU Fortran compiler together will result in two OpenMP libraries |
| 77 | +# linked to the UMFPACK, CHOLMOD, ParU, and SPQR libraries. This will |
| 78 | +# cause serious performance issues. This cmake file detects if icx and |
| 79 | +# gfortran are in use, and issues a fatal error. Otherwise, if the C, |
| 80 | +# C++, and Fortran compilers have a different compiler ID, a warning is |
| 81 | +# issued; this is NOT recommended, but it might be OK. In that case, |
| 82 | +# ensure that you are linking with just one OpenMP library. If this |
| 83 | +# occurs, disable the use of Fortran by setting SUITESPARSE_USE_FORTRAN |
| 84 | +# to OFF, use a suite of C/C++/Fortran compilers with the same ID, |
| 85 | +# or ensure that all your compiled libraries link against a single |
| 86 | +# OpenMP library. |
89 | 87 | # |
90 | 88 | # SUITESPARSE_PKGFILEDIR: Directory where CMake Config and pkg-config files |
91 | 89 | # will be installed. By default, CMake Config files will |
@@ -301,13 +299,38 @@ endif ( ) |
301 | 299 | #------------------------------------------------------------------------------- |
302 | 300 |
|
303 | 301 | include ( CheckLanguage ) |
304 | | -option ( SUITESPARSE_USE_FORTRAN "ON: use Fortran. OFF (default): do not use Fortran" OFF ) |
| 302 | +option ( SUITESPARSE_USE_FORTRAN "ON (default): use Fortran. OFF: do not use Fortran" ON ) |
305 | 303 | if ( SUITESPARSE_USE_FORTRAN ) |
| 304 | + message ( STATUS "Checking if Fortran is available and compatible with C/C++" ) |
306 | 305 | check_language ( Fortran ) |
307 | 306 | if ( CMAKE_Fortran_COMPILER ) |
| 307 | + # Fortran is available; ensure that it is compatible with C/C++ |
| 308 | + enable_language ( CXX ) |
308 | 309 | enable_language ( Fortran ) |
309 | | - message ( STATUS "Fortran: ${CMAKE_Fortran_COMPILER}" ) |
310 | 310 | set ( SUITESPARSE_HAS_FORTRAN ON ) |
| 311 | + if ( NOT "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_C_COMPILER_ID}" OR |
| 312 | + NOT "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}" ) |
| 313 | + message ( STATUS " " ) |
| 314 | + message ( STATUS "Incompatible Fortran/C/C++ compilers detected:" ) |
| 315 | + message ( STATUS " Fortran: ${CMAKE_Fortran_COMPILER}" ) |
| 316 | + message ( STATUS " Fortran id: ${CMAKE_Fortran_COMPILER_ID}" ) |
| 317 | + message ( STATUS " C ${CMAKE_C_COMPILER}" ) |
| 318 | + message ( STATUS " C id: ${CMAKE_C_COMPILER_ID}" ) |
| 319 | + message ( STATUS " C++ ${CMAKE_CXX_COMPILER}" ) |
| 320 | + message ( STATUS " C++ id: ${CMAKE_CXX_COMPILER_ID}" ) |
| 321 | + if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "IntelLLVM" ) |
| 322 | + # icx/icpx cannot be used with gfortran: this is a fatal error |
| 323 | + message ( FATAL_ERROR "ERROR: Using Fortran with SuiteSparse requires that " |
| 324 | + " it has the same compiler ID as the C/C++ compilers." |
| 325 | + " Use a compatible Fortran compiler, or set SUITESPARSE_USE_FORTRAN to OFF." ) |
| 326 | + else ( ) |
| 327 | + # other cases: just issue a warning and hope it works. |
| 328 | + message ( WARNING "Warning: Using Fortran with SuiteSparse requires that " |
| 329 | + " it has the same compiler ID as the C/C++ compilers." |
| 330 | + " Use a compatible Fortran compiler, or set SUITESPARSE_USE_FORTRAN to OFF." ) |
| 331 | + endif ( ) |
| 332 | + endif ( ) |
| 333 | + message ( STATUS "Fortran: enabled" ) |
311 | 334 | else ( ) |
312 | 335 | # Fortran not available: |
313 | 336 | set ( SUITESPARSE_HAS_FORTRAN OFF ) |
|
0 commit comments