From 407f2fdd5ec6f79287919486aa5869b346093906 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 31 Jul 2023 12:46:32 -0700 Subject: PR #1498: Fix order of link options in pkg-config files Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1498 In Windows, a few libraries (`dbghelp`, `advapi32`, and `bcrypt`) are added via link options. However, the .pc files produced for pkg-config erroneously include them before the abseil libraries. This can cause undefined references when trying to build against abseil. This commit swaps the order and adds the custom link options after the abseil dependencies. The following is a list of `.pc` files affected by this and the additional link options used: * all: `-L${libdir}` * `absl_base.pc`: `-ladvapi32` * `absl_random_internal_seed_material.pc`: `-lbcrypt` * `absl_symbolize.pc`: `-ldbghelp` Closes https://github.com/abseil/abseil-cpp/issues/1497 Merge af61f6d5d5fa7b390fc2e009652cd6da68b0fd38 into c9c0fd5185067208e1cc4227d16122571762af39 Merging this change closes #1498 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1498 from stanhu:sh-fix-pc-link-order af61f6d5d5fa7b390fc2e009652cd6da68b0fd38 PiperOrigin-RevId: 552564626 Change-Id: I9d2a6ab99993bb4315dc94eade2cd419f1109c13 --- CMake/AbseilDll.cmake | 2 +- CMake/AbseilHelpers.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'CMake') diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake index f8dea458..f0d984ae 100644 --- a/CMake/AbseilDll.cmake +++ b/CMake/AbseilDll.cmake @@ -788,7 +788,7 @@ Name: ${_dll}\n\ Description: Abseil DLL library\n\ URL: https://abseil.io/\n\ Version: ${absl_VERSION}\n\ -Libs: -L\${libdir} ${PC_LINKOPTS} $<$>:-l${_dll}>\n\ +Libs: -L\${libdir} $<$>:-l${_dll}> ${PC_LINKOPTS}\n\ Cflags: -I\${includedir}${PC_CFLAGS}\n") INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/pkgconfig/${_dll}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake index de63531b..5a6c57fd 100644 --- a/CMake/AbseilHelpers.cmake +++ b/CMake/AbseilHelpers.cmake @@ -211,7 +211,7 @@ Description: Abseil ${_NAME} library\n\ URL: https://abseil.io/\n\ Version: ${PC_VERSION}\n\ Requires:${PC_DEPS}\n\ -Libs: -L\${libdir} ${PC_LINKOPTS} $<$>:${LNK_LIB}>\n\ +Libs: -L\${libdir} $<$>:${LNK_LIB}> ${PC_LINKOPTS}\n\ Cflags: -I\${includedir}${PC_CFLAGS}\n") INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") -- cgit v1.2.3