Skip to content

Commit

Permalink
Fix pkg_check_modules usage
Browse files Browse the repository at this point in the history
Per documentation:
<XXX>_LIBRARIES - only the libraries (without the '-l')
<XXX>_LINK_LIBRARIES - the libraries and their absolute paths

Using _LIBRARIES assumes that appropriate default -L arguments will be
provided by the environment/system. CMake discourages directly adding
paths with -L or link_directiories because it polutes the environment
and can cause issues. So the only way to ensure correct build on some
platforms is to use absolute paths provided by _LINK_LIBRARIES.

Signed-off-by: Tin Švagelj <[email protected]>
  • Loading branch information
Caellian committed Nov 16, 2024
1 parent 905aa15 commit a0a17fb
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ endif(BUILD_IPV6)

if(BUILD_HTTP)
pkg_check_modules(MICROHTTPD REQUIRED libmicrohttpd>=0.9.25)
set(conky_libs ${conky_libs} ${MICROHTTPD_LIBRARIES})
set(conky_libs ${conky_libs} ${MICROHTTPD_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${MICROHTTPD_INCLUDE_DIRS})
endif(BUILD_HTTP)

Expand Down Expand Up @@ -471,28 +471,28 @@ if(BUILD_WAYLAND)

if(OS_DARWIN OR OS_DRAGONFLY OR OS_FREEBSD OR OS_NETBSD OR OS_OPENBSD)
pkg_check_modules(EPOLL REQUIRED epoll-shim)
set(conky_libs ${conky_libs} ${EPOLL_LIBRARIES})
set(conky_libs ${conky_libs} ${EPOLL_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${EPOLL_INCLUDE_DIRS})
endif(OS_DARWIN OR OS_DRAGONFLY OR OS_FREEBSD OR OS_NETBSD OR OS_OPENBSD)

pkg_check_modules(CAIRO REQUIRED cairo)
set(conky_libs ${conky_libs} ${CAIRO_LIBRARIES})
set(conky_libs ${conky_libs} ${CAIRO_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${CAIRO_INCLUDE_DIR})

pkg_check_modules(PANGO REQUIRED pango)
set(conky_libs ${conky_libs} ${PANGO_LIBRARIES})
set(conky_libs ${conky_libs} ${PANGO_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGO_INCLUDE_DIRS})

pkg_check_modules(PANGOCAIRO pangocairo)
set(conky_libs ${conky_libs} ${PANGOCAIRO_LIBRARIES})
set(conky_libs ${conky_libs} ${PANGOCAIRO_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGOCAIRO_INCLUDE_DIRS})

pkg_check_modules(PANGOFC pangofc)
set(conky_libs ${conky_libs} ${PANGOFC_LIBRARIES})
set(conky_libs ${conky_libs} ${PANGOFC_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGOFC_INCLUDE_DIRS})

pkg_check_modules(PANGOFT2 pangoft2)
set(conky_libs ${conky_libs} ${PANGOFT2_LIBRARIES})
set(conky_libs ${conky_libs} ${PANGOFT2_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGOFT2_INCLUDE_DIRS})
endif(BUILD_WAYLAND)

Expand All @@ -505,17 +505,17 @@ include_directories(3rdparty/toluapp/include)
# Check for libraries used by Lua bindings
if(BUILD_LUA_CAIRO)
pkg_check_modules(CAIRO REQUIRED cairo>=1.14)
set(luacairo_libs ${CAIRO_LIBRARIES} ${LUA_LIBRARIES})
set(luacairo_libs ${CAIRO_LINK_LIBRARIES} ${LUA_LIBRARIES})
set(luacairo_includes ${CAIRO_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})

if(BUILD_LUA_CAIRO_XLIB)
pkg_check_modules(CAIROXLIB REQUIRED cairo-xlib)
set(luacairo_libs ${CAIROXLIB_LIBRARIES} ${luacairo_libs})
set(luacairo_libs ${CAIROXLIB_LINK_LIBRARIES} ${luacairo_libs})
set(luacairo_includes ${CAIROXLIB_INCLUDE_DIRS} ${luacairo_includes})
endif(BUILD_LUA_CAIRO_XLIB)

# This is required because OpenBSD requires X11_LIBRARIES instead of -lX11
# because X11 isn't in default linker search path
# Required because X11 isn't in default linker search path on some platforms
# (OpenBSD), so absolute paths provided by X11_LIBRARIES must be used.
list(REMOVE_DUPLICATES luacairo_libs)
if("X11" IN_LIST luacairo_libs)
list(REMOVE_ITEM luacairo_libs "X11" "Xext")
Expand All @@ -540,7 +540,7 @@ endif(BUILD_LUA_IMLIB2)

if(BUILD_LUA_RSVG)
pkg_check_modules(RSVG REQUIRED librsvg-2.0>=2.52)
set(luarsvg_libs ${RSVG_LIBRARIES} ${LUA_LIBRARIES})
set(luarsvg_libs ${RSVG_LINK_LIBRARIES} ${LUA_LIBRARIES})
set(luarsvg_includes ${RSVG_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
endif(BUILD_LUA_RSVG)

Expand All @@ -555,7 +555,7 @@ if(BUILD_AUDACIOUS)
pkg_check_modules(AUDACIOUS REQUIRED audacious<1.4.0)
endif(NEW_AUDACIOUS_FOUND)

set(conky_libs ${conky_libs} ${AUDACIOUS_LIBRARIES} ${DBUS_GLIB_LIBRARIES})
set(conky_libs ${conky_libs} ${AUDACIOUS_LINK_LIBRARIES} ${DBUS_GLIB_LIBRARIES})
set(conky_includes
${conky_includes}
${AUDACIOUS_INCLUDE_DIRS}
Expand All @@ -564,7 +564,7 @@ endif(BUILD_AUDACIOUS)

if(BUILD_XMMS2)
pkg_check_modules(XMMS2 REQUIRED xmms2-client>=0.6)
set(conky_libs ${conky_libs} ${XMMS2_LIBRARIES})
set(conky_libs ${conky_libs} ${XMMS2_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${XMMS2_INCLUDE_DIRS})
endif(BUILD_XMMS2)

Expand Down Expand Up @@ -604,26 +604,26 @@ endif(BUILD_JOURNAL)

if(BUILD_PULSEAUDIO)
pkg_check_modules(PULSEAUDIO REQUIRED libpulse)
set(conky_libs ${conky_libs} ${PULSEAUDIO_LIBRARIES})
set(conky_libs ${conky_libs} ${PULSEAUDIO_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${PULSEAUDIO_INCLUDE_DIRS})
endif(BUILD_PULSEAUDIO)

if(WANT_CURL)
pkg_check_modules(CURL REQUIRED libcurl)
set(conky_libs ${conky_libs} ${CURL_LIBRARIES})
set(conky_libs ${conky_libs} ${CURL_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${CURL_INCLUDE_DIRS})
endif(WANT_CURL)

# Common libraries
if(WANT_GLIB)
pkg_check_modules(GLIB REQUIRED glib-2.0>=2.36)
set(conky_libs ${conky_libs} ${GLIB_LIBRARIES})
set(conky_libs ${conky_libs} ${GLIB_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${GLIB_INCLUDE_DIRS})
endif(WANT_GLIB)

if(WANT_CURL)
pkg_check_modules(CURL REQUIRED libcurl)
set(conky_libs ${conky_libs} ${CURL_LIBRARIES})
set(conky_libs ${conky_libs} ${CURL_LINK_LIBRARIES})
set(conky_includes ${conky_includes} ${CURL_INCLUDE_DIRS})
endif(WANT_CURL)

Expand Down

0 comments on commit a0a17fb

Please sign in to comment.