Skip to content

FindBLAS: Handle compilers that implicitly link BLAS libraries

On HPC systems, such as built by Cray (e.g. Cori (NERSC), Titan (ORNL), etc.) "compilers" may actually be compiler wrappers that implicitly link commonly used libraries. Examples of such libraries are MPI, BLAS, and LAPACK. FindBLAS.cmake was not aware of this possibility causing either CMake to fail when it did not find a BLAS library (even though this is not explicitly needed), or CMake might find an alternate BLAS library causing link time conflicts. The changes introduced have FindBLAS.cmake check first if BLAS is implicitly linked (in which case BLAS will be marked as found but BLAS_LIBRARIES will be empty), otherwise it will proceed with the usual approach of searching for commonly used BLAS libraries. One additional change was required because the code block for the Intel MKL detection was not protected by an if-statement to preserve prior found BLAS libraries. As the MKL libraries were searched for last they would take precedence over everything else. Hence adding that if-statement as needed to protect the detection of implicitly linked BLAS libraries caused a change in semantics such that all other BLAS libraries take precedence over the Intel MKL libraries. This was subsequently fixed by moving the Intel MKL detection forward so that this library is now the first one checked for (after checking for implicitly linked BLAS libraries). So no the order of priority is: implicitly linked BLAS libraries, Intel MKL, everything else just as before.

Edited by Brad King

Merge request reports