Skip to content
Merged
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
34 changes: 19 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ option(AF_WITH_NONFREE "Build ArrayFire nonfree algorithms" OFF)
option(AF_WITH_LOGGING "Build ArrayFire with logging support" ON)
option(AF_WITH_STACKTRACE "Add stacktraces to the error messages." ON)
option(AF_CACHE_KERNELS_TO_DISK "Enable caching kernels to disk" ON)
option(AF_WITH_STATIC_MKL "Link against static Intel MKL libraries" OFF)

if(WIN32)
set(AF_STACKTRACE_TYPE "Windbg" CACHE STRING "The type of backtrace features. Windbg(simple), None")
Expand Down Expand Up @@ -106,6 +107,7 @@ mark_as_advanced(
SPDLOG_BUILD_TESTING
ADDR2LINE_PROGRAM
Backtrace_LIBRARY
AF_WITH_STATIC_MKL
)

#Configure forge submodule
Expand Down Expand Up @@ -311,32 +313,34 @@ install(FILES ${ArrayFire_BINARY_DIR}/cmake/install/ArrayFireConfig.cmake
DESTINATION ${AF_INSTALL_CMAKE_DIR}
COMPONENT cmake)

if((USE_CPU_MKL OR USE_OPENCL_MKL) AND TARGET MKL::Shared AND AF_INSTALL_STANDALONE)
if((USE_CPU_MKL OR USE_OPENCL_MKL) AND AF_INSTALL_STANDALONE)
if(TARGET MKL::ThreadingLibrary)
install(FILES
$<TARGET_FILE:MKL::ThreadingLibrary>
DESTINATION ${AF_INSTALL_LIB_DIR}
COMPONENT mkl_dependencies)
endif()

if(NOT WIN32)
if(NOT AF_WITH_STATIC_MKL AND TARGET MKL::Shared)
if(NOT WIN32)
install(FILES
$<TARGET_FILE:MKL::Interface>
DESTINATION ${AF_INSTALL_LIB_DIR}
COMPONENT mkl_dependencies)
endif()

install(FILES
$<TARGET_FILE:MKL::Interface>
$<TARGET_FILE:MKL::Shared>
$<TARGET_FILE:MKL::ThreadLayer>
${MKL_RUNTIME_KERNEL_LIBRARIES}

# This variable is used to add tbb.so.2 library because the main lib
# is a linker script and not a symlink so it cant be resolved using
# get_filename_component
${AF_ADDITIONAL_MKL_LIBRARIES}
DESTINATION ${AF_INSTALL_LIB_DIR}
COMPONENT mkl_dependencies)
endif()

install(FILES
$<TARGET_FILE:MKL::Shared>
$<TARGET_FILE:MKL::ThreadLayer>
${MKL_RUNTIME_KERNEL_LIBRARIES}

# This variable is used to add tbb.so.2 library because the main lib
# is a linker script and not a symlink so it cant be resolved using
# get_filename_component
${AF_ADDITIONAL_MKL_LIBRARIES}
DESTINATION ${AF_INSTALL_LIB_DIR}
COMPONENT mkl_dependencies)
endif()

# This file will be used to create the config file for the build directory.
Expand Down
6 changes: 2 additions & 4 deletions src/api/unified/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ target_link_libraries(af
# pass the RTLD_GLOBAL flag to dlload, but that causes issues with the ArrayFire
# libraries. To get around this we are also linking the unified backend with
# the MKL library
if((USE_CPU_MKL OR USE_OPENCL_MKL) AND TARGET MKL::Shared)
target_link_libraries(af
PRIVATE
MKL::Shared)
if((USE_CPU_MKL OR USE_OPENCL_MKL) AND TARGET MKL::Shared AND NOT AF_WITH_STATIC_MKL)
target_link_libraries(af PRIVATE MKL::Shared)
endif()


Expand Down
6 changes: 5 additions & 1 deletion src/backend/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,13 @@ if(USE_CPU_MKL)
cpp_api_interface
afcommon_interface
cpu_sort_by_key
MKL::Shared
Threads::Threads
)
if(AF_WITH_STATIC_MKL)
target_link_libraries(afcpu PRIVATE MKL::Static)
else()
target_link_libraries(afcpu PRIVATE MKL::Shared)
endif()
else()
dependency_check(FFTW_FOUND "FFTW not found")
dependency_check(CBLAS_FOUND "CBLAS not found")
Expand Down
8 changes: 5 additions & 3 deletions src/backend/opencl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,11 @@ if(LAPACK_FOUND OR MKL_Shared_FOUND)
dependency_check(MKL_Shared_FOUND "MKL not found")
target_compile_definitions(afopencl PRIVATE USE_MKL)

target_link_libraries(afopencl
PRIVATE
MKL::Shared)
if(AF_WITH_STATIC_MKL)
target_link_libraries(afopencl PRIVATE MKL::Static)
else()
target_link_libraries(afopencl PRIVATE MKL::Shared)
endif()
else()
dependency_check(OpenCL_FOUND "OpenCL not found.")

Expand Down