blob: c6f9c6de6189cd4485b9f723f0f5b21e33f6a8e9 [file] [log] [blame]
Andrew Geissler69721092021-07-23 12:57:00 -04001From 2cc41bee63223cb398ea932aad6ecc94ff5b61dd Mon Sep 17 00:00:00 2001
Andrew Geissler82c905d2020-04-13 13:39:40 -05002From: Changqing Li <changqing.li@windriver.com>
3Date: Tue, 24 Jul 2018 13:33:33 +0800
4Subject: [PATCH] cmake: Install libcares.pc
5
6Prepare and install libcares.pc file during cmake build, so libraries
7using pkg-config to find libcares will not fail.
8
9Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
10
11update to 1.14.0, fix patch warning
12
13Signed-off-by: Changqing Li <changqing.li@windriver.com>
Andrew Geissler69721092021-07-23 12:57:00 -040014
Andrew Geissler82c905d2020-04-13 13:39:40 -050015---
Andrew Geissler69721092021-07-23 12:57:00 -040016 CMakeLists.txt | 23 +++++++++++++++++------
17 1 file changed, 17 insertions(+), 6 deletions(-)
Andrew Geissler82c905d2020-04-13 13:39:40 -050018
19diff --git a/CMakeLists.txt b/CMakeLists.txt
Andrew Geissler69721092021-07-23 12:57:00 -040020index 08c0247..0020d6b 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050021--- a/CMakeLists.txt
22+++ b/CMakeLists.txt
23@@ -214,22 +214,25 @@ ADD_DEFINITIONS(${SYSFLAGS})
24
25
26 # Tell C-Ares about libraries to depend on
27+# Also pass these libraries to pkg-config file
28+SET(CARES_PRIVATE_LIBS_LIST)
29 IF (HAVE_LIBRESOLV)
30- LIST (APPEND CARES_DEPENDENT_LIBS resolv)
31+ LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lresolv")
32 ENDIF ()
33 IF (HAVE_LIBNSL)
34- LIST (APPEND CARES_DEPENDENT_LIBS nsl)
35+ LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lnsl")
36 ENDIF ()
37 IF (HAVE_LIBSOCKET)
38- LIST (APPEND CARES_DEPENDENT_LIBS socket)
39+ LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lsocket")
40 ENDIF ()
41 IF (HAVE_LIBRT)
42- LIST (APPEND CARES_DEPENDENT_LIBS rt)
43+ LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lrt")
44 ENDIF ()
45 IF (WIN32)
46- LIST (APPEND CARES_DEPENDENT_LIBS ws2_32 Advapi32)
47+ LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lws2_32")
48 ENDIF ()
49
50+string (REPLACE ";" " " CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS_LIST}")
51
52 # When checking for symbols, we need to make sure we set the proper
53 # headers, libraries, and definitions for the detection to work properly
Andrew Geissler69721092021-07-23 12:57:00 -040054@@ -551,6 +554,15 @@ ENDIF()
55 # Record toplevel CMakeLists.txt path
56 set(CARES_TOPLEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
Andrew Geissler82c905d2020-04-13 13:39:40 -050057
58+# Pass required CFLAGS to pkg-config in case of static library
59+IF (CARES_STATIC)
60+ SET (CPPFLAG_CARES_STATICLIB "-DCARES_STATICLIB")
61+ENDIF()
62+
63+# Write ares_config.h configuration file. This is used only for the build.
64+CONFIGURE_FILE (libcares.pc.cmakein ${PROJECT_BINARY_DIR}/libcares.pc @ONLY)
65+
66+
67
68 # TRANSFORM_MAKEFILE_INC
69 #
Andrew Geissler69721092021-07-23 12:57:00 -040070@@ -624,7 +636,6 @@ IF (CARES_INSTALL)
Andrew Geissler82c905d2020-04-13 13:39:40 -050071 INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
72 ENDIF ()
73
Andrew Geissler69721092021-07-23 12:57:00 -040074-
Andrew Geissler82c905d2020-04-13 13:39:40 -050075 # Legacy chain-building variables (provided for compatibility with old code).
76 # Don't use these, external code should be updated to refer to the aliases directly (e.g., Cares::cares).
77 SET (CARES_FOUND 1 CACHE INTERNAL "CARES LIBRARY FOUND")