From 0bbae498c9669911c7bafafdf24fbf91b545f2f3 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 26 Jan 2026 22:22:12 -0500 Subject: [PATCH] python: fix archaic and soft-deprecated use of raw cmake vars In commit 9a9a262ea171c1092fcab560db57bb8cc4e65ac9 we moved from pkg-config to find_package() to work around a deficiency in the pkgsrc package manager, which does not ship pkg-config files as intended by CPython. Modern CMake discourages use of "FOO_LIBRARIES" in all cases, when imported "interface" libraries can and should be used instead. The meson equivalent is `dependency()` versus `cc.find_library()`, so this is certainly a general trend among modern build systems. An imported interface target, such as the previous PkgConfig::PYTHON, carries with it the various internal properties such as DEFINITIONS, INCLUDE_DIRS, or LIBRARIES, and batch applies them. It also avoids leaking across cmake 2.x style whole-directory scopes. Use the documented cmake imported interface target for embedding Python and avoid `add_definitions(${Python_DEFINITIONS})` and similar. As a bonus, it's also shorter and more concise. Fixes: 9a9a262ea171c1092fcab560db57bb8cc4e65ac9 Fixes: https://github.com/weechat/weechat/pull/2251 Signed-off-by: Eli Schwartz --- src/plugins/python/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/python/CMakeLists.txt b/src/plugins/python/CMakeLists.txt index c0003a1ae..dc751ceef 100644 --- a/src/plugins/python/CMakeLists.txt +++ b/src/plugins/python/CMakeLists.txt @@ -31,8 +31,8 @@ add_library(python MODULE ) set_target_properties(python PROPERTIES PREFIX "") -include_directories(${Python_INCLUDE_DIRS}) -add_definitions(${Python_DEFINITIONS}) -target_link_libraries(python ${Python_LIBRARIES} weechat_plugins_scripts coverage_config) +if(Python_FOUND) + target_link_libraries(python Python::Python weechat_plugins_scripts coverage_config) +endif() install(TARGETS python LIBRARY DESTINATION "${WEECHAT_LIBDIR}/plugins")