CMakeLists.txt 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # Copyright The OpenTelemetry Authors
  2. # SPDX-License-Identifier: Apache-2.0
  3. if(WITH_OTLP_GRPC)
  4. # TRACE
  5. add_executable(example_otlp_grpc grpc_main.cc)
  6. target_link_libraries(example_otlp_grpc PRIVATE common_foo_library)
  7. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  8. target_compile_definitions(example_otlp_grpc
  9. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  10. target_link_libraries(example_otlp_grpc
  11. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  12. else()
  13. target_link_libraries(example_otlp_grpc
  14. PRIVATE opentelemetry-cpp::otlp_grpc_exporter)
  15. endif()
  16. # METRIC
  17. add_executable(example_otlp_grpc_metric grpc_metric_main.cc)
  18. target_link_libraries(example_otlp_grpc_metric
  19. PRIVATE common_metrics_foo_library)
  20. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  21. target_compile_definitions(example_otlp_grpc_metric
  22. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  23. target_link_libraries(example_otlp_grpc_metric
  24. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  25. else()
  26. target_link_libraries(example_otlp_grpc_metric
  27. PRIVATE opentelemetry-cpp::otlp_grpc_metrics_exporter)
  28. endif()
  29. # LOG
  30. add_executable(example_otlp_grpc_log grpc_log_main.cc)
  31. target_link_libraries(example_otlp_grpc_log PRIVATE common_logs_foo_library)
  32. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  33. target_compile_definitions(example_otlp_grpc_log
  34. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  35. target_link_libraries(example_otlp_grpc_log
  36. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  37. else()
  38. target_link_libraries(
  39. example_otlp_grpc_log
  40. PRIVATE opentelemetry-cpp::otlp_grpc_exporter
  41. opentelemetry-cpp::otlp_grpc_log_record_exporter)
  42. endif()
  43. endif()
  44. if(WITH_OTLP_HTTP)
  45. # TRACE
  46. add_executable(example_otlp_http http_main.cc)
  47. target_link_libraries(example_otlp_http PRIVATE common_foo_library)
  48. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  49. target_compile_definitions(example_otlp_http
  50. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  51. target_link_libraries(example_otlp_http
  52. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  53. else()
  54. target_link_libraries(example_otlp_http
  55. PRIVATE opentelemetry-cpp::otlp_http_exporter)
  56. endif()
  57. # METRIC
  58. add_executable(example_otlp_http_metric http_metric_main.cc)
  59. target_link_libraries(example_otlp_http_metric
  60. PRIVATE common_metrics_foo_library)
  61. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  62. target_compile_definitions(example_otlp_http_metric
  63. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  64. target_link_libraries(example_otlp_http_metric
  65. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  66. else()
  67. target_link_libraries(example_otlp_http_metric
  68. PRIVATE opentelemetry-cpp::otlp_http_metric_exporter)
  69. endif()
  70. # LOG
  71. add_executable(example_otlp_http_log http_log_main.cc)
  72. target_link_libraries(example_otlp_http_log PRIVATE common_logs_foo_library)
  73. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  74. target_compile_definitions(example_otlp_http_log
  75. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  76. target_link_libraries(example_otlp_http_log
  77. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  78. else()
  79. target_link_libraries(
  80. example_otlp_http_log
  81. PRIVATE opentelemetry-cpp::otlp_http_exporter
  82. opentelemetry-cpp::otlp_http_log_record_exporter)
  83. endif()
  84. # ALL, instrumented
  85. add_executable(example_otlp_instrumented_http http_instrumented_main.cc)
  86. # Note: common_logs_foo_library provide traces and logs
  87. target_link_libraries(
  88. example_otlp_instrumented_http PRIVATE common_metrics_foo_library
  89. common_logs_foo_library)
  90. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  91. target_compile_definitions(example_otlp_instrumented_http
  92. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  93. target_link_libraries(example_otlp_instrumented_http
  94. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  95. else()
  96. target_link_libraries(
  97. example_otlp_instrumented_http
  98. PRIVATE opentelemetry-cpp::otlp_http_exporter
  99. opentelemetry-cpp::otlp_http_metric_exporter
  100. opentelemetry-cpp::otlp_http_log_record_exporter)
  101. endif()
  102. endif()
  103. if(WITH_OTLP_FILE)
  104. # TRACE
  105. add_executable(example_otlp_file file_main.cc)
  106. target_link_libraries(example_otlp_file PRIVATE common_foo_library)
  107. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  108. target_compile_definitions(example_otlp_file
  109. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  110. target_link_libraries(example_otlp_file
  111. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  112. else()
  113. target_link_libraries(example_otlp_file
  114. PRIVATE opentelemetry-cpp::otlp_file_exporter)
  115. endif()
  116. # METRIC
  117. add_executable(example_otlp_file_metric file_metric_main.cc)
  118. target_link_libraries(example_otlp_file_metric
  119. PRIVATE common_metrics_foo_library)
  120. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  121. target_compile_definitions(example_otlp_file_metric
  122. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  123. target_link_libraries(example_otlp_file_metric
  124. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  125. else()
  126. target_link_libraries(example_otlp_file_metric
  127. PRIVATE opentelemetry-cpp::otlp_file_metric_exporter)
  128. endif()
  129. # LOG
  130. add_executable(example_otlp_file_log file_log_main.cc)
  131. target_link_libraries(example_otlp_file_log PRIVATE common_logs_foo_library)
  132. if(DEFINED OPENTELEMETRY_BUILD_DLL)
  133. target_compile_definitions(example_otlp_file_log
  134. PRIVATE OPENTELEMETRY_BUILD_IMPORT_DLL)
  135. target_link_libraries(example_otlp_file_log
  136. PRIVATE opentelemetry-cpp::opentelemetry_cpp)
  137. else()
  138. target_link_libraries(
  139. example_otlp_file_log
  140. PRIVATE opentelemetry-cpp::otlp_file_exporter
  141. opentelemetry-cpp::otlp_file_log_record_exporter)
  142. endif()
  143. endif()