Skip to content

Commit

Permalink
Update CMakeFile build and install
Browse files Browse the repository at this point in the history
  • Loading branch information
chusitoo committed Jan 7, 2023
1 parent 8f10779 commit 697c402
Show file tree
Hide file tree
Showing 20 changed files with 117 additions and 108 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,25 @@ include_directories(api/include)
add_subdirectory(api)

if(WITH_OPENTRACING)
find_package(OpenTracing CONFIG QUIET)
if(NOT OpenTracing_FOUND)
set(OPENTRACING_DIR "third_party/opentracing-cpp")
message("Trying to use local ${OPENTRACING_DIR} from submodule")
if(EXISTS "${PROJECT_SOURCE_DIR}/${OPENTRACING_DIR}/.git")
set(SAVED_BUILD_TESTING ${BUILD_TESTING})
set(BUILD_TESTING OFF)
add_subdirectory(${OPENTRACING_DIR})
set(BUILD_TESTING ${SAVED_BUILD_TESTING})
else()
message(
FATAL_ERROR
"\nopentracing-cpp package was not found. Please either provide it manually or clone with submodules. "
"To initialize, fetch and checkout any nested submodules, you can use the following command:\n"
"git submodule update --init --recursive")
endif()
else()
message("Using external opentracing-cpp")
endif()
add_subdirectory(opentracing-shim)
endif()

Expand Down
4 changes: 3 additions & 1 deletion cmake/opentelemetry-cpp-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# opentelemetry-cpp::jaeger_trace_exporter - Imported target of opentelemetry-cpp::jaeger_trace_exporter
# opentelemetry-cpp::zpages - Imported target of opentelemetry-cpp::zpages
# opentelemetry-cpp::http_client_curl - Imported target of opentelemetry-cpp::http_client_curl
# opentelemetry-cpp::opentracing_shim - Imported target of opentelemetry-cpp::opentracing_shim
#

# =============================================================================
Expand Down Expand Up @@ -101,7 +102,8 @@ set(_OPENTELEMETRY_CPP_LIBRARIES_TEST_TARGETS
etw_exporter
jaeger_trace_exporter
zpages
http_client_curl)
http_client_curl
opentracing_shim)
foreach(_TEST_TARGET IN LISTS _OPENTELEMETRY_CPP_LIBRARIES_TEST_TARGETS)
if(TARGET opentelemetry-cpp::${_TEST_TARGET})
list(APPEND OPENTELEMETRY_CPP_LIBRARIES opentelemetry-cpp::${_TEST_TARGET})
Expand Down
109 changes: 68 additions & 41 deletions opentracing-shim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,73 @@
set(this_target opentelemetry_opentracing_shim)

#message("CMAKE_CURRENT_LIST_DIR " ${CMAKE_CURRENT_LIST_DIR})
#message("CMAKE_CURRENT_SOURCE_DIR " ${CMAKE_CURRENT_SOURCE_DIR})
#message("CMAKE_SOURCE_DIR " ${CMAKE_SOURCE_DIR})
#message("PROJECT_SOURCE_DIR " ${PROJECT_SOURCE_DIR})

#add_library(${this_target} INTERFACE)
#target_include_directories(
# ${this_target}
# PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
# "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/third_party/opentracing-cpp/include>"
# "$<INSTALL_INTERFACE:include>")
#
#set_target_properties(${this_target} PROPERTIES EXPORT_NAME "opentracing-shim")
#target_link_libraries(${this_target} INTERFACE ${this_target} opentracing-cpp)
#
#get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
#foreach(dir ${dirs})
# message(STATUS "dir='${dir}'")
#endforeach()
#
#install(
# TARGETS ${this_target}
# EXPORT "${PROJECT_NAME}-target"
# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
#
#install(
# DIRECTORY include/opentelemetry/opentracing-shim
# DESTINATION include/opentelemetry/
# FILES_MATCHING
# PATTERN "*.h")

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/third_party/opentracing-cpp/include
${CMAKE_SOURCE_DIR}/third_party/opentracing-cpp/build/include
${CMAKE_SOURCE_DIR}/third_party/opentracing-cpp/3rd_party/include)

add_subdirectory(src)
add_library(${this_target}
src/span_shim.cc
src/span_context_shim.cc
src/tracer_shim.cc)

set_target_properties(${this_target} PROPERTIES EXPORT_NAME opentracing_shim)

if(OPENTRACING_DIR)
include_directories(
"${CMAKE_BINARY_DIR}/${OPENTRACING_DIR}/include"
"${CMAKE_SOURCE_DIR}/${OPENTRACING_DIR}/include"
"${CMAKE_SOURCE_DIR}/${OPENTRACING_DIR}/3rd_party/include")
endif()

target_include_directories(
${this_target}
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

target_link_libraries(
${this_target}
PUBLIC opentelemetry_api)

install(
TARGETS ${this_target}
EXPORT "${PROJECT_NAME}-target"
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(
DIRECTORY include/opentelemetry/opentracingshim
DESTINATION include/opentelemetry
FILES_MATCHING
PATTERN "*.h")

if(BUILD_TESTING)
add_subdirectory(test)
foreach(
testname
propagation_test
shim_utils_test
span_shim_test
span_context_shim_test
tracer_shim_test)

add_executable(${testname} "test/${testname}.cc")

if(OPENTRACING_DIR)
target_link_libraries(
${testname}
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
opentelemetry_api
opentelemetry_opentracing_shim
opentracing)
else()
target_link_libraries(
${testname}
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
opentelemetry_api
opentelemetry_opentracing_shim
OpenTracing::opentracing)
endif()

gtest_add_tests(
TARGET ${testname}
TEST_PREFIX opentracing_shim.
TEST_LIST ${testname})
endforeach()
endif() # BUILD_TESTING
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma once

#include "span_context_shim.h"
#include "opentelemetry/opentracingshim/span_context_shim.h"

#include "opentelemetry/baggage/baggage.h"
#include "opentelemetry/baggage/baggage_context.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#pragma once

#include "tracer_shim.h"
#include "span_context_shim.h"
#include "opentelemetry/opentracingshim/tracer_shim.h"
#include "opentelemetry/opentracingshim/span_context_shim.h"

#include "opentelemetry/baggage/baggage.h"
#include "opentelemetry/common/attribute_value.h"
Expand Down
File renamed without changes.
28 changes: 0 additions & 28 deletions opentracing-shim/src/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion opentracing-shim/src/span_context_shim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "span_context_shim.h"
#include "opentelemetry/opentracingshim/span_context_shim.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace opentracingshim
Expand Down
8 changes: 4 additions & 4 deletions opentracing-shim/src/span_shim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "span_shim.h"
#include "span_context_shim.h"
#include "tracer_shim.h"
#include "shim_utils.h"
#include "opentelemetry/opentracingshim/span_shim.h"
#include "opentelemetry/opentracingshim/span_context_shim.h"
#include "opentelemetry/opentracingshim/tracer_shim.h"
#include "opentelemetry/opentracingshim/shim_utils.h"

#include "opentelemetry/trace/semantic_conventions.h"
#include "opentelemetry/trace/span_metadata.h"
Expand Down
8 changes: 4 additions & 4 deletions opentracing-shim/src/tracer_shim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "tracer_shim.h"
#include "span_shim.h"
#include "shim_utils.h"
#include "propagation.h"
#include "opentelemetry/opentracingshim/tracer_shim.h"
#include "opentelemetry/opentracingshim/span_shim.h"
#include "opentelemetry/opentracingshim/shim_utils.h"
#include "opentelemetry/opentracingshim/propagation.h"

#include "opentelemetry/context/propagation/global_propagator.h"
#include "opentelemetry/trace/context.h"
Expand Down
17 changes: 0 additions & 17 deletions opentracing-shim/test/CMakeLists.txt

This file was deleted.

3 changes: 2 additions & 1 deletion opentracing-shim/test/propagation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "propagation.h"
#include "shim_mocks.h"

#include "opentelemetry/opentracingshim/propagation.h"

#include <gtest/gtest.h>

namespace baggage = opentelemetry::baggage;
Expand Down
1 change: 1 addition & 0 deletions opentracing-shim/test/shim_mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include "opentelemetry/baggage/baggage_context.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/trace/span_metadata.h"
Expand Down
3 changes: 2 additions & 1 deletion opentracing-shim/test/shim_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "shim_utils.h"
#include "shim_mocks.h"

#include "opentelemetry/opentracingshim/shim_utils.h"

#include "opentracing/tracer.h"

#include <gtest/gtest.h>
Expand Down
2 changes: 1 addition & 1 deletion opentracing-shim/test/span_context_shim_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "span_context_shim.h"
#include "opentelemetry/opentracingshim/span_context_shim.h"

#include "opentelemetry/baggage/baggage.h"
#include "opentelemetry/trace/span_context.h"
Expand Down
5 changes: 3 additions & 2 deletions opentracing-shim/test/span_shim_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "span_shim.h"
#include "tracer_shim.h"
#include "shim_mocks.h"

#include "opentelemetry/opentracingshim/span_shim.h"
#include "opentelemetry/opentracingshim/tracer_shim.h"

#include <gtest/gtest.h>

namespace trace_api = opentelemetry::trace;
Expand Down
9 changes: 5 additions & 4 deletions opentracing-shim/test/tracer_shim_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "tracer_shim.h"
#include "span_shim.h"
#include "span_context_shim.h"
#include "shim_utils.h"
#include "shim_mocks.h"

#include "opentelemetry/opentracingshim/tracer_shim.h"
#include "opentelemetry/opentracingshim/span_shim.h"
#include "opentelemetry/opentracingshim/span_context_shim.h"
#include "opentelemetry/opentracingshim/shim_utils.h"

#include "opentracing/noop.h"

#include <gtest/gtest.h>
Expand Down
1 change: 1 addition & 0 deletions third_party/opentracing-cpp
Submodule opentracing-cpp added at 06b57f

0 comments on commit 697c402

Please sign in to comment.