Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 1 | From 2cc41bee63223cb398ea932aad6ecc94ff5b61dd Mon Sep 17 00:00:00 2001 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 2 | From: Changqing Li <changqing.li@windriver.com> |
| 3 | Date: Tue, 24 Jul 2018 13:33:33 +0800 |
| 4 | Subject: [PATCH] cmake: Install libcares.pc |
| 5 | |
| 6 | Prepare and install libcares.pc file during cmake build, so libraries |
| 7 | using pkg-config to find libcares will not fail. |
| 8 | |
| 9 | Signed-off-by: Alexey Firago <alexey_firago@mentor.com> |
| 10 | |
| 11 | update to 1.14.0, fix patch warning |
| 12 | |
| 13 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 14 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 15 | --- |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 16 | CMakeLists.txt | 23 +++++++++++++++++------ |
| 17 | 1 file changed, 17 insertions(+), 6 deletions(-) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 18 | |
| 19 | diff --git a/CMakeLists.txt b/CMakeLists.txt |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 20 | index 08c0247..0020d6b 100644 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 21 | --- 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 Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 54 | @@ -551,6 +554,15 @@ ENDIF() |
| 55 | # Record toplevel CMakeLists.txt path |
| 56 | set(CARES_TOPLEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}") |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 57 | |
| 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 Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 70 | @@ -624,7 +636,6 @@ IF (CARES_INSTALL) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 71 | INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
| 72 | ENDIF () |
| 73 | |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 74 | - |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 75 | # 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") |