|Summary:||dev-util/cmake: Gentoo patch breaks FindBLAS for development|
|Product:||Gentoo Linux||Reporter:||Lucas Hosseini <lucas.hosseini>|
|Component:||Current packages||Assignee:||Gentoo's Team for Core System packages <base-system>|
|Package list:||Runtime testing required:||---|
Description Lucas Hosseini 2020-08-09 17:11:18 UTC
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 ￼+set(BLA_PREFER_PKGCONFIG On) ``` 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) set(BLA_PREFER_PKGCONFIG ON) endif() ``` 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.
Comment 1 Sam James 2020-08-11 07:06:40 UTC
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).
Comment 2 Lucas Hosseini 2020-08-14 20:39:30 UTC
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`).
Comment 3 Sam James 2022-02-17 22:39:35 UTC
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)
Comment 4 Lucas Hosseini 2022-02-17 22:44:57 UTC
Thanks Sam. 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.