File tree Expand file tree Collapse file tree 3 files changed +43
-6
lines changed Expand file tree Collapse file tree 3 files changed +43
-6
lines changed Original file line number Diff line number Diff line change @@ -119,8 +119,12 @@ if(WITH_OTLP_HTTP)
119
119
target_link_libraries (
120
120
opentelemetry_exporter_otlp_http_client
121
121
PUBLIC opentelemetry_sdk opentelemetry_ext
122
- PRIVATE opentelemetry_proto opentelemetry_http_client_curl
123
- nlohmann_json::nlohmann_json )
122
+ # Links flags of opentelemetry_http_client_curl should be public when
123
+ # building internal components
124
+ PRIVATE opentelemetry_proto
125
+ "$<BUILD_INTERFACE:opentelemetry_http_client_curl>"
126
+ nlohmann_json::nlohmann_json
127
+ "$<INSTALL_INTERFACE:opentelemetry_http_client_curl>" )
124
128
if (TARGET absl::strings )
125
129
target_link_libraries (opentelemetry_exporter_otlp_http_client
126
130
PUBLIC absl::strings )
Original file line number Diff line number Diff line change @@ -10,11 +10,33 @@ set_target_properties(opentelemetry_http_client_curl
10
10
set_target_version (opentelemetry_http_client_curl )
11
11
target_link_libraries (opentelemetry_http_client_curl
12
12
PUBLIC opentelemetry_common )
13
- if (TARGET CURL::libcurl )
13
+
14
+ unset (CURL_IMPORTED_TARGET_NAME )
15
+
16
+ foreach (FIND_CURL_IMPORTED_TARGET CURL::libcurl CURL::libcurl_shared
17
+ CURL::libcurl_static )
18
+ if (TARGET ${FIND_CURL_IMPORTED_TARGET} )
19
+ set (CURL_IMPORTED_TARGET_NAME ${FIND_CURL_IMPORTED_TARGET} )
20
+ break ()
21
+ endif ()
22
+ endforeach ()
23
+
24
+ if (TARGET ${CURL_IMPORTED_TARGET_NAME} )
14
25
target_link_libraries (
15
26
opentelemetry_http_client_curl
16
27
PUBLIC opentelemetry_ext
17
- PRIVATE CURL::libcurl )
28
+ PRIVATE ${CURL_IMPORTED_TARGET_NAME} )
29
+
30
+ # Some versions of libcurl do not export the link directories, which may cause
31
+ # link errors
32
+ project_build_tools_get_imported_location (CURL_LIB_FILE_PATH
33
+ ${CURL_IMPORTED_TARGET_NAME} )
34
+ get_filename_component (CURL_LIB_DIR_PATH "${CURL_LIB_FILE_PATH} " DIRECTORY )
35
+
36
+ if (CURL_LIB_DIR_PATH )
37
+ target_link_directories (opentelemetry_http_client_curl PUBLIC
38
+ "$<BUILD_INTERFACE:${CURL_LIB_DIR_PATH} >" )
39
+ endif ()
18
40
else ()
19
41
target_include_directories (opentelemetry_http_client_curl
20
42
INTERFACE "${CURL_INCLUDE_DIRS} " )
Original file line number Diff line number Diff line change @@ -8,14 +8,25 @@ if(WITH_HTTP_CLIENT_CURL)
8
8
target_link_libraries (${FILENAME} ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES}
9
9
${CMAKE_THREAD_LIBS_INIT} )
10
10
11
- if (TARGET CURL::libcurl )
11
+ unset (CURL_IMPORTED_TARGET_NAME )
12
+
13
+ foreach (FIND_CURL_IMPORTED_TARGET CURL::libcurl CURL::libcurl_shared
14
+ CURL::libcurl_static )
15
+ if (TARGET ${FIND_CURL_IMPORTED_TARGET} )
16
+ set (CURL_IMPORTED_TARGET_NAME ${FIND_CURL_IMPORTED_TARGET} )
17
+ break ()
18
+ endif ()
19
+ endforeach ()
20
+
21
+ if (TARGET ${CURL_IMPORTED_TARGET_NAME} )
12
22
target_link_libraries (${FILENAME} opentelemetry_http_client_curl
13
- opentelemetry_common CURL::libcurl )
23
+ opentelemetry_common ${CURL_IMPORTED_TARGET_NAME} )
14
24
else ()
15
25
include_directories (${CURL_INCLUDE_DIRS} )
16
26
target_link_libraries (${FILENAME} ${CURL_LIBRARIES}
17
27
opentelemetry_http_client_curl opentelemetry_common )
18
28
endif ()
29
+
19
30
gtest_add_tests (
20
31
TARGET ${FILENAME}
21
32
TEST_PREFIX ext.http.curl.
You can’t perform that action at this time.
0 commit comments