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@