[libxslt] Use Python3 if compatible
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxslt] Use Python3 if compatible
- Date: Tue, 2 Mar 2021 14:13:58 +0000 (UTC)
commit 9835e6f611aca6b0e1a2c15a30a19100742cf7b4
Author: Markus Rickert <rickert fortiss org>
Date: Mon Feb 22 21:14:15 2021 +0100
Use Python3 if compatible
CMakeLists.txt | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d990784..4a88a44c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,7 @@ include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
+include(CheckSymbolExists)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
@@ -49,8 +50,17 @@ if(LIBXSLT_WITH_CRYPTO)
endif()
if(LIBXSLT_WITH_PYTHON)
- find_package(Python2 COMPONENTS Interpreter Development REQUIRED)
- set(LIBXSLT_PYTHON_INSTALL_DIR ${Python2_SITEARCH} CACHE PATH "Python bindings install directory")
+ check_include_files(unistd.h HAVE_UNISTD_H)
+ check_symbol_exists(F_GETFL fcntl.h HAVE_F_GETFL)
+ if(HAVE_UNISTD_H AND HAVE_F_GETFL)
+ find_package(Python COMPONENTS Interpreter Development REQUIRED)
+ else()
+ find_package(Python2 COMPONENTS Interpreter Development REQUIRED)
+ add_library(Python::Python ALIAS Python2::Python)
+ set(Python_EXECUTABLE ${Python2_EXECUTABLE})
+ set(Python_SITEARCH ${Python2_SITEARCH})
+ endif()
+ set(LIBXSLT_PYTHON_INSTALL_DIR ${Python_SITEARCH} CACHE PATH "Python bindings install directory")
endif()
if(LIBXSLT_WITH_THREADS)
@@ -366,7 +376,7 @@ if(LIBXSLT_WITH_PYTHON)
set(ENV{SRCDIR} ${CMAKE_CURRENT_SOURCE_DIR}/python)
execute_process(
COMMAND
- ${Python2_EXECUTABLE}
+ ${Python_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/python/generator.py
${CMAKE_CURRENT_SOURCE_DIR}/doc/libxslt-api.xml
${CMAKE_CURRENT_SOURCE_DIR}/python/libxslt-python-api.xml
@@ -393,7 +403,7 @@ if(LIBXSLT_WITH_PYTHON)
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/python>
)
- target_link_libraries(LibXsltMod LibXslt LibExslt Python2::Python)
+ target_link_libraries(LibXsltMod LibXslt LibExslt Python::Python)
set_target_properties(
LibXsltMod
PROPERTIES
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]