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