Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ if(WITH_OTLP_HTTP)
target_link_libraries(
opentelemetry_exporter_otlp_http_client
PUBLIC opentelemetry_sdk opentelemetry_ext
PRIVATE opentelemetry_proto opentelemetry_http_client_curl
nlohmann_json::nlohmann_json)
# Links flags of opentelemetry_http_client_curl should be public when
# building internal components
PRIVATE opentelemetry_proto
"$<BUILD_INTERFACE:opentelemetry_http_client_curl>"
nlohmann_json::nlohmann_json
"$<INSTALL_INTERFACE:opentelemetry_http_client_curl>")
if(TARGET absl::strings)
target_link_libraries(opentelemetry_exporter_otlp_http_client
PUBLIC absl::strings)
Expand Down
26 changes: 24 additions & 2 deletions ext/src/http/client/curl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,33 @@ set_target_properties(opentelemetry_http_client_curl
set_target_version(opentelemetry_http_client_curl)
target_link_libraries(opentelemetry_http_client_curl
PUBLIC opentelemetry_common)
if(TARGET CURL::libcurl)

unset(CURL_IMPORTED_TARGET_NAME)

foreach(FIND_CURL_IMPORTED_TARGET CURL::libcurl CURL::libcurl_shared
CURL::libcurl_static)
if(TARGET ${FIND_CURL_IMPORTED_TARGET})
set(CURL_IMPORTED_TARGET_NAME ${FIND_CURL_IMPORTED_TARGET})
break()
endif()
endforeach()

if(TARGET ${CURL_IMPORTED_TARGET_NAME})
target_link_libraries(
opentelemetry_http_client_curl
PUBLIC opentelemetry_ext
PRIVATE CURL::libcurl)
PRIVATE ${CURL_IMPORTED_TARGET_NAME})

# Some versions of libcurl do not export the link directories, which may cause
# link errors
project_build_tools_get_imported_location(CURL_LIB_FILE_PATH
${CURL_IMPORTED_TARGET_NAME})
get_filename_component(CURL_LIB_DIR_PATH "${CURL_LIB_FILE_PATH}" DIRECTORY)

if(CURL_LIB_DIR_PATH)
target_link_directories(opentelemetry_http_client_curl PUBLIC
"$<BUILD_INTERFACE:${CURL_LIB_DIR_PATH}>")
endif()
else()
target_include_directories(opentelemetry_http_client_curl
INTERFACE "${CURL_INCLUDE_DIRS}")
Expand Down
15 changes: 13 additions & 2 deletions ext/test/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@ if(WITH_HTTP_CLIENT_CURL)
target_link_libraries(${FILENAME} ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})

if(TARGET CURL::libcurl)
unset(CURL_IMPORTED_TARGET_NAME)

foreach(FIND_CURL_IMPORTED_TARGET CURL::libcurl CURL::libcurl_shared
CURL::libcurl_static)
if(TARGET ${FIND_CURL_IMPORTED_TARGET})
set(CURL_IMPORTED_TARGET_NAME ${FIND_CURL_IMPORTED_TARGET})
break()
endif()
endforeach()

if(TARGET ${CURL_IMPORTED_TARGET_NAME})
target_link_libraries(${FILENAME} opentelemetry_http_client_curl
opentelemetry_common CURL::libcurl)
opentelemetry_common ${CURL_IMPORTED_TARGET_NAME})
else()
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(${FILENAME} ${CURL_LIBRARIES}
opentelemetry_http_client_curl opentelemetry_common)
endif()

gtest_add_tests(
TARGET ${FILENAME}
TEST_PREFIX ext.http.curl.
Expand Down
Loading