|
72 | 72 | # for your system. |
73 | 73 | # Default: ON |
74 | 74 | # |
| 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. |
| 87 | +# |
75 | 88 | # SUITESPARSE_PKGFILEDIR: Directory where CMake Config and pkg-config files |
76 | 89 | # will be installed. By default, CMake Config files will |
77 | 90 | # be installed in the subfolder `cmake` of the directory |
@@ -288,11 +301,36 @@ endif ( ) |
288 | 301 | include ( CheckLanguage ) |
289 | 302 | option ( SUITESPARSE_USE_FORTRAN "ON (default): use Fortran. OFF: do not use Fortran" ON ) |
290 | 303 | if ( SUITESPARSE_USE_FORTRAN ) |
| 304 | + message ( STATUS "Checking if Fortran is available and compatible with C/C++" ) |
291 | 305 | check_language ( Fortran ) |
292 | 306 | if ( CMAKE_Fortran_COMPILER ) |
| 307 | + # Fortran is available; ensure that it is compatible with C/C++ |
| 308 | + enable_language ( CXX ) |
293 | 309 | enable_language ( Fortran ) |
294 | | - message ( STATUS "Fortran: ${CMAKE_Fortran_COMPILER}" ) |
295 | 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" ) |
296 | 334 | else ( ) |
297 | 335 | # Fortran not available: |
298 | 336 | set ( SUITESPARSE_HAS_FORTRAN OFF ) |
|
0 commit comments