Skip to content

Commit

Permalink
[Geneva, User Events] Update CMakeLists.txt (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pravila00 authored Apr 3, 2024
1 parent 897c9ef commit 4f30593
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/geneva_metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ jobs:
mkdir -p "$GITHUB_WORKSPACE/otel_cpp_contrib/exporters/geneva/build"
cd "$GITHUB_WORKSPACE/otel_cpp_contrib/exporters/geneva/build"
cmake .. "-DCMAKE_PREFIX_PATH=$HOME/prebuilt-otel" \
-DBUILD_TESTING=ON -DBUILD_EXAMPLE=ON
-DBUILD_TESTING=ON -DWITH_EXAMPLES=ON
cmake --build . -j$(nproc)
ctest
2 changes: 1 addition & 1 deletion exporters/geneva/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if(OPENTELEMETRY_INSTALL)
PATTERN "*.h")
endif()

if(BUILD_EXAMPLE)
if(WITH_EXAMPLES)
add_executable(example_metrics example/example_metrics.cc
example/foo_library.cc)
target_link_libraries(example_metrics opentelemetry_exporter_geneva_metrics)
Expand Down
2 changes: 1 addition & 1 deletion exporters/geneva/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ for instructions.
inclusion in shared libraries, this variable is used.
- `-DBUILD_SHARED_LIBS=ON` : To build shared libraries for the targets.
- `-DBUILD_TESTING=ON` : Build the unit-tests
- `-DBUILD_EXAMPLE=ON`: Build the example code which generates measurements and collects/exports metrics periodically
- `-DWITH_EXAMPLES=ON`: Build the example code which generates measurements and collects/exports metrics periodically

4. Once build configuration is created, build the exporter:

Expand Down
33 changes: 22 additions & 11 deletions exporters/user_events/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
cmake_minimum_required(VERSION 3.12)

if (MAIN_PROJECT)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(WIN32)
message(FATAL_ERROR "user_events exporter is Linux only for now")
endif()

option(BUILD_EXAMPLE "Build example" ON)
option(WITH_EXAMPLES "Build example" ON)
option(BUILD_TESTING "Build tests" ON)
option(BUILD_TRACEPOINTS "Build tracepoints library" ON)

project(opentelemetry-user_events-exporter)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
Expand All @@ -28,16 +24,28 @@ if(MAIN_PROJECT)
find_package(opentelemetry-cpp REQUIRED)
endif()

# don't build samples and tools from LinuxTracepoints.
set(BUILD_SAMPLES OFF)
set(BUILD_TOOLS OFF)
add_subdirectory(third_party/LinuxTracepoints)
if(BUILD_TRACEPOINTS)
set(ORIGINAL_BUILD_SAMPLES ${BUILD_SAMPLES})
set(ORIGINAL_BUILD_TOOLS ${BUILD_TOOLS})

# don't build samples and tools from LinuxTracepoints.
set(BUILD_SAMPLES OFF)
set(BUILD_TOOLS OFF)
add_subdirectory(third_party/LinuxTracepoints)

# Restore original values
set(BUILD_SAMPLES ${ORIGINAL_BUILD_SAMPLES})
set(BUILD_TOOLS ${ORIGINAL_BUILD_TOOLS})
endif()

include_directories(include)

add_library(opentelemetry_exporter_user_events_logs
src/logs_exporter.cc src/recordable.cc src/utils.cc)

target_compile_features(opentelemetry_exporter_user_events_logs
PRIVATE cxx_std_17)

target_compile_definitions(opentelemetry_exporter_user_events_logs
PUBLIC HAVE_CONSOLE_LOG HAVE_LOGS_PREVIEW)

Expand All @@ -60,6 +68,9 @@ set_target_properties(opentelemetry_exporter_user_events_logs

add_library(opentelemetry_exporter_user_events_metrics src/metrics_exporter.cc)

target_compile_features(opentelemetry_exporter_user_events_metrics
PRIVATE cxx_std_17)

if(MAIN_PROJECT)
target_include_directories(opentelemetry_exporter_user_events_metrics
PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
Expand All @@ -74,7 +85,7 @@ else()
opentelemetry_otlp_recordable tracepoint)
endif()

if(BUILD_EXAMPLE)
if(WITH_EXAMPLES)
add_executable(user_events_logs example/logs/main.cc
example/logs/foo_library.cc)
target_link_libraries(user_events_logs ${CMAKE_THREAD_LIBS_INIT}
Expand Down

0 comments on commit 4f30593

Please sign in to comment.