FindBLAS: IntelMKL cannot be found without C language
The problem arises from this line: https://gitlab.kitware.com/cmake/cmake/-/blob/v3.27.8/Modules/FindBLAS.cmake#L437
Reproducing:
cmake_minimum_required(VERSION 3.28)
project(test LANGUAGES Fortran)
find_package(BLAS REQUIRED)
Output:
cmake -Bbuild -DCMAKE_Fortran_COMPILER=gfortran
-- The Fortran compiler identification is GNU 12.2.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/cray/pe/gcc/12.2.0/bin/gfortran - skipped
CMake Error at /home/lokalgi/.local/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
/home/lokalgi/.local/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
/home/lokalgi/.local/share/cmake-3.28/Modules/FindBLAS.cmake:1383 (find_package_handle_standard_args)
CMakeLists.txt:6 (find_package)
If one enables C compiler:
cmake_minimum_required(VERSION 3.28)
project(test LANGUAGES Fortran C)
find_package(BLAS REQUIRED)
Configuration is successful:
cmake -Bbuild -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_C_COMPILER=gcc; rm -rf build
-- The Fortran compiler identification is GNU 12.2.0
-- The C compiler identification is GNU 12.2.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/cray/pe/gcc/12.2.0/bin/gfortran - skipped
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/cray/pe/gcc/12.2.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - found
-- Found BLAS: /project/lokalkorr/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_gf_lp64.so;/project/lokalkorr/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_gnu_thread.so;/project/lokalkorr/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_core.so;/opt/cray/pe/gcc/12.2.0/snos/lib64/libgomp.so;-lpthread;-lm;-ldl
-- Configuring done (2.9s)
-- Generating done (0.0s)
-- Build files have been written to
Edited by Brad King