aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/c-ares/c-ares/cmake-install-libcares.pc.patch
blob: c6f9c6de6189cd4485b9f723f0f5b21e33f6a8e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From 2cc41bee63223cb398ea932aad6ecc94ff5b61dd Mon Sep 17 00:00:00 2001
From: Changqing Li <changqing.li@windriver.com>
Date: Tue, 24 Jul 2018 13:33:33 +0800
Subject: [PATCH] cmake: Install libcares.pc

Prepare and install libcares.pc file during cmake build, so libraries
using pkg-config to find libcares will not fail.

Signed-off-by: Alexey Firago <alexey_firago@mentor.com>

update to 1.14.0, fix patch warning

Signed-off-by: Changqing Li <changqing.li@windriver.com>

---
 CMakeLists.txt | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 08c0247..0020d6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -214,22 +214,25 @@ ADD_DEFINITIONS(${SYSFLAGS})
 
 
 # Tell C-Ares about libraries to depend on
+# Also pass these libraries to pkg-config file
+SET(CARES_PRIVATE_LIBS_LIST)
 IF (HAVE_LIBRESOLV)
-	LIST (APPEND CARES_DEPENDENT_LIBS resolv)
+	LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lresolv")
 ENDIF ()
 IF (HAVE_LIBNSL)
-	LIST (APPEND CARES_DEPENDENT_LIBS nsl)
+	LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lnsl")
 ENDIF ()
 IF (HAVE_LIBSOCKET)
-	LIST (APPEND CARES_DEPENDENT_LIBS socket)
+	LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lsocket")
 ENDIF ()
 IF (HAVE_LIBRT)
-	LIST (APPEND CARES_DEPENDENT_LIBS rt)
+	LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lrt")
 ENDIF ()
 IF (WIN32)
-	LIST (APPEND CARES_DEPENDENT_LIBS ws2_32 Advapi32)
+	LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lws2_32")
 ENDIF ()
 
+string (REPLACE ";" " " CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS_LIST}")
 
 # When checking for symbols, we need to make sure we set the proper
 # headers, libraries, and definitions for the detection to work properly
@@ -551,6 +554,15 @@ ENDIF()
 # Record toplevel CMakeLists.txt path
 set(CARES_TOPLEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
 
+# Pass required CFLAGS to pkg-config in case of static library
+IF (CARES_STATIC)
+       SET (CPPFLAG_CARES_STATICLIB "-DCARES_STATICLIB")
+ENDIF()
+
+# Write ares_config.h configuration file.  This is used only for the build.
+CONFIGURE_FILE (libcares.pc.cmakein ${PROJECT_BINARY_DIR}/libcares.pc @ONLY)
+
+
 
 # TRANSFORM_MAKEFILE_INC
 #
@@ -624,7 +636,6 @@ IF (CARES_INSTALL)
 	INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 ENDIF ()
 
-
 # Legacy chain-building variables (provided for compatibility with old code).
 # Don't use these, external code should be updated to refer to the aliases directly (e.g., Cares::cares).
 SET (CARES_FOUND 1 CACHE INTERNAL "CARES LIBRARY FOUND")