Skip to content
Snippets Groups Projects
Commit dbb83409 authored by Laurent Petre's avatar Laurent Petre
Browse files

Merge branch 'feature/find-xdaq-nlohmann' into 'develop'

Add support for nlohmann-json (from xDAQ)

Closes #83

See merge request cmsgemonline/cmsgemos!119
parents 60bec733 aebdc204
No related branches found
No related tags found
1 merge request!119Add support for nlohmann-json (from xDAQ)
Pipeline #2417012 failed
......@@ -58,7 +58,7 @@ find_package(PkgConfig REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem iostreams system unit_test_framework)
find_package(CACTUS REQUIRED COMPONENTS amc13_amc13 uhal_uhal uhal_log)
find_package(xDAQ REQUIRED COMPONENTS cgicc config log4cplus tstore toolbox xcept xdaq xdaq2rc xdata xerces-c xgi xoap)
find_package(xDAQ REQUIRED COMPONENTS cgicc config log4cplus nlohmann tstore toolbox xcept xdaq xdaq2rc xdata xerces-c xgi xoap)
pkg_check_modules(YAMLCpp REQUIRED IMPORTED_TARGET yaml-cpp)
# xHAL is considered as an external dependency
......
......@@ -20,6 +20,7 @@
# * `logudpappender`
# * `logxmlappender`
# * `mimetic`
# * `nlohmann` (JSON)
# * `occi`
# * `peer`
# * `toolbox`
......@@ -68,10 +69,11 @@ set(xdaq_all_libs "")
# Declares a library that can be required using the COMPONENTS argument
macro(_xdaq_library name)
cmake_parse_arguments(ARG "THREADS;NO_SONAME" "HEADER" "DEPENDS" ${ARGN})
cmake_parse_arguments(ARG "HEADER_ONLY;THREADS;NO_SONAME" "HEADER" "DEPENDS" ${ARGN})
set(xdaq_${name}_threads ${ARG_THREADS})
set(xdaq_${name}_header ${ARG_HEADER})
set(xdaq_${name}_header_only ${ARG_HEADER_ONLY})
set(xdaq_${name}_depends ${ARG_DEPENDS})
set(xdaq_${name}_nosoname ${ARG_NO_SONAME})
list(APPEND xdaq_all_libs ${name})
......@@ -89,6 +91,7 @@ _xdaq_library(logudpappender HEADER "log4cplus/log4judpappender.h"
_xdaq_library(logxmlappender HEADER "log/xmlappender/version.h"
DEPENDS config log4cplus NO_SONAME)
_xdaq_library(mimetic HEADER "mimetic/version.h")
_xdaq_library(nlohmann HEADER "nlohmann/json.hpp" HEADER_ONLY)
_xdaq_library(occi HEADER "occi.h" DEPENDS clntsh)
_xdaq_library(peer HEADER "pt/version.h" DEPENDS config toolbox xcept xoap
THREADS NO_SONAME)
......@@ -172,7 +175,14 @@ list(REMOVE_DUPLICATES xdaq_requested_libs)
foreach(lib ${xDAQ_FIND_COMPONENTS})
set(xdaq_${lib}_required_variables xDAQ_${lib}_LIBRARY xDAQ_${lib}_INCLUDE_DIR)
foreach(dep ${xdaq_${lib}_recursive_depends})
list(APPEND xdaq_${lib}_required_variables xDAQ_${dep}_LIBRARY xDAQ_${dep}_INCLUDE_DIR)
list(APPEND xdaq_${lib}_required_variables xDAQ_${dep}_INCLUDE_DIR)
# Library
if(NOT xdaq_${dep}_header_only)
list(APPEND xdaq_${lib}_required_variables xDAQ_${dep}_LIBRARY)
else()
message(STATUS "${dep} is header only")
endif()
# Threads
if(xdaq_${dep}_threads)
......@@ -216,17 +226,19 @@ macro(_xdaq_import_lib name)
# Do nothing if already found
if(NOT TARGET xDAQ::${name})
# Try to find the library
find_library(
xDAQ_${name}_LIBRARY
${name}
NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH
HINTS ENV XDAQ_ROOT
PATHS /opt/xdaq/
PATH_SUFFIXES lib lib64
DOC "Path of xDAQ library ${name}")
mark_as_advanced(xDAQ_${name}_LIBRARY)
if(NOT xdaq_${name}_header_only)
# Try to find the library
find_library(
xDAQ_${name}_LIBRARY
${name}
NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH
HINTS ENV XDAQ_ROOT
PATHS /opt/xdaq/
PATH_SUFFIXES lib lib64
DOC "Path of xDAQ library ${name}")
mark_as_advanced(xDAQ_${name}_LIBRARY)
endif()
# Try to find the headers
find_path(
......@@ -240,7 +252,22 @@ macro(_xdaq_import_lib name)
mark_as_advanced(xDAQ_${name}_INCLUDE_DIR)
if(xDAQ_${name}_LIBRARY AND xDAQ_${name}_INCLUDE_DIR)
if(xdaq_${name}_header_only AND xDAQ_${name}_INCLUDE_DIR)
# Found!
set(xDAQ_${name}_FOUND TRUE)
# Create the target
add_library(xDAQ::${name} INTERFACE IMPORTED)
# Set include path
set_target_properties(
xDAQ::${name}
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${xDAQ_${name}_INCLUDE_DIR};${xDAQ_${name}_INCLUDE_DIR}/linux"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
"${xDAQ_${name}_INCLUDE_DIR};${xDAQ_${name}_INCLUDE_DIR}/linux")
elseif(xDAQ_${name}_LIBRARY AND xDAQ_${name}_INCLUDE_DIR)
# Found!
set(xDAQ_${name}_FOUND TRUE)
......@@ -309,7 +336,9 @@ set(xDAQ_INCLUDE_DIRS "")
set(xdaq_required_variables "")
foreach(lib ${xDAQ_FIND_COMPONENTS})
list(APPEND xDAQ_LIBRARIES ${xDAQ_${lib}_LIBRARY})
if(NOT xdaq_${lib}_header_only)
list(APPEND xDAQ_LIBRARIES ${xDAQ_${lib}_LIBRARY})
endif()
list(APPEND xDAQ_INCLUDE_DIRS ${xDAQ_${lib}_INCLUDE_DIR})
list(APPEND xdaq_required_variables ${xdaq_${lib}_required_variables})
endforeach()
......@@ -345,6 +374,7 @@ find_package_handle_standard_args(
foreach(name ${xdaq_all_libs})
unset(xdaq_${name}_threads)
unset(xdaq_${name}_header)
unset(xdaq_${name}_header_only)
unset(xdaq_${name}_depends)
unset(xdaq_${name}_nosoname)
unset(xdaq_${name}_recursive_depends)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment