68 lines
2.3 KiB
CMake
68 lines
2.3 KiB
CMake
#--- FindDKS ------------------------------------------------------------------
|
|
#
|
|
# This module defines:
|
|
# DKS_INCLUDE_DIR, where to find DKSBaseMuSR.h
|
|
# DKS_LIBS, shared library to be linked against if using DKS
|
|
# DKS_CFLAGS, compiler flags needed for DKS
|
|
#
|
|
# **as35** since I currently also maintaing the DKS library, it should add
|
|
# a DKSConfig.cmake which eventually will make this module obsolate. This
|
|
# means this module is only a kick starter.
|
|
|
|
find_path(DKS_INCLUDE_DIR DKSBaseMuSR.h
|
|
HINTS "/usr/include" "/opt/local/include" "$ENV{HOME}/Apps/DKS/exec/include"
|
|
"$ENV{HOME}/Applications/DKS/exec/include"
|
|
)
|
|
|
|
# find position of DKSBaseMuSR.h from the end
|
|
string(FIND "${DKS_INCLUDE_DIR}" "/DKSBaseMuSR.h" pos REVERSE)
|
|
# truncate the string
|
|
string(SUBSTRING "${DKS_INCLUDE_DIR}" 0 ${pos} substr)
|
|
set(DKS_INCLUDE_DIR ${substr})
|
|
unset(substr)
|
|
|
|
find_library(DKS_LIBRARY dksshared
|
|
HINTS "/usr/lib" "/usr/lib64" "/opt/local/lib" "$ENV{HOME}/Apps/DKS/exec/lib"
|
|
"$ENV{HOME}/Applications/DKS/exec/lib"
|
|
)
|
|
|
|
if (CUDA_FOUND)
|
|
set(DKS_CFLAGS -DDKS_OPENCL -DDKS_CUDA -I${DKS_INCLUDE_DIR} -I${CUDA_INCLUDE_DIRS})
|
|
set(DKS_LIBS ${CUDA_LIBRARIES} ${DKS_LIBRARY})
|
|
else (CUDA_FOUND)
|
|
if (OpenCL_FOUND)
|
|
if (APPLE)
|
|
set(DKS_CFLAGS -DDKS_OPENCL -I${DKS_INCLUDE_DIR} -I${OpenCL_INCLUDE_DIRS})
|
|
set(DKS_LIBS ${OpenCL_LIBRARY} ${DKS_LIBRARY})
|
|
else (APPLE)
|
|
set(DKS_CFLAGS -DDKS_OPENCL -I${DKS_INCLUDE_DIR} -I${OpenCL_INCLUDE_DIRS})
|
|
set(DKS_LIBS ${OpenCL_LIBRARY} ${DKS_LIBRARY})
|
|
endif (APPLE)
|
|
else (OpenCL_FOUND)
|
|
message(FATAL "neither CUDA nor OpenCL found when looking for DKS.")
|
|
endif (OpenCL_FOUND)
|
|
endif (CUDA_FOUND)
|
|
|
|
# as35 set here the DKS version explicitly. This is VERY ugly and should be fixed
|
|
# asap by using a package
|
|
set(DKS_VERSION "1.1.3")
|
|
|
|
# handle the QUIETLY and REQUIRED arguments and set DKS_FOUND to TRUE if
|
|
# all listed variables are TRUE
|
|
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
|
find_package_handle_standard_args(DKS
|
|
REQUIRED_VARS DKS_CFLAGS DKS_LIBS DKS_INCLUDE_DIR
|
|
VERSION_VAR DKS_VERSION)
|
|
|
|
if (NOT DKS_FOUND)
|
|
unset(DKS_CFLAGS)
|
|
unset(DKS_LIBS)
|
|
endif (NOT DKS_FOUND)
|
|
|
|
mark_as_advanced(
|
|
DKS_INCLUDE_DIR
|
|
DKS_CFLAGS
|
|
DKS_LIBS
|
|
)
|
|
|