]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/jaeger-client-cpp/cmake/Findnlohmann_json.cmake
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / jaeger-client-cpp / cmake / Findnlohmann_json.cmake
1 # - Try to find nlohmann_json
2 #
3 # The following variables are optionally searched for defaults
4 # nlohmann_json_ROOT_DIR: Base directory where all GLOG components are found
5 #
6 # The following are set after configuration is done:
7 # nlohmann_json_FOUND
8 # nlohmann_json_INCLUDE_DIRS
9 # nlohmann_json_LIBRARIES
10
11 include(FindPackageHandleStandardArgs)
12
13 # only look in default directories
14 set(nlohmann_json_INCLUDE_NAME "nlohmann/json.hpp")
15
16 find_path(nlohmann_json_INCLUDE_DIR
17 NAMES
18 nlohmann/json.hpp
19 PATHS /usr/local/include
20 /usr/include)
21
22 if (NOT nlohmann_json_INCLUDE_DIR)
23 set(nlohmann_json_INCLUDE_NAME "json.hpp")
24 find_path(
25 nlohmann_json_INCLUDE_DIR
26 NAMES "${nlohmann_json_INCLUDE_NAME}"
27 )
28 endif()
29
30
31 # Version detection. Unfortunately the header doesn't expose a proper version
32 # define.
33 if (nlohmann_json_INCLUDE_DIR AND nlohmann_json_INCLUDE_NAME)
34 file(READ "${nlohmann_json_INCLUDE_DIR}/${nlohmann_json_INCLUDE_NAME}" NL_HDR_TXT LIMIT 1000)
35 if (NL_HDR_TXT MATCHES "version ([0-9]+\.[0-9]+\.[0-9]+)")
36 set(nlohmann_json_VERSION "${CMAKE_MATCH_1}")
37 endif()
38 endif()
39
40 set(nlohmann_json_VERSION "${nlohmann_json_VERSION}" CACHE STRING "nlohmann header version")
41
42 # handle the QUIETLY and REQUIRED arguments and set nlohmann_json_FOUND to TRUE
43 # if all listed variables are TRUE, hide their existence from configuration view
44 include(FindPackageHandleStandardArgs)
45 find_package_handle_standard_args(
46 nlohmann_json
47 REQUIRED_VARS nlohmann_json_INCLUDE_DIR nlohmann_json_INCLUDE_NAME
48 VERSION_VAR nlohmann_json_VERSION)
49
50 if(nlohmann_json_FOUND AND NOT (TARGET nlohmann_json))
51 add_library(nlohmann_json SHARED IMPORTED)
52 set_target_properties(nlohmann_json PROPERTIES
53 INTERFACE_INCLUDE_DIRECTORIES "${nlohmann_json_INCLUDE_DIR}"
54 )
55 endif()