The `FindBLAS` CMake module supports options `BLA_VENDOR` (which enables one to specify a BLAS implementation), and `BLA_PREFER_PKGCONFIG` (which controls whether pkg-config should be used to do the lookup).
The Gentoo ebuild has a patch that overrides used input for `BLA_PREFER_PKGCONFIG`:
+# first, try PkgConfig
This breaks CMake projects using `FindBLAS` with `BLA_VENDOR` set and `BLA_PREFER_PKGCONFIG=OFF`, since the `BLA_VENDOR` constraint will not be used as `BLA_PREFER_PKGCONFIG=OFF` gets overridden.
A simple fix would be to replace the above with:
if(NOT DEFINED BLA_PREFER_PKGCONFIG)
This would still override upstream CMake defaults, and would need any CMake project using `FindBLAS` to accomodate for Gentoo's customization, but at least it would give them a way to, unlike now.
A real fix would be to remove this tweak altogether, and patch each Gentoo CMake project that calls `FindBLAS` to `set(BLA_PREFER_PKGCONFIG ON)` before the `find_package(BLAS)` call.
It would help to see an example of the failure (inc. any relevant CMakeError/Info.txt files, but also the full build.log + emerge --info).
I may have not been clear in my explanations: up to CMake 3.17, Gentoo patches the `FindBLAS` module in such a way (https://github.com/gentoo/gentoo/blob/master/dev-util/cmake/files/cmake-3.17.0_rc1-FindBLAS.patch) that the default behavior in Gentoo differs from the default behavior in upstream CMake.
More specifically, this materializes when the input variable `BLA_PREFER_PKGCONFIG` is set to `OFF`: outside of Gentoo pkg-config is then not used, while in Gentoo, it is used regardless as (`BLA_PREFER_PKGCONFIG` is overridden by the patch and set to `ON` despite the user explicitly setting it to `OFF`).
I was wondering why this is useful but it's because of e.g.:
[22:38:54] <beauby> sam_: Yeah sorry I got distracted :D My use-case is not for Gentoo components, but using CMake to build third party projects (specifically one library that explicitly relies on mkl)
To expand on the above remark, the use-case would be using CMake to build third-party projects (not ebuilds) that explicitly depend on a specific BLAS implem (for instance MKL) without forcing the user to change their system-wide default BLAS implem.