# HG changeset patch
# User Chun-wei Fan <fanchunwei@src.gnome.org>
# Date 1646799957 -28800
#      Wed Mar 09 12:25:57 2022 +0800
# Node ID de959d58debd6bd5f6d20757965a5f961cd3a3b1
# Parent  4dab6613f318c09cfd09b0321417781494feafc5
CMake: Relax check for Python 3.x support on Windows

Since the code is now ported to support Python 3.x on Windows, we can enable
building the Python-3.x version of the Python modules on Windows directly.

Not sure about the other platforms that the Python libxslt module supports, so
continue to require unistd.h and have F_GETFL support in fcntl.h on the other
platforms.

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,10 +59,16 @@
 if(LIBXSLT_WITH_PYTHON)
 	check_include_files(unistd.h HAVE_UNISTD_H)
 	check_symbol_exists(F_GETFL fcntl.h HAVE_F_GETFL)
-	find_package(Python COMPONENTS Interpreter Development REQUIRED)
-        #set(LIBXSLT_PYTHON_INSTALL_DIR ${Python_SITEARCH} CACHE PATH "Python bindings install directory")
-	set(LIBXSLT_PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/python"
-	    CACHE PATH "Python bindings install directory")
+	if(WIN32 OR (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")
+	set(LIBXSLT_PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/python" CACHE PATH "Python bindings install directory")
 endif()
 
 if(LIBXSLT_WITH_THREADS)