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 defines after find_package not documented #24

Open
NAThompson opened this issue Dec 18, 2022 · 1 comment
Open

CMake defines after find_package not documented #24

NAThompson opened this issue Dec 18, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@NAThompson
Copy link

NAThompson commented Dec 18, 2022

I can easily find instructions on how to build blaspp, and succeeded in doing so. However, how to reference it in another CMake-managed project does not appear to be documented.

I have resorted to the following technique to see what CMake variables are defined after a successful find_package(blaspp REQUIRED):

cmake_minimum_required (VERSION 3.25.0)
project(try_blaspp)
get_directory_property(_vars_before VARIABLES)
find_package(blaspp REQUIRED)
get_directory_property(_vars VARIABLES)

list(REMOVE_ITEM _vars _vars_before ${_vars_before})
foreach(_var IN LISTS _vars)
    message(STATUS "${_var} = ${${_var}}")
endforeach()
add_executable(run main.cpp)
# This line will fail:
#target_include_directories(run PRIVATE ${blaspp_INCLUDE_DIRS})

This prints:

-- CONFIG_FILES = /opt/slate/lib/blaspp/blasppTargets-noconfig.cmake
-- _DIR = /opt/slate/lib/blaspp
-- blaspp_CONFIG = /opt/slate/lib/blaspp/blasppConfig.cmake
-- blaspp_CONSIDERED_CONFIGS = /opt/slate/lib/blaspp/blasppConfig.cmake
-- blaspp_CONSIDERED_VERSIONS = 2022.07.00
-- blaspp_FOUND = 1
-- blaspp_VERSION = 2022.07.00
-- blaspp_VERSION_COUNT = 3
-- blaspp_VERSION_MAJOR = 2022
-- blaspp_VERSION_MINOR = 7
-- blaspp_VERSION_PATCH = 0
-- blaspp_VERSION_TWEAK = 0
-- blaspp_cblas_found = true
-- blaspp_cblas_include = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Headers
-- blaspp_cblas_libraries =
-- blaspp_defines = -DBLAS_FORTRAN_ADD_;-DBLAS_HAVE_ACCELERATE;-DBLAS_COMPLEX_RETURN_ARGUMENT;-DBLAS_HAVE_F2C;-DBLAS_HAVE_ACCELERATE_CBLAS_H;-DBLAS_HAVE_CBLAS
-- blaspp_libraries = -framework Accelerate;OpenMP::OpenMP_CXX
-- blaspp_use_cuda = false
-- blaspp_use_hip = false
-- blaspp_use_openmp = true

I expected that one of these CMake variables should be set to /opt/slate/include, so that I can write (say)

target_include_directories(run PRIVATE ${blaspp_INCLUDE_DIRS})

yet blaspp_INCLUDE_DIRS does not appear to be defined, and hence the compile step fails:

main.cpp:3:10: fatal error: 'blas.hh' file not found
#include <blas.hh>
         ^~~~~~~~~
1 error generated.

If I hardcode the path to the blas include dir, I fail to link, necessitating hard coded path to the blas library, which again I cannot see in the defined CMake variables:

...
target_include_directories(run PRIVATE /opt/slate/include)
target_link_libraries(run PRIVATE /opt/slate/lib/libblaspp.dylib)
@mgates3
Copy link
Collaborator

mgates3 commented Dec 19, 2022

Thanks for the feedback. We will add documentation on how to integrate BLAS++ into an application. However, I don't understand the issue that you are having. It seems to be too complicated. Simply doing this works in the example directory:

#-------------------------------------------------------------------------------
find_package( blaspp REQUIRED )

#--------------------
add_executable(
    example_gemm
    example_gemm.cc
)
target_link_libraries(
    example_gemm
    blaspp
)

I don't find it necessary with CMake packages to explicitly get the path to their include directory — CMake should use it automatically.

@mgates3 mgates3 added the documentation Improvements or additions to documentation label Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants