Skip to content

Commit

Permalink
Merge pull request #144 from tdegeus/cmake
Browse files Browse the repository at this point in the history
CMake: Adding target "xtensor-blas" which readily links lapack and blas
  • Loading branch information
JohanMabille committed Dec 6, 2019
2 parents eaf8262 + 2c41803 commit 3351826
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ set(XTENSOR_BLAS_HEADERS
${INCLUDE_DIR}/xtensor-blas/xlinalg.hpp
)

add_library(xtensor-blas INTERFACE)

target_include_directories(xtensor-blas
INTERFACE
$<BUILD_INTERFACE:${XTENSOR_BLAS_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)

OPTION(CXXBLAS_DEBUG "print cxxblas debug information" OFF)
OPTION(XTENSOR_USE_FLENS_BLAS "use FLENS generic implementation instead of cblas" OFF)
# Decide whether to use OpenBLAS or not.
Expand Down Expand Up @@ -108,6 +115,13 @@ endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

install(TARGETS xtensor-blas
EXPORT ${PROJECT_NAME}-targets)

# Makes the project importable from the build directory
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")

install(FILES ${XTENSOR_BLAS_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtensor-blas)

Expand Down Expand Up @@ -138,3 +152,7 @@ set(CMAKE_SIZEOF_VOID_P ${_XTENSOR_CMAKE_SIZEOF_VOID_P})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${XTENSOR_BLAS_CMAKECONFIG_INSTALL_DIR})

install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION ${XTENSOR_BLAS_CMAKECONFIG_INSTALL_DIR})
11 changes: 11 additions & 0 deletions xtensor-blasConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@

@PACKAGE_INIT@

if(NOT TARGET @PROJECT_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
get_target_property(@PROJECT_NAME@_INCLUDE_DIRS xtensor-blas INTERFACE_INCLUDE_DIRECTORIES)
find_dependency(BLAS REQUIRED)
find_dependency(LAPACK REQUIRED)
target_link_libraries(xtensor-blas INTERFACE ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.8)
target_compile_features(xtensor-blas INTERFACE cxx_std_14)
endif()
endif()

set(PN xtensor_blas)
set_and_check(TEMP_XTENSOR_BLAS_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
set(${PN}_INCLUDE_DIRS "${TEMP_XTENSOR_BLAS_INCLUDE_DIR}")
Expand Down

0 comments on commit 3351826

Please sign in to comment.