How to tell plugin which blas library is used?

Hey, I’m writing a plugin for Psi4 and I’m hoping to use BLAS in it. I realize that I don’t need “find_package blas” in my plugin cmake, but when I run the plugin, the version (OpenBLAS vs MKL) depends on how psi4 was built. I’m hoping to use a macro to tell the plugin compiler if MKL BLAS will be used at run time so it can compile with the particular sections of the code accordingly, however I’m having some trouble.
Firstly, it seems to me that by compiling psi4 with BLAS_TYPE=MKL or OPENBLAS cmake options, the plugin still uses the same BLAS version. However, it seems that the python used to compile psi4 might be the one determining it: if numpy uses MKL, then the MKL BLAS is used in the plugin. Could someone please confirm if this is true?
Secondly, I tried directly using “ifdef USING_LAPACK_MKL” in my plugin, the compiler always reacts as the macro is undefined. Is this the correct variable I should use? How should I change my plugin CMakeLists.txt to allow it to retrieve the variable from psi4 compling procedure? Or should I try a different way?

P.S. Function ZDOTC is defined differently in MKL blas. Since psi4 doesn’t have wrappers for Z functions, I built them myself, and I tried to keep everything in the same way as libqt.

OpenBLAS won’t work reliably threaded, so just use MKL. USING_LAPACK_MKL is a compile definition that comes with tgt::lapack, so you’ll have to find_package(TargetLAPACK) and target_link_library(your_target PRIVATE tgt::lapack) to make it aware. Yes, psi4’s lapack must exactly match numpy’s see Notes here. Because of how link loaders work, if something loaded first pulls in a lapack with a fn, then if your routine, loaded after, needs that fn, it uses the already present one. May as well add the “Z” fns to libqt, if you’re collecting them, imo.