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
64 changes: 64 additions & 0 deletions ArrayFireConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Defines the following variables:
# ArrayFire_INCLUDE_DIRS - Location of ArrayFire's include directory.
# ArrayFire_LIBRARIES - Location of ArrayFire's libraries. This will default
# to a GPU backend if one is found.
# ArrayFire_FOUND - True if ArrayFire has been located
#
# You may provide a hint to where ArrayFire's root directory may be located
# by setting ArrayFire_DIR.
#
# ----------------------------------------------------------------------------
#
# ArrayFire_CPU_FOUND - True of the ArrayFire CPU library has been found.
# ArrayFire_CPU_LIBRARIES - Location of ArrayFire's CPU library, if found
# ArrayFire_CUDA_FOUND - True of the ArrayFire CUDA library has been found.
# ArrayFire_CUDA_LIBRARIES - Location of ArrayFire's CUDA library, if found
# ArrayFire_OpenCL_FOUND - True of the ArrayFire OpenCL library has been found.
# ArrayFire_OpenCL_LIBRARIES - Location of ArrayFire's OpenCL library, if found
#
#=============================================================================
# Copyright (c) 2015, ArrayFire
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# * Neither the name of the ArrayFire nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================

get_filename_component(ArrayFire_INCLUDE_DIRS "@INCLUDE_DIR@" ABSOLUTE)

# keep in the backends in the slowest to fastest order
foreach(backend CPU OpenCL CUDA)
string(TOLOWER "${backend}" lowerbackend)
set(targetFile ${CMAKE_CURRENT_LIST_DIR}/@BACKEND_DIR@/ArrayFire${backend}.cmake)
if(EXISTS ${targetFile})
include(${targetFile})
set(ArrayFire_${backend}_FOUND ON)
set(ArrayFire_${backend}_LIBRARIES af${lowerbackend})
# set the default backend
set(ArrayFire_LIBRARIES af${lowerbackend})
else()
set(ArrayFire_${backend}_FOUND OFF)
endif()
endforeach()
73 changes: 73 additions & 0 deletions ArrayFireConfigVersion.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#=============================================================================
# Copyright (c) 2015, ArrayFire
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# * Neither the name of the ArrayFire nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================

# This is a basic version file for the Config-mode of find_package().
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
# but only if the requested major version is the same as the current one.


set(PACKAGE_VERSION "@AF_VERSION@@AF_VERSION_MINOR@")

if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()

if("@AF_VERSION@@AF_VERSION_MINOR@" MATCHES "^([0-9]+)\\.")
set(ArrayFire_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
set(ArrayFire_VERSION_MAJOR "@AF_VERSION@@AF_VERSION_MINOR@")
endif()

if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${ArrayFire_VERSION_MAJOR}")
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else()
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()

if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()


# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
return()
endif()

# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@")
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ ENDIF()

INCLUDE(${CMAKE_MODULE_PATH}/Version.cmake)

IF(WIN32)
SET(ARRAYFIRE_CMAKE_DIR cmake)
ELSE()
SET(ARRAYFIRE_CMAKE_DIR share/ArrayFire)
ENDIF()

IF(${BUILD_CPU})
ADD_SUBDIRECTORY(src/backend/cpu)
ENDIF()
Expand Down Expand Up @@ -106,3 +112,28 @@ INSTALL(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include
INSTALL(FILES
${CMAKE_SOURCE_DIR}/include/af/version.h DESTINATION include/af/
)

## configuration to be used from the binary directory directly
SET(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
SET(BACKEND_DIR "src/backend/\${lowerbackend}")
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/ArrayFireConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ArrayFireConfig.cmake
@ONLY)

## installed cmake configuration
# use a relative dir to keep arrayfire relocatable
STRING(REGEX REPLACE "[^/]+" ".." reldir "${ARRAYFIRE_CMAKE_DIR}")
SET(INCLUDE_DIR "\${CMAKE_CURRENT_LIST_DIR}/${reldir}/include")
set(BACKEND_DIR)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/ArrayFireConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/Install/ArrayFireConfig.cmake
@ONLY)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/ArrayFireConfigVersion.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ArrayFireConfigVersion.cmake
@ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/Install/ArrayFireConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ArrayFireConfigVersion.cmake
DESTINATION ${ARRAYFIRE_CMAKE_DIR})
5 changes: 4 additions & 1 deletion src/backend/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,7 @@ ADD_LIBRARY(afcpu SHARED

TARGET_LINK_LIBRARIES(afcpu ${lib_deps} ${CBLAS_LIBRARIES} ${FFTW_LIBRARIES})

INSTALL(TARGETS afcpu DESTINATION lib)
INSTALL(TARGETS afcpu EXPORT CPU DESTINATION lib)

export(TARGETS afcpu FILE ArrayFireCPU.cmake)
INSTALL(EXPORT CPU DESTINATION ${ARRAYFIRE_CMAKE_DIR} FILE ArrayFireCPU.cmake)
5 changes: 4 additions & 1 deletion src/backend/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,7 @@ ADD_DEPENDENCIES(afcuda ${ptx_targets})

TARGET_LINK_LIBRARIES(afcuda ${CUDA_CUBLAS_LIBRARIES} ${CUDA_LIBRARIES} ${lib_deps} ${CUDA_CUFFT_LIBRARIES} ${CUDA_NVVM_LIBRARIES} ${CUDA_CUDA_LIBRARY})

INSTALL(TARGETS afcuda DESTINATION lib)
INSTALL(TARGETS afcuda EXPORT CUDA DESTINATION lib)

export(TARGETS afcuda FILE ArrayFireCUDA.cmake)
INSTALL(EXPORT CUDA DESTINATION ${ARRAYFIRE_CMAKE_DIR} FILE ArrayFireCUDA.cmake)
20 changes: 19 additions & 1 deletion src/backend/opencl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,22 @@ ADD_DEPENDENCIES(afopencl ${cl_kernel_targets})

TARGET_LINK_LIBRARIES(afopencl ${OPENCL_LIBRARIES} ${lib_deps} ${CLBLAS_LIBRARIES} ${CLFFT_LIBRARIES} ${CMAKE_DL_LIBS} ${Boost_LIBRARIES})

INSTALL(TARGETS afopencl DESTINATION lib)
# locally built but not installed libraries (clBLAS and clFFT) must NOT appear in the
# link interface. The best option would be to use LINK_PRIVATE, but unfortunately
# it is not available for older cmake than 2.8.7, so they must be remove from
# the link interface manually. Both LINK_INTERFACE_LIBRARIES and INTERFACE_LINK_LIBRARIES
# are used to keep it working with older cmake versions that 2.8.12 and avoid
# warnings on newer versions - see CMP0022
FOREACH(property LINK_INTERFACE_LIBRARIES INTERFACE_LINK_LIBRARIES)
GET_TARGET_PROPERTY(value afopencl ${property})
IF(value)
LIST(REMOVE_ITEM value ${CLBLAS_LIBRARIES} ${CLFFT_LIBRARIES})
SET_TARGET_PROPERTIES(afopencl PROPERTIES LINK_INTERFACE_LIBRARIES "${value}")
SET_TARGET_PROPERTIES(afopencl PROPERTIES INTERFACE_LINK_LIBRARIES "${value}")
ENDIF()
ENDFOREACH()

INSTALL(TARGETS afopencl EXPORT OpenCL DESTINATION lib)

export(TARGETS afopencl FILE ArrayFireOpenCL.cmake)
INSTALL(EXPORT OpenCL DESTINATION ${ARRAYFIRE_CMAKE_DIR} FILE ArrayFireOpenCL.cmake)