Commit 456d50a7 authored by Dominik Charousset's avatar Dominik Charousset

Adopt CMake script file from VAST

parent b45136ea
# Try to find libcaf headers and library.
# Try to find CAF headers and libraries.
#
# Use this module as follows:
#
# find_package(Libcaf)
# find_package(CAF)
#
# Variables used by this module (they can change the default behaviour and need
# to be set before calling find_package):
#
# LIBCAF_ROOT_DIR Set this variable to the root installation of
# libcaf if the module has problems finding
# the proper installation path.
# CAF_ROOT_DIR Set this variable either to an installation prefix or to wa
# CAF build directory where to look for the CAF libraries.
#
# Variables defined by this module:
#
# LIBCAF_FOUND System has libcaf headers and library
# LIBCAF_LIBRARIES List of library files for all components
# LIBCAF_INCLUDE_DIRS List of include paths for all components
# LIBCAF_LIBRARY_$C Library file for component $C
# LIBCAF_INCLUDE_DIR_$C Include path for component $C
# CAF_FOUND System has CAF headers and library
# CAF_LIBRARIES List of library files for all components
# CAF_INCLUDE_DIRS List of include paths for all components
# CAF_LIBRARY_$C Library file for component $C
# CAF_INCLUDE_DIR_$C Include path for component $C
# iterate over user-defined components
foreach (comp ${Libcaf_FIND_COMPONENTS})
foreach (comp ${CAF_FIND_COMPONENTS})
# we use uppercase letters only for variable names
string(TOUPPER "${comp}" UPPERCOMP)
if ("${comp}" STREQUAL "core")
......@@ -28,69 +27,57 @@ foreach (comp ${Libcaf_FIND_COMPONENTS})
else ()
set(HDRNAME "caf/${comp}/all.hpp")
endif ()
# look for headers: give CMake hints where to find non-installed CAF versions
# note that we look for the headers of each component individually: this is
# necessary to support non-installed versions of CAF, i.e., accessing the
# checked out "actor-framework" or "caf" directory structure directly;
# also check whether LIBCAF_ROOT_DIR is a source directory
set(HDRHINT "${LIBCAF_ROOT_DIR}/libcaf_${comp}")
foreach(dir ".." "../.." "../../..")
foreach(subdir "actor-framework" "caf")
set(HDRHINT ${HDRHINT} "${dir}/${subdir}/libcaf_${comp}")
endforeach()
endforeach()
find_path(LIBCAF_INCLUDE_DIR_${UPPERCOMP}
if (CAF_ROOT_DIR)
set(header_hints
"${CAF_ROOT_DIR}/include"
"${CAF_ROOT_DIR}/../libcaf_${comp}")
endif ()
find_path(CAF_INCLUDE_DIR_${UPPERCOMP}
NAMES
${HDRNAME}
HINTS
${LIBCAF_ROOT_DIR}/include
HINTS
${header_hints}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
${CMAKE_INSTALL_PREFIX}/include
${HDRHINT})
mark_as_advanced(LIBCAF_INCLUDE_DIR_${UPPERCOMP})
if (NOT "${LIBCAF_INCLUDE_DIR_${UPPERCOMP}}" STREQUAL "LIBCAF_INCLUDE_DIR_${UPPERCOMP}-NOTFOUND")
${CMAKE_INSTALL_PREFIX}/include)
mark_as_advanced(CAF_INCLUDE_DIR_${UPPERCOMP})
if (NOT "${CAF_INCLUDE_DIR_${UPPERCOMP}}"
STREQUAL "CAF_INCLUDE_DIR_${UPPERCOMP}-NOTFOUND")
# mark as found (set back to false in case library cannot be found)
set(Libcaf_${comp}_FOUND true)
# add to LIBCAF_INCLUDE_DIRS only if path isn't already set
set(CAF_${comp}_FOUND true)
# add to CAF_INCLUDE_DIRS only if path isn't already set
set(duplicate false)
foreach (p ${LIBCAF_INCLUDE_DIRS})
if (${p} STREQUAL ${LIBCAF_INCLUDE_DIR_${UPPERCOMP}})
foreach (p ${CAF_INCLUDE_DIRS})
if (${p} STREQUAL ${CAF_INCLUDE_DIR_${UPPERCOMP}})
set(duplicate true)
endif ()
endforeach ()
if (NOT duplicate)
set(LIBCAF_INCLUDE_DIRS ${LIBCAF_INCLUDE_DIRS} ${LIBCAF_INCLUDE_DIR_${UPPERCOMP}})
set(CAF_INCLUDE_DIRS ${CAF_INCLUDE_DIRS} ${CAF_INCLUDE_DIR_${UPPERCOMP}})
endif()
# look for (.dll|.so|.dylib) file, again giving hints for non-installed CAFs
# skip probe_event as it is header only
if (NOT ${comp} STREQUAL "probe_event")
unset(LIBHINT)
foreach(dir ".." "../.." "../../..")
foreach(subdir "actor-framework" "caf")
set(LIBHINT ${LIBHINT} "${dir}/${subdir}/build/lib")
endforeach()
endforeach()
message(STATUS "libhint: ${LIBHINT}")
find_library(LIBCAF_LIBRARY_${UPPERCOMP}
if (CAF_ROOT_DIR)
set(library_hints "${CAF_ROOT_DIR}/lib")
endif ()
find_library(CAF_LIBRARY_${UPPERCOMP}
NAMES
"caf_${comp}"
HINTS
${LIBCAF_ROOT_DIR}/lib
${LIBCAF_ROOT_DIR}/build/lib
${library_hints}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
${CMAKE_INSTALL_PREFIX}/lib
${LIBHINT})
mark_as_advanced(LIBCAF_LIBRARY_${UPPERCOMP})
if ("${LIBCAF_LIBRARY_${UPPERCOMP}}" STREQUAL "LIBCAF_LIBRARY-NOTFOUND")
set(Libcaf_${comp}_FOUND false)
${CMAKE_INSTALL_PREFIX}/lib)
mark_as_advanced(CAF_LIBRARY_${UPPERCOMP})
if ("${CAF_LIBRARY_${UPPERCOMP}}" STREQUAL "CAF_LIBRARY-NOTFOUND")
set(CAF_${comp}_FOUND false)
else ()
set(LIBCAF_LIBRARIES ${LIBCAF_LIBRARIES} ${LIBCAF_LIBRARY_${UPPERCOMP}})
set(CAF_LIBRARIES ${CAF_LIBRARIES} ${CAF_LIBRARY_${UPPERCOMP}})
endif ()
endif ()
endif ()
......@@ -98,12 +85,13 @@ endforeach ()
# let CMake check whether all requested components have been found
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libcaf
FOUND_VAR LIBCAF_FOUND
REQUIRED_VARS LIBCAF_LIBRARIES LIBCAF_INCLUDE_DIRS
find_package_handle_standard_args(CAF
FOUND_VAR CAF_FOUND
REQUIRED_VARS CAF_LIBRARIES CAF_INCLUDE_DIRS
HANDLE_COMPONENTS)
# final step to tell CMake we're done
mark_as_advanced(LIBCAF_ROOT_DIR
LIBCAF_LIBRARIES
LIBCAF_INCLUDE_DIRS)
mark_as_advanced(CAF_ROOT_DIR
CAF_LIBRARIES
CAF_INCLUDE_DIRS)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment