1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 13:26:38 +02:00

python: fix archaic and soft-deprecated use of raw cmake vars

In commit 9a9a262ea1 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: 9a9a262ea1
Fixes: https://github.com/weechat/weechat/pull/2251
Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
This commit is contained in:
Eli Schwartz
2026-01-26 22:22:12 -05:00
committed by Sébastien Helleu
parent 4c79e870af
commit 0bbae498c9
+3 -3
View File
@@ -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")