From 5417ea5f1f33f62e2511bda74477da05dce900a3 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Sun, 14 Apr 2024 12:07:15 -0500 Subject: CMake: Use imported targets for PkgConfig packages (#954) This carries include directories and the required link flags. Several libraries brought in through pkg_check_modules aren't linked correctly using the _LDFLAGS variables. Instead, they link the libraries directly with `-l`. This is problematic because it doesn't properly pull in the actual directory of the library being linked when it is not in a system library directory. Likewise, the necessary include directories for several of these targets aren't properly set either. Linking against the imported targets automatically pulls in the necessary include directories. --- src/CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b12880c3b..326fb5d09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -535,7 +535,7 @@ if(FLTK_USE_X11) endif(FLTK_USE_X11) if(FLTK_BACKEND_WAYLAND) - pkg_check_modules(DBUS dbus-1) + pkg_check_modules(DBUS IMPORTED_TARGET dbus-1) set(IDIRS "${CMAKE_CURRENT_BINARY_DIR}") set(CDEFS "_GNU_SOURCE;HAVE_MEMFD_CREATE;HAVE_MKOSTEMP;HAVE_POSIX_FALLOCATE") set(COPTS "-fPIC") @@ -676,10 +676,10 @@ endif(HAVE_XRENDER) if(USE_PANGO) ### FIXME ### This needs to use the PKG_* variables directly - list(APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGO} ${HAVE_LIB_PANGOCAIRO}) - list(APPEND OPTIONAL_LIBS ${HAVE_LIB_CAIRO} ${HAVE_LIB_GOBJECT}) + list(APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGO} PkgConfig::PANGOCAIRO) + list(APPEND OPTIONAL_LIBS PkgConfig::CAIRO ${HAVE_LIB_GOBJECT}) if(USE_PANGOXFT) - list(APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGOXFT}) + list(APPEND OPTIONAL_LIBS PkgConfig::PANGOXFT) endif(USE_PANGOXFT) endif(USE_PANGO) @@ -754,16 +754,16 @@ if(UNIX AND FLTK_BACKEND_WAYLAND) endif() if(FLTK_USE_GL) - list(APPEND OPTIONAL_LIBS "-lwayland-egl -lEGL") + list(APPEND OPTIONAL_LIBS PkgConfig::WLD_EGL PkgConfig::PKG_EGL) endif(FLTK_USE_GL) if(USE_SYSTEM_LIBDECOR) - list(APPEND OPTIONAL_LIBS "-ldecor-0") + list(APPEND OPTIONAL_LIBS PkgConfig::SYSTEM_LIBDECOR) elseif(GTK_FOUND AND FLTK_USE_LIBDECOR_GTK) - list(APPEND OPTIONAL_LIBS ${GTK_LDFLAGS} ) + list(APPEND OPTIONAL_LIBS PkgConfig::GTK) endif(USE_SYSTEM_LIBDECOR) - list(APPEND OPTIONAL_LIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldl") + list(APPEND OPTIONAL_LIBS PkgConfig::WLDCURSOR PkgConfig::WLDCLIENT PkgConfig::XKBCOMMON -ldl) if(DBUS_FOUND) - list(APPEND OPTIONAL_LIBS "${DBUS_LDFLAGS}") + list(APPEND OPTIONAL_LIBS PkgConfig::DBUS) endif(DBUS_FOUND) endif(UNIX AND FLTK_BACKEND_WAYLAND) -- cgit v1.2.3