Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake find module in pre-built distribution #4396

Open
nickanthony-dgl opened this issue Dec 27, 2023 · 4 comments
Open

CMake find module in pre-built distribution #4396

nickanthony-dgl opened this issue Dec 27, 2023 · 4 comments

Comments

@nickanthony-dgl
Copy link

I can see here that there is a template for a well made find module for OpenBLAS. However, the find module provided with the pre-built releases is extremely basic and doesn't work without modification.

Where does the nicer find module get used? Is there a reason not to include it with the download?

@martin-frbg
Copy link
Collaborator

The .cmake.in gets serves as a template during the install step to create the .cmake module. Which release did you look at ? I think there used to be a problem where the Makefile and CMake builds did not create the same "nice" quality module.

@nickanthony-dgl
Copy link
Author

I am using the 0.3.25-x64 release for Windows. The contents of OpenBLASConfig.cmake are:

SET(OpenBLAS_VERSION "0.3.25")
SET(OpenBLAS_INCLUDE_DIRS win64/include)
SET(OpenBLAS_LIBRARIES win64/bin/libopenblas.dll)

which doesn't work without some changes.

@martin-frbg
Copy link
Collaborator

Sorry, I really do not know how to improve this - the precompiled binaries are provided as a convenience for anybody who cannot build their own, and I have no idea where they would end up on a user's system. The paths you saw simply correspond to the (relative) install locations on my build host - which currently happens to be a Linux system with a mingw(gcc)-based cross-compiler

@nickanthony-dgl
Copy link
Author

Here is what I am using which I think would be an improvement.

SET(OpenBLAS_VERSION "0.3.25")
file(REAL_PATH "../../.." _OpenBLAS_ROOT_DIR BASE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} )
SET(OpenBLAS_INCLUDE_DIRS ${_OpenBLAS_ROOT_DIR}/include)
SET(OpenBLAS_LIBRARIES ${_OpenBLAS_ROOT_DIR}/bin/libopenblas.dll)
add_library(OpenBLAS::OpenBLAS SHARED IMPORTED)
target_include_directories(OpenBLAS::OpenBLAS INTERFACE ${OpenBLAS_INCLUDE_DIRS})
set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_LOCATION ${OpenBLAS_LIBRARIES})
set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB ${_OpenBLAS_ROOT_DIR}/lib/libopenblas.lib)

The user just needs to set an OpenBLAS_DIR cache variable that points to the location of the find module. The find module will provide the same OpenBLAS::OpenBLAS target that you gen when building from source or using VCPKG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants