Commit 2da37d13 authored by Dominik Charousset's avatar Dominik Charousset

Prevent duplicates in LIBCAF_INCLUDE_DIRS

parent c067ea95
# - Try to find user-defined components of libcaf # Try to find libcaf headers and library.
# Once done this will define
# #
# LIBCAF_INCLUDE_DIRS - include directories for all found components # Use this module as follows:
# LIBCAF_LIBRARY_$C - library for component $C #
# LIBCAF_FOUND - system has libcaf # find_package(Libcaf)
# LIBCAF_INCLUDE_DIRS - libcaf include dir #
# LIBCAF_LIBRARIES - link againgst libcaf # Variables used by this module (they can change the default behaviour and need
# LIBCAF_VERSION - version in {major}.{minor}.{patch} format # 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.
#
# 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
# iterate over user-defined components
foreach (comp ${Libcaf_FIND_COMPONENTS}) foreach (comp ${Libcaf_FIND_COMPONENTS})
# we use uppercase letters only for variable names
string(TOUPPER "${comp}" UPPERCOMP) string(TOUPPER "${comp}" UPPERCOMP)
if ("${comp}" STREQUAL "core") if ("${comp}" STREQUAL "core")
set(HDRNAME "caf/all.hpp") set(HDRNAME "caf/all.hpp")
else () else ()
set(HDRNAME "caf/${comp}/all.hpp") set(HDRNAME "caf/${comp}/all.hpp")
endif () endif ()
message(STATUS "Search for libcaf_${comp} and ${HDRNAME}") # 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" directory structure directly
set(HDRHINT "actor-framework/libcaf_${comp}") set(HDRHINT "actor-framework/libcaf_${comp}")
unset(LIBCAF_INCLUDE_DIR)
find_path(LIBCAF_INCLUDE_DIR_${UPPERCOMP} find_path(LIBCAF_INCLUDE_DIR_${UPPERCOMP}
NAMES NAMES
${HDRNAME} ${HDRNAME}
...@@ -33,10 +48,21 @@ foreach (comp ${Libcaf_FIND_COMPONENTS}) ...@@ -33,10 +48,21 @@ foreach (comp ${Libcaf_FIND_COMPONENTS})
../../../${HDRHINT}) ../../../${HDRHINT})
mark_as_advanced(LIBCAF_INCLUDE_DIR_${UPPERCOMP}) mark_as_advanced(LIBCAF_INCLUDE_DIR_${UPPERCOMP})
if ("${LIBCAF_INCLUDE_DIR_${UPPERCOMP}}" STREQUAL "LIBCAF_INCLUDE_DIR_${UPPERCOMP}-NOTFOUND") if ("${LIBCAF_INCLUDE_DIR_${UPPERCOMP}}" STREQUAL "LIBCAF_INCLUDE_DIR_${UPPERCOMP}-NOTFOUND")
# exit on first error
break () break ()
else () else ()
message(STATUS "Found headers for ${HDRNAME}") # add to LIBCAF_INCLUDE_DIRS only if path isn't already set
set(duplicate false)
foreach (p ${LIBCAF_INCLUDE_DIRS})
if (${p} STREQUAL ${LIBCAF_INCLUDE_DIR_${UPPERCOMP}})
set(duplicate true)
endif ()
endforeach ()
if (NOT duplicate)
set(LIBCAF_INCLUDE_DIRS ${LIBCAF_INCLUDE_DIRS} ${LIBCAF_INCLUDE_DIR_${UPPERCOMP}})
endif()
endif () endif ()
# look for (.dll|.so|.dylib) file, again giving hints for non-installed CAFs
find_library(LIBCAF_LIBRARY_${UPPERCOMP} find_library(LIBCAF_LIBRARY_${UPPERCOMP}
NAMES NAMES
"caf_${comp}" "caf_${comp}"
...@@ -52,14 +78,19 @@ foreach (comp ${Libcaf_FIND_COMPONENTS}) ...@@ -52,14 +78,19 @@ foreach (comp ${Libcaf_FIND_COMPONENTS})
../../../actor-framework/build/lib) ../../../actor-framework/build/lib)
mark_as_advanced(LIBCAF_LIBRARY_${UPPERCOMP}) mark_as_advanced(LIBCAF_LIBRARY_${UPPERCOMP})
if ("${LIBCAF_LIBRARY_${UPPERCOMP}}" STREQUAL "LIBCAF_LIBRARY-NOTFOUND") if ("${LIBCAF_LIBRARY_${UPPERCOMP}}" STREQUAL "LIBCAF_LIBRARY-NOTFOUND")
# exit on first error
break () break ()
else () else ()
message(STATUS "Found lib: ${LIBCAF_LIBRARY_${UPPERCOMP}}") set(LIBCAF_LIBRARIES ${LIBCAF_LIBRARIES} ${LIBCAF_LIBRARY_${UPPERCOMP}})
endif () endif ()
endforeach () endforeach ()
# final steps to tell CMake we're done
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libcaf
mark_as_advanced( DEFAULT_MSG
LIBCAF_ROOT_DIR LIBCAF_LIBRARIES
LIBCAF_INCLUDE_DIRS) LIBCAF_INCLUDE_DIRS)
mark_as_advanced(LIBCAF_ROOT_DIR
LIBCAF_LIBRARIES
LIBCAF_INCLUDE_DIRS)
\ No newline at end of file
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