summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/jaeger-client-cpp/cmake/FindOpenTracing.cmake
blob: 79413d17ecb1b766fb188d82f6a8f60dbfdd789f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#.rst:
# FindOpenTracing
# ------------
#
# This module finds the `OpenTracing` library.
#
# Imported target
# ^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` target:
#
# ``OpenTracing``
#   The Opentracing library, if found
#
# Result variables
# ^^^^^^^^^^^^^^^^
#
# This module sets the following
#
# ``OpenTracing_FOUND``
#   ``TRUE`` if system has OpenTracing
# ``OpenTracing_INCLUDE_DIRS``
#   The OpenTracing include directories
# ``OpenTracing_LIBRARIES``
#   The libraries needed to use OpenTracing
# ``OpenTracing_VERSION_STRING``
#   The OpenTracing version

#=============================================================================
# Copyright 2018 Mania Abdi, Inc.
# Copyright 2018 Mania Abdi
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
#  License text for the above reference.)

find_path(OpenTracing_INCLUDE_DIRS
  NAMES  opentracing/tracer.h
  HINTS
    ${OpenTracing_HOME}
    ENV OpenTracing_HOME
  PATH_SUFFIXES
      include
  )
message(STATUS "OpenTracing_INCLUDE_DIRS ${OpenTracing_INCLUDE_DIRS}")
find_library(OpenTracing_LIBRARIES NAMES
  opentracing libopentracing
  HINTS
    ${OpenTracing_HOME}
    ENV OpenTracing_HOME
  PATH_SUFFIXES
      lib lib64
  )
message(STATUS "opentracing libraries ${OpenTracing_LIBRARIES}")

if(OpenTracing_INCLUDE_DIRS AND OpenTracing_LIBRARIES)

  # will need specifically 1.5.x for successful working with Jaeger
  set(OpenTracing_VERSION_STRING "1.6.0")

  if(NOT TARGET OpenTracing::opentracing)
    add_library(OpenTracing::opentracing SHARED IMPORTED)
    set_target_properties(OpenTracing::opentracing PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${OpenTracing_INCLUDE_DIRS}"
      INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}
      IMPORTED_LINK_INTERFACE_LANGUAGES "C"
      IMPORTED_LOCATION "${OpenTracing_LIBRARIES}")
  endif()

  if(NOT TARGET OpenTracing::opentracing-static)
    add_library(OpenTracing::opentracing-static STATIC IMPORTED)
    set_target_properties(OpenTracing::opentracing-static PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${OpenTracing_INCLUDE_DIRS}"
      INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}
      IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
      IMPORTED_LOCATION "${OpenTracing_LIBRARIES}")
  endif()
  message(STATUS "include opentracing ${OpenTracing_INCLUDE_DIRS}")

  # add libdl to required libraries
  set(OpenTracing_LIBRARIES ${OpenTracing_LIBRARIES} ${CMAKE_DL_LIBS})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenTracing FOUND_VAR OpenTracing_FOUND
                                  REQUIRED_VARS OpenTracing_LIBRARIES
                                                OpenTracing_INCLUDE_DIRS
                                  VERSION_VAR OpenTracing_VERSION_STRING)
mark_as_advanced(OpenTracing_LIBRARIES OpenTracing_INCLUDE_DIRS)