cmake: make sure all DKS related libaries and include paths are properly set.

This commit is contained in:
2018-06-04 11:16:45 +02:00
parent b2c8b9b72b
commit 58148581ba
2 changed files with 32 additions and 12 deletions

View File

@ -2,7 +2,8 @@
#
# This module defines:
# DKS_INCLUDE_DIR, where to find DKSBaseMuSR.h
# DKS_LIBRARY, shared library to be linked against if using DKS
# 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
@ -25,6 +26,23 @@ find_library(DKS_LIBRARY dksshared
"$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")
@ -33,15 +51,17 @@ set(DKS_VERSION "1.1.3")
# all listed variables are TRUE
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(DKS
REQUIRED_VARS DKS_LIBRARY DKS_INCLUDE_DIR
REQUIRED_VARS DKS_CFLAGS DKS_LIBS DKS_INCLUDE_DIR
VERSION_VAR DKS_VERSION)
if (NOT DKS_FOUND)
unset(DKS_LIBRARY)
unset(DKS_CFLAGS)
unset(DKS_LIBS)
endif (NOT DKS_FOUND)
mark_as_advanced(
DKS_INCLUDE_DIR
DKS_LIBRARY
DKS_INCLUDE_DIR
DKS_CFLAGS
DKS_LIBS
)