musrfit/cmake/FindDKS.cmake

48 lines
1.6 KiB
CMake

#--- FindDKS ------------------------------------------------------------------
#
# This module defines:
# DKS_INCLUDE_DIR, where to find DKSBaseMuSR.h
# DKS_LIBRARY, shared library to be linked against if using 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"
)
# 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_LIBRARY DKS_INCLUDE_DIR
VERSION_VAR DKS_VERSION)
if (NOT DKS_FOUND)
unset(DKS_LIBRARY)
endif (NOT DKS_FOUND)
mark_as_advanced(
DKS_INCLUDE_DIR
DKS_LIBRARY
)