1
- From fea2b8280b0889b5c03f628c498cae7125f2a64c Mon Sep 17 00:00:00 2001
1
+ From 3fe99f466679a9876cd264f7a07f1ca37fe6c15f Mon Sep 17 00:00:00 2001
2
2
From: Scott Ware <
[email protected] >
3
- Date: Tue, 7 Apr 2020 20:59:53 +0100
3
+ Date: Mon, 22 Apr 2024 09:33:47 +0100
4
4
Subject: [PATCH] Use pkg-config to find libs
5
5
6
- Signed-off-by: Scott Ware <
[email protected] >
7
-
8
- Add link options to cmake configs. Other package (such as
9
- azure-iot-sdk-c) link library of azure-c-shared-utility
10
- with these options to avoid the following error
11
- ...
12
- ld: iothub_client/libiothub_client.so.1.4.1: undefined reference to `ERR_load_BIO_strings'
13
- collect2: error: ld returned 1 exit status
14
- ...
15
-
16
- Upstream-Status: Inappropriate [oe specific]
6
+ Upstream-Status: Pending
17
7
18
- Signed-off-by: Hongxu Jia <hongxu.jia@windriver .com>
8
+ Signed-off-by: Scott Ware <scott.r.ware@intel .com>
19
9
---
20
- CMakeLists.txt | 31 ++++++++++-------------------
10
+ CMakeLists.txt | 30 ++++++++++-------------------
21
11
configs/azure_iot_build_rules.cmake | 5 +++++
22
- 2 files changed, 15 insertions(+), 21 deletions(-)
12
+ 2 files changed, 15 insertions(+), 20 deletions(-)
23
13
24
14
diff --git a/CMakeLists.txt b/CMakeLists.txt
25
- index e7078fee..c8c0f9d5 100644
15
+ index 00e79a95..eef28e29 100755
26
16
--- a/CMakeLists.txt
27
17
+++ b/CMakeLists.txt
28
- @@ -116,9 +116,13 @@ if(${use_openssl})
18
+ @@ -126,7 +126,11 @@ if(${use_openssl})
29
19
# If OpenSSL::SSL OR OpenSSL::Crypto are not set then you need to run
30
20
# the find package for openssl
31
21
if (NOT TARGET OpenSSL::SSL OR NOT TARGET OpenSSL::Crypto OR NOT ${OPENSSL_INCLUDE_DIR})
@@ -36,30 +26,35 @@ index e7078fee..c8c0f9d5 100644
36
26
+ pkg_check_modules(CRYPTO libcrypto)
37
27
+ endif()
38
28
endif()
29
+
30
+ # The block below enables the v1 back-compatibility layer in OpenSSL 3,
31
+ @@ -136,7 +140,7 @@ if(${use_openssl})
32
+ add_definitions(-DOPENSSL_API_COMPAT=0x10101000L)
33
+ endif()
34
+
39
35
- include_directories(${OPENSSL_INCLUDE_DIR})
40
36
+ include_directories(${OPENSSL_INCLUDE_DIR} ${CRYPTO_INCLUDE_DIR})
41
37
endif()
42
38
43
39
if(${use_applessl})
44
- @@ -511,26 +515 ,11 @@ if(${use_http})
40
+ @@ -543,25 +547 ,11 @@ if(${use_http})
45
41
set(aziotsharedutil_target_libs ${aziotsharedutil_target_libs} crypt32 winhttp)
46
42
else()
47
43
if (NOT use_builtin_httpapi)
48
- - if (CMAKE_CROSSCOMPILING)
49
- - # As mentioned at https://cmake.org/Wiki/CMake_Cross_Compiling the
50
- - # pkg-config tool can not be used by cmake while cross compiling.
51
- - message(STATUS "Cross compiling not using pkg-config")
52
- - else()
53
- - # try pkg-config first
54
- - find_package(PkgConfig)
55
- - if(PKG_CONFIG_FOUND)
56
- - pkg_check_modules(CURL libcurl)
57
- - endif()
58
- - endif()
59
44
-
60
- - # if that didn't work, try CMake find_package
61
- - if(NOT CURL_FOUND)
62
- - find_package(CURL)
45
+ - # try CMake find_package first
46
+ - find_package(CURL)
47
+ -
48
+ - # As mentioned at https://cmake.org/Wiki/CMake_Cross_Compiling the
49
+ - # pkg-config tool can not be used by cmake while cross compiling.
50
+ - if (NOT CMAKE_CROSSCOMPILING)
51
+ - # if find_package didn't work, try pkg-config
52
+ - if(NOT CURL_FOUND)
53
+ - find_package(PkgConfig)
54
+ - if(PKG_CONFIG_FOUND)
55
+ - pkg_check_modules(CURL libcurl)
56
+ - endif()
57
+ - endif()
63
58
+ find_package(PkgConfig)
64
59
+ if(PKG_CONFIG_FOUND)
65
60
+ pkg_check_modules(CURL libcurl)
@@ -71,7 +66,7 @@ index e7078fee..c8c0f9d5 100644
71
66
include_directories(${CURL_INCLUDE_DIRS})
72
67
set(aziotsharedutil_target_libs ${aziotsharedutil_target_libs} ${CURL_LIBRARIES})
73
68
endif(NOT use_builtin_httpapi)
74
- @@ -571 ,7 +560 ,7 @@ if(${use_bearssl})
69
+ @@ -602 ,7 +592 ,7 @@ if(${use_bearssl})
75
70
endif()
76
71
77
72
if(${use_openssl})
@@ -81,12 +76,12 @@ index e7078fee..c8c0f9d5 100644
81
76
set(aziotsharedutil_target_libs ${aziotsharedutil_target_libs} crypt32 ws2_32 secur32)
82
77
endif()
83
78
diff --git a/configs/azure_iot_build_rules.cmake b/configs/azure_iot_build_rules.cmake
84
- index be3e14fe..4f85a2b8 100644
79
+ index 655b7f01..747fd256 100644
85
80
--- a/configs/azure_iot_build_rules.cmake
86
81
+++ b/configs/azure_iot_build_rules.cmake
87
- @@ -76 ,6 +76 ,11 @@ elseif(UNIX) #LINUX OR APPLE
88
- if(NOT (IN_OPENWRT OR APPLE))
89
- set (CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L ${CMAKE_C_FLAGS}")
82
+ @@ -77 ,6 +77 ,11 @@ elseif(UNIX) #LINUX OR APPLE
83
+ # _XOPEN_SOURCE=500 is required for glibc to expose random and srandom.
84
+ set (CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500 ${CMAKE_C_FLAGS}")
90
85
endif()
91
86
+
92
87
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lssl -lcrypto")
@@ -96,6 +91,3 @@ index be3e14fe..4f85a2b8 100644
96
91
endif()
97
92
98
93
enable_testing()
99
- - -
100
- 2.27.0
101
-
0 commit comments