CMake pkg-config windows: fix static library options

pkg-config uses the .private suffix for static linking to c-ares,
set the libraries and cflags necessary for this.

Authored-By: Christoph Reiter (@lazka)
Approved-By: Brad House (@bradh352)
pull/857/head
Brad House 4 months ago
parent 8f4328073c
commit 1b5473fbb9
  1. 11
      CMakeLists.txt
  2. 7
      libcares.pc.cmake

@ -772,12 +772,11 @@ IF (CARES_INSTALL)
INSTALL (EXPORT ${PROJECT_NAME}-targets COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR} NAMESPACE ${PROJECT_NAME}::) INSTALL (EXPORT ${PROJECT_NAME}-targets COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR} NAMESPACE ${PROJECT_NAME}::)
INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR}) INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR})
# pkgconfig support # pkgconfig support for static builds
IF (NOT CARES_SHARED) FOREACH (LIB ${CARES_DEPENDENT_LIBS})
FOREACH (LIB ${CARES_DEPENDENT_LIBS}) SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}")
SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}") ENDFOREACH ()
ENDFOREACH ()
ENDIF ()
CONFIGURE_FILE("libcares.pc.cmake" "libcares.pc" @ONLY) CONFIGURE_FILE("libcares.pc.cmake" "libcares.pc" @ONLY)
INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
ENDIF () ENDIF ()

@ -7,9 +7,9 @@
# Copyright (C) The c-ares project and its contributors # Copyright (C) The c-ares project and its contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_FULL_BINDIR@ exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@ libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: c-ares Name: c-ares
URL: https://c-ares.org/ URL: https://c-ares.org/
@ -18,5 +18,6 @@ Version: @CARES_VERSION@
Requires: Requires:
Requires.private: Requires.private:
Cflags: -I${includedir} Cflags: -I${includedir}
Cflags.private: -DCARES_STATICLIB
Libs: -L${libdir} -lcares Libs: -L${libdir} -lcares
Libs.private: @CARES_PRIVATE_LIBS@ Libs.private: @CARES_PRIVATE_LIBS@

Loading…
Cancel
Save