Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 12414304245cce6ef0e8b9547949be5109845353 Mon Sep 17 00:00:00 2001 |
| 2 | From: Changqing Li <changqing.li@windriver.com> |
| 3 | Date: Tue, 24 Jul 2018 13:33:33 +0800 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 10 | |
| 11 | update to 1.14.0, fix patch warning |
| 12 | |
| 13 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 14 | --- |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 15 | CMakeLists.txt | 23 +++++++++++++++++++++++ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | libcares.pc.cmakein | 20 ++++++++++++++++++++ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 17 | 2 files changed, 43 insertions(+) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 18 | create mode 100644 libcares.pc.cmakein |
| 19 | |
| 20 | diff --git a/CMakeLists.txt b/CMakeLists.txt |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 21 | index 60a880c..71eaa53 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 22 | --- a/CMakeLists.txt |
| 23 | +++ b/CMakeLists.txt |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 24 | @@ -193,22 +193,30 @@ ADD_DEFINITIONS(${SYSFLAGS}) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 25 | |
| 26 | |
| 27 | # Tell C-Ares about libraries to depend on |
| 28 | +# Also pass these libraries to pkg-config file |
| 29 | +SET(CARES_PRIVATE_LIBS_LIST) |
| 30 | IF (HAVE_LIBRESOLV) |
| 31 | LIST (APPEND CARES_DEPENDENT_LIBS resolv) |
| 32 | + LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lresolv") |
| 33 | ENDIF () |
| 34 | IF (HAVE_LIBNSL) |
| 35 | LIST (APPEND CARES_DEPENDENT_LIBS nsl) |
| 36 | + LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lnsl") |
| 37 | ENDIF () |
| 38 | IF (HAVE_LIBSOCKET) |
| 39 | LIST (APPEND CARES_DEPENDENT_LIBS socket) |
| 40 | + LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lsocket") |
| 41 | ENDIF () |
| 42 | IF (HAVE_LIBRT) |
| 43 | LIST (APPEND CARES_DEPENDENT_LIBS rt) |
| 44 | + LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lrt") |
| 45 | ENDIF () |
| 46 | IF (WIN32) |
| 47 | LIST (APPEND CARES_DEPENDENT_LIBS ws2_32) |
| 48 | + LIST (APPEND CARES_PRIVATE_LIBS_LIST "-lws2_32") |
| 49 | ENDIF () |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 50 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 51 | +string (REPLACE ";" " " CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS_LIST}") |
| 52 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 53 | # When checking for symbols, we need to make sure we set the proper |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 54 | # headers, libraries, and definitions for the detection to work properly |
| 55 | @@ -514,6 +522,15 @@ CONFIGURE_FILE (ares_build.h.cmake ${PROJECT_BINARY_DIR}/ares_build.h) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 56 | # Write ares_config.h configuration file. This is used only for the build. |
| 57 | CONFIGURE_FILE (ares_config.h.cmake ${PROJECT_BINARY_DIR}/ares_config.h) |
| 58 | |
| 59 | +# Pass required CFLAGS to pkg-config in case of static library |
| 60 | +IF (CARES_STATIC) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 61 | + SET (CPPFLAG_CARES_STATICLIB "-DCARES_STATICLIB") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 62 | +ENDIF() |
| 63 | + |
| 64 | +# Write ares_config.h configuration file. This is used only for the build. |
| 65 | +CONFIGURE_FILE (libcares.pc.cmakein ${PROJECT_BINARY_DIR}/libcares.pc @ONLY) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 66 | + |
| 67 | + |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 68 | |
| 69 | # TRANSFORM_MAKEFILE_INC |
| 70 | # |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 71 | @@ -664,6 +681,12 @@ IF (CARES_INSTALL) |
| 72 | INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 73 | ENDIF () |
| 74 | |
| 75 | +# pkg-config file |
| 76 | +IF (CARES_INSTALL) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 77 | + SET (PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
| 78 | + INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" DESTINATION ${PKGCONFIG_INSTALL_DIR}) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 79 | +ENDIF () |
| 80 | + |
| 81 | # Legacy chain-building variables (provided for compatibility with old code). |
| 82 | # Don't use these, external code should be updated to refer to the aliases directly (e.g., Cares::cares). |
| 83 | SET (CARES_FOUND 1 CACHE INTERNAL "CARES LIBRARY FOUND") |
| 84 | diff --git a/libcares.pc.cmakein b/libcares.pc.cmakein |
| 85 | new file mode 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 86 | index 0000000..3579256 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 87 | --- /dev/null |
| 88 | +++ b/libcares.pc.cmakein |
| 89 | @@ -0,0 +1,20 @@ |
| 90 | +#*************************************************************************** |
| 91 | +# Project ___ __ _ _ __ ___ ___ |
| 92 | +# / __|____ / _` | '__/ _ \/ __| |
| 93 | +# | (_|_____| (_| | | | __/\__ \ |
| 94 | +# \___| \__,_|_| \___||___/ |
| 95 | +# |
| 96 | +prefix=@CMAKE_INSTALL_PREFIX@ |
| 97 | +exec_prefix=@CMAKE_INSTALL_PREFIX@ |
| 98 | +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ |
| 99 | +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ |
| 100 | + |
| 101 | +Name: c-ares |
| 102 | +URL: http://daniel.haxx.se/projects/c-ares/ |
| 103 | +Description: asynchronous DNS lookup library |
| 104 | +Version: @VERSION@ |
| 105 | +Requires: |
| 106 | +Requires.private: |
| 107 | +Cflags: -I${includedir} @CPPFLAG_CARES_STATICLIB@ |
| 108 | +Libs: -L${libdir} -lcares |
| 109 | +Libs.private: @CARES_PRIVATE_LIBS@ |
| 110 | -- |
| 111 | 2.7.4 |
| 112 | |