mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Use FindPython3 in addition to pkg-config
This commit is contained in:
@@ -172,9 +172,42 @@ if(WANT_PERL)
|
||||
endif()
|
||||
if (WANT_PYTHON)
|
||||
find_package(Perl 5.10 REQUIRED)
|
||||
pkg_check_modules(PYTHON "${WANT_PYTHON_VERSION}-embed")
|
||||
if (NOT PYTHON_FOUND)
|
||||
pkg_check_modules(PYTHON "${WANT_PYTHON_VERSION}" REQUIRED)
|
||||
# VERSION_GREATER_EQUAL is available only since 3.7
|
||||
if (CMAKE_VERSION VERSION_LESS 3.12)
|
||||
else()
|
||||
# Even if FindPython3 is available (since CMake 3.12) we still use
|
||||
# pkg-config, because FindPython has a hardcoded list of python
|
||||
# versions, which may become outdated when new pythons are released,
|
||||
# but when cmake in the distro is old.
|
||||
#
|
||||
# Why FindPython3 is useful at all? Because sometimes there is no
|
||||
# python3.pc, but only python-3.5.pc and python-3.6.pc; which would
|
||||
# force user to provide the version explicitly via
|
||||
# WANT_PYTHON_VERSION. This is the case on Gentoo when NOT building
|
||||
# via emerge.
|
||||
if (WANT_PYTHON_VERSION STREQUAL "python3")
|
||||
find_package(Python3 COMPONENTS Development)
|
||||
else()
|
||||
# We used to pass value like "python-3.5" to the variable.
|
||||
if (WANT_PYTHON_VERSION MATCHES "^(python-)?(.*)$")
|
||||
find_package(Python3 COMPONENTS Development
|
||||
EXACT "${CMAKE_MATCH_2}")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid value of WANT_PYTHON_VERSION")
|
||||
endif()
|
||||
endif()
|
||||
# Compatibility with pkg-config variables
|
||||
set(Python3_LDFLAGS "${Python3_LIBRARIES}")
|
||||
endif()
|
||||
if (NOT Python3_FOUND AND WANT_PYTHON_VERSION MATCHES "^python")
|
||||
# Since python 3.8, -embed is required for embedding.
|
||||
pkg_check_modules(Python3 "${WANT_PYTHON_VERSION}-embed >= 3.0")
|
||||
if (NOT Python3_FOUND)
|
||||
pkg_check_modules(Python3 "${WANT_PYTHON_VERSION} >= 3.0")
|
||||
endif()
|
||||
endif()
|
||||
if (NOT Python3_FOUND)
|
||||
message(FATAL_ERROR "Python 3 is not found. Try disabling it.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -361,7 +394,7 @@ summary_line("SSL " "${OPENSSL_FOUND}")
|
||||
summary_line("IPv6 " "${WANT_IPV6}")
|
||||
summary_line("Async DNS" "${HAVE_THREADED_DNS}")
|
||||
summary_line("Perl " "${PERLLIBS_FOUND}")
|
||||
summary_line("Python " "${PYTHON_FOUND}")
|
||||
summary_line("Python " "${Python3_FOUND}")
|
||||
summary_line("Tcl " "${TCL_FOUND}")
|
||||
summary_line("Cyrus " "${CYRUS_FOUND}")
|
||||
summary_line("Charset " "${ICU_FOUND}")
|
||||
|
||||
@@ -50,7 +50,7 @@ execute_process(COMMAND "${brew}" --prefix python3
|
||||
if(brew_python_f EQUAL 0)
|
||||
find_package_message(brew_python "Python via Homebrew: ${brew_python}"
|
||||
"${brew_python}")
|
||||
list(APPEND Python_FRAMEWORKS_ADDITIONAL
|
||||
list(APPEND Python3_FRAMEWORKS_ADDITIONAL
|
||||
"${brew_python}/Frameworks/Python.framework")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ else()
|
||||
set(moddisable_modperl true)
|
||||
endif()
|
||||
|
||||
if(PYTHON_FOUND)
|
||||
if(Python3_FOUND)
|
||||
add_subdirectory(modpython)
|
||||
else()
|
||||
set(moddisable_modpython true)
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
# TODO: consider switching to swig_add_library() after bumping CMake
|
||||
# requirements to 3.8, when that command started using IMPLICIT_DEPENDS
|
||||
|
||||
set(modinclude_modpython PUBLIC ${PYTHON_INCLUDE_DIRS}
|
||||
set(modinclude_modpython PUBLIC ${Python3_INCLUDE_DIRS}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/.." PARENT_SCOPE)
|
||||
set(modlink_modpython PUBLIC ${PYTHON_LDFLAGS} PARENT_SCOPE)
|
||||
set(modlink_modpython PUBLIC ${Python3_LDFLAGS} PARENT_SCOPE)
|
||||
set(moddef_modpython PUBLIC "SWIG_TYPE_TABLE=znc" PARENT_SCOPE)
|
||||
set(moddepend_modpython modpython_functions modpython_swigruntime PARENT_SCOPE)
|
||||
|
||||
@@ -75,8 +75,8 @@ target_include_directories(modpython_lib PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/.."
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/.."
|
||||
${PYTHON_INCLUDE_DIRS})
|
||||
target_link_libraries(modpython_lib ${znc_link} ${PYTHON_LDFLAGS})
|
||||
${Python3_INCLUDE_DIRS})
|
||||
target_link_libraries(modpython_lib ${znc_link} ${Python3_LDFLAGS})
|
||||
set_target_properties(modpython_lib PROPERTIES
|
||||
PREFIX "_"
|
||||
OUTPUT_NAME "znc_core"
|
||||
|
||||
Reference in New Issue
Block a user