|
| 1 | +Replace LINK_FLAG target property set from <prefix>_LDFLAGS by a proper |
| 2 | +target_link_libraries() using <prefix>_LINK_LIBRARIES for pkg-config |
| 3 | +dependencies. Otherwise, the full path of the linked library may not be |
| 4 | +preserved (-L linker flag in INTERFACE_LINK_LIBRARIES mysteriously disappear when |
| 5 | +using imported targets). Using LDFLAGS is also depend on the linker path order, |
| 6 | +so this is not robust anyway. |
| 7 | + |
| 8 | +Still append <prefix>_LDFLAGS_OTHER to LINK_FLAGS, as this may contain e.g. a |
| 9 | +required linker rpath. |
| 10 | + |
| 11 | +--- cmake/pkg-config.cmake~ 2024-10-08 00:19:41.000000000 +0200 |
| 12 | ++++ cmake/pkg-config.cmake 2024-11-08 17:14:01.580195312 +0100 |
| 13 | +@@ -992,13 +992,12 @@ |
| 14 | + endif() |
| 15 | + |
| 16 | + # Transform semi-colon seperated list in to space separated list. |
| 17 | +- foreach(FLAG ${${PREFIX}_LDFLAGS}) |
| 18 | ++ foreach(FLAG ${${PREFIX}_LDFLAGS_OTHER}) |
| 19 | + set(LDFLAGS "${LDFLAGS} ${FLAG}") |
| 20 | + endforeach() |
| 21 | + |
| 22 | + # Update the flags. |
| 23 | + set_target_properties(${TARGET} PROPERTIES LINK_FLAGS${CONFIG} "${LDFLAGS}") |
| 24 | +- _filter_link_flags(${TARGET} ${IS_GENERAL} ${IS_DEBUG} "${${PREFIX}_LDFLAGS}") |
| 25 | + _filter_link_flags(${TARGET} ${IS_GENERAL} ${IS_DEBUG} |
| 26 | + "${${PREFIX}_LDFLAGS_OTHER}") |
| 27 | + endmacro( |
| 28 | +@@ -1046,12 +1046,7 @@ |
| 29 | + endif() |
| 30 | + endif() |
| 31 | + |
| 32 | +- # Include/libraries paths seems to be filtered on Linux, add paths again. |
| 33 | +- link_directories(${${PREFIX}_LIBRARY_DIRS}) |
| 34 | +- if(DEFINED ${PREFIX}_DEBUG_FOUND) |
| 35 | +- link_directories(${${PREFIX}_DEBUG_LIBRARY_DIRS}) |
| 36 | +- endif() |
| 37 | +- |
| 38 | ++ target_link_libraries(${TARGET} ${PUBLIC_KEYWORD} ${${PREFIX}_LINK_LIBRARIES}) |
| 39 | + endmacro(PKG_CONFIG_USE_LLINK_DEPENDENCY) |
| 40 | + |
| 41 | + macro(BUILD_PREFIX_FOR_PKG DEPENDENCY PREFIX) |
0 commit comments