Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,42 +207,47 @@ foreach(backend CPU CUDA OpenCL Unified)
install(EXPORT ArrayFire${backend}Targets
NAMESPACE ArrayFire::
DESTINATION ${AF_INSTALL_CMAKE_DIR}
COMPONENT cmake
)
COMPONENT cmake)

export( EXPORT ArrayFire${backend}Targets
NAMESPACE ArrayFire::
FILE ArrayFire${backend}Targets.cmake
)
FILE cmake/ArrayFire${backend}Targets.cmake)
endif()
endforeach()

set(INCLUDE_DIR include)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ArrayFireConfigVersion.cmake"
"${ArrayFire_BINARY_DIR}/cmake/ArrayFireConfigVersion.cmake"
COMPATIBILITY SameMajorVersion
)

# This config file will be installed so we need to set the install_destination
# path relitive to the install path
set(INCLUDE_DIRS include)
set(CMAKE_DIR ${AF_INSTALL_CMAKE_DIR})
configure_package_config_file(
${CMAKE_MODULE_PATH}/ArrayFireConfig.cmake.in
ArrayFireInstallConfig/ArrayFireConfig.cmake
cmake/install/ArrayFireConfig.cmake
INSTALL_DESTINATION "${AF_INSTALL_CMAKE_DIR}"
PATH_VARS INCLUDE_DIR AF_INSTALL_CMAKE_DIR
PATH_VARS INCLUDE_DIRS CMAKE_DIR
)

install(FILES ${ArrayFire_BINARY_DIR}/ArrayFireInstallConfig/ArrayFireConfig.cmake
${ArrayFire_BINARY_DIR}/ArrayFireConfigVersion.cmake
install(FILES ${ArrayFire_BINARY_DIR}/cmake/install/ArrayFireConfig.cmake
${ArrayFire_BINARY_DIR}/cmake/ArrayFireConfigVersion.cmake
DESTINATION ${AF_INSTALL_CMAKE_DIR}
COMPONENT cmake)

set(AF_INSTALL_CMAKE_DIR "${ArrayFire_BINARY_DIR}")

# This file will be used to create the config file for the build directory.
# These config files will be used by the examples to find the ArrayFire
# libraries
set(INCLUDE_DIRS "${ArrayFire_SOURCE_DIR}/include" "${ArrayFire_BINARY_DIR}/include")
set(CMAKE_DIR "${ArrayFire_BINARY_DIR}/cmake")
configure_package_config_file(
${CMAKE_MODULE_PATH}/ArrayFireConfig.cmake.in
${ArrayFire_BINARY_DIR}/ArrayFireConfig.cmake
INSTALL_DESTINATION "${ArrayFire_BINARY_DIR}"
PATH_VARS INCLUDE_DIR AF_INSTALL_CMAKE_DIR
cmake/ArrayFireConfig.cmake
INSTALL_DESTINATION "${ArrayFire_BINARY_DIR}/cmake"
PATH_VARS INCLUDE_DIRS CMAKE_DIR
INSTALL_PREFIX "${ArrayFire_BINARY_DIR}"
)

Expand Down
6 changes: 3 additions & 3 deletions CMakeModules/ArrayFireConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

@PACKAGE_INIT@

set_and_check(ArrayFire_INCLUDE_DIRS @PACKAGE_INCLUDE_DIR@)
set_and_check(ArrayFire_INCLUDE_DIRS @PACKAGE_INCLUDE_DIRS@)

foreach(backend Unified CPU OpenCL CUDA)
if(backend STREQUAL "Unified")
Expand All @@ -59,8 +59,8 @@ foreach(backend Unified CPU OpenCL CUDA)
string(TOLOWER "${backend}" lowerbackend)
endif()
if(NOT TARGET ArrayFire::af${lowerbackend})
if(EXISTS @PACKAGE_AF_INSTALL_CMAKE_DIR@/ArrayFire${backend}Targets.cmake)
include(@PACKAGE_AF_INSTALL_CMAKE_DIR@/ArrayFire${backend}Targets.cmake)
if(EXISTS @PACKAGE_CMAKE_DIR@/ArrayFire${backend}Targets.cmake)
include(@PACKAGE_CMAKE_DIR@/ArrayFire${backend}Targets.cmake)
endif()
endif()

Expand Down
7 changes: 2 additions & 5 deletions CMakeModules/InternalUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif()
endfunction()

macro(arrayfire_set_cmake_default_variables)
set(CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}prefix;${CMAKE_PREFIX_PATH}")
set(CMAKE_PREFIX_PATH "${ArrayFire_BINARY_DIR}/cmake;${CMAKE_PREFIX_PATH}")
set(BUILD_SHARED_LIBS ON)

set(CMAKE_CXX_STANDARD 11)
Expand Down Expand Up @@ -97,10 +97,7 @@ macro(arrayfire_set_cmake_default_variables)
endif()

if(APPLE)
# Brew does not put the glbinding cmake config files where it can be found
# TODO(umar) check if other systems have a similar problem
set(CMAKE_PREFIX_PATH "/usr/local/opt/glbinding;${CMAKE_PREFIX_PATH}")
# TODO(umar) Remove rpath to third_part lib
# TODO(umar) Remove rpath to third_party lib
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${AF_INSTALL_LIB_DIR};${ArrayFire_BINARY_DIR}/third_party/forge/lib")
endif()
endmacro()
6 changes: 0 additions & 6 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ function(target_compile_definitions target access definitions)
_target_compile_definitions(example_${target} ${access} ${definitions})
endfunction()

function(find_package args)
if(NOT (TARGET ArrayFire::afcpu OR TARGET ArrayFire::afcuda OR TARGET ArrayFire::afopencl OR TARGET ArrayFire::af))
_find_package(args)
endif()
endfunction()

add_subdirectory(benchmarks)
add_subdirectory(computer_vision)
add_subdirectory(financial)
Expand Down