From 1b5473fbb94b8f632c638b8c13f33794cc00f17c Mon Sep 17 00:00:00 2001 From: Brad House Date: Wed, 7 Aug 2024 09:43:39 -0400 Subject: [PATCH] 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) --- CMakeLists.txt | 11 +++++------ libcares.pc.cmake | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3f69075..948e7edb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -772,12 +772,11 @@ IF (CARES_INSTALL) 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}) - # pkgconfig support - IF (NOT CARES_SHARED) - FOREACH (LIB ${CARES_DEPENDENT_LIBS}) - SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}") - ENDFOREACH () - ENDIF () + # pkgconfig support for static builds + FOREACH (LIB ${CARES_DEPENDENT_LIBS}) + SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}") + ENDFOREACH () + CONFIGURE_FILE("libcares.pc.cmake" "libcares.pc" @ONLY) INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") ENDIF () diff --git a/libcares.pc.cmake b/libcares.pc.cmake index 74e4d0cf..257255d8 100644 --- a/libcares.pc.cmake +++ b/libcares.pc.cmake @@ -7,9 +7,9 @@ # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_FULL_BINDIR@ -libdir=@CMAKE_INSTALL_FULL_LIBDIR@ -includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: c-ares URL: https://c-ares.org/ @@ -18,5 +18,6 @@ Version: @CARES_VERSION@ Requires: Requires.private: Cflags: -I${includedir} +Cflags.private: -DCARES_STATICLIB Libs: -L${libdir} -lcares Libs.private: @CARES_PRIVATE_LIBS@