@@ -18,7 +18,18 @@ project(opentelemetry-fluentd)
1818
1919add_definitions (-DHAVE_CONSOLE_LOG)
2020add_definitions (-DENABLE_LOGS_PREVIEW)
21- find_package (opentelemetry-cpp REQUIRED)
21+
22+ find_package (opentelemetry-cpp QUIET )
23+ if (opentelemetry_cpp_FOUND)
24+ message ("Using external opentelemetry-cpp" )
25+ else ()
26+ include (cmake/opentelemetry-cpp.cmake)
27+ build_opentelemetry()
28+ set (OPENTELEMETRY_CPP_INCLUDE_DIRS "" )
29+ set (OPENTELEMETRY_CPP_LIBRARIES "opentelemetry::libopentelemetry" )
30+ message ("\n opentelemetry-cpp package was not found. Cloned from github" )
31+ endif ()
32+
2233find_package (nlohmann_json QUIET )
2334set (nlohmann_json_clone FALSE )
2435if (nlohmann_json_FOUND)
@@ -41,7 +52,8 @@ target_link_libraries(
4152 opentelemetry_exporter_fluentd_trace
4253 PUBLIC ${OPENTELEMETRY_CPP_LIBRARIES}
4354 INTERFACE nlohmann_json::nlohmann_json)
44- set_target_properties (opentelemetry_exporter_fluentd_trace PROPERTIES EXPORT_NAME trace)
55+ set_target_properties (opentelemetry_exporter_fluentd_trace
56+ PROPERTIES EXPORT_NAME trace)
4557
4658# create fluentd logs exporter
4759
@@ -53,14 +65,17 @@ target_link_libraries(
5365 opentelemetry_exporter_fluentd_logs
5466 PUBLIC ${OPENTELEMETRY_CPP_LIBRARIES}
5567 INTERFACE nlohmann_json::nlohmann_json)
56- set_target_properties (opentelemetry_exporter_fluentd_logs PROPERTIES EXPORT_NAME logs)
68+ set_target_properties (opentelemetry_exporter_fluentd_logs PROPERTIES EXPORT_NAME
69+ logs)
5770
5871if (nlohmann_json_clone)
59- add_dependencies (opentelemetry_exporter_fluentd_trace nlohmann_json::nlohmann_json)
60- add_dependencies (opentelemetry_exporter_fluentd_logs nlohmann_json::nlohmann_json)
72+ add_dependencies (opentelemetry_exporter_fluentd_trace
73+ nlohmann_json::nlohmann_json)
74+ add_dependencies (opentelemetry_exporter_fluentd_logs
75+ nlohmann_json::nlohmann_json)
6176 include_directories (${PROJECT_BINARY_DIR} /include )
6277endif ()
63-
78+
6479add_subdirectory (example)
6580
6681install (
@@ -124,8 +139,8 @@ if(BUILD_TESTING)
124139 opentelemetry_exporter_fluentd_logs)
125140
126141 if (nlohmann_json_clone)
127- add_dependencies (fluentd_recordable_logs_test nlohmann_json::nlohmann_json)
128- endif ()
142+ add_dependencies (fluentd_recordable_logs_test nlohmann_json::nlohmann_json)
143+ endif ()
129144
130145 gtest_add_tests(
131146 TARGET fluentd_recordable_logs_test
@@ -137,20 +152,21 @@ endif() # BUILD_TESTING
137152include (GNUInstallDirs)
138153include (CMakePackageConfigHelpers)
139154
140- set (OPENTELEMETRY_CPP_FLUENTD_VERSION, "0 .1.0 " )
155+ set (OPENTELEMETRY_CPP_FLUENTD_VERSION "1 .1.1 " )
141156set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR} " )
142157configure_package_config_file(
143- "${CMAKE_CURRENT_LIST_DIR} /cmake/opentelemetry-cpp-fluentd-config.cmake.in"
144- "${CMAKE_CURRENT_BINARY_DIR} /cmake/${PROJECT_NAME} /${PROJECT_NAME} -config.cmake"
145- INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME} "
146- #PATH_VARS OPENTELEMETRY_CPP_FLUENTD_VERSION PROJECT_NAME INCLUDE_INSTALL_DIR CMAKE_INSTALL_LIBDIR
147- PATH_VARS PROJECT_NAME INCLUDE_INSTALL_DIR CMAKE_INSTALL_LIBDIR
148- NO_CHECK_REQUIRED_COMPONENTS_MACRO)
158+ "${CMAKE_CURRENT_LIST_DIR} /cmake/opentelemetry-cpp-fluentd-config.cmake.in"
159+ "${CMAKE_CURRENT_BINARY_DIR} /cmake/${PROJECT_NAME} /${PROJECT_NAME} -config.cmake"
160+ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME} "
161+ # PATH_VARS OPENTELEMETRY_CPP_FLUENTD_VERSION PROJECT_NAME INCLUDE_INSTALL_DIR
162+ # CMAKE_INSTALL_LIBDIR
163+ PATH_VARS PROJECT_NAME INCLUDE_INSTALL_DIR CMAKE_INSTALL_LIBDIR
164+ NO_CHECK_REQUIRED_COMPONENTS_MACRO)
149165
150166# Write version file for find_packages(opentelemetry-cpp-fluentd CONFIG)
151167write_basic_package_version_file(
152168 "${CMAKE_CURRENT_BINARY_DIR} /cmake/${PROJECT_NAME} /${PROJECT_NAME} -config-version.cmake"
153- VERSION ${OPENTELEMETRY_VERSION }
169+ VERSION ${OPENTELEMETRY_CPP_FLUENTD_VERSION }
154170 COMPATIBILITY ExactVersion)
155171
156172install (
@@ -165,4 +181,3 @@ export(
165181 NAMESPACE "${PROJECT_NAME} ::"
166182 FILE "${CMAKE_CURRENT_BINARY_DIR} /cmake/${PROJECT_NAME} /${PROJECT_NAME} -target.cmake"
167183)
168-
0 commit comments