From 115d3f883e2fceea0f2e7df0e570864a01178f4e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sat, 4 Jun 2022 14:19:07 +0200 Subject: [PATCH] Add target_link_directory() compat function We need this function to deal with pkgconfig files properly, but unfortunately it doesn't exist until CMake 3.13, and we need to support CMake 3.10. So add a hacky compatibility function for older systems. --- CMakeLists.txt | 2 ++ cmake/TargetLinkDirectories.cmake | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 cmake/TargetLinkDirectories.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c6b99fd61..f8cacb9dd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ include(CheckCSourceRuns) include(CMakeMacroLibtoolFile) +include(cmake/TargetLinkDirectories.cmake) + project(tigervnc) set(VERSION 1.12.80) diff --git a/cmake/TargetLinkDirectories.cmake b/cmake/TargetLinkDirectories.cmake new file mode 100644 index 0000000000..11b056702e --- /dev/null +++ b/cmake/TargetLinkDirectories.cmake @@ -0,0 +1,12 @@ +# Compatibility replacement of target_link_directories() for older cmake + +if(${CMAKE_VERSION} VERSION_LESS "3.13.0") + function(target_link_directories TARGET SCOPE) + get_target_property(INTERFACE_LINK_LIBRARIES ${TARGET} INTERFACE_LINK_LIBRARIES) + foreach(DIRECTORY ${ARGN}) + list(INSERT INTERFACE_LINK_LIBRARIES 0 "-L${DIRECTORY}") + endforeach() + set_target_properties(${TARGET} PROPERTIES + INTERFACE_LINK_LIBRARIES "${INTERFACE_LINK_LIBRARIES}") + endfunction() +endif()