Commit 7851a188 authored by Alvin Wong's avatar Alvin Wong

Add CMake check for Python version on Windows

Maniphest Tasks: T6503, T6540, T1625
parent 9eb964b2
......@@ -190,9 +190,17 @@ include(MacroJPEG)
## so we should request the correct version in advance ##
###########################################################
find_package(PythonInterp 3.0)
find_package(PythonLibrary 3.0)
if(MINGW)
# Special check: Building on Windows and ext_python is used
find_package(PythonInterp 3.6)
find_package(PythonLibrary 3.6)
if(PYTHONLIBS_FOUND)
include("${CMAKE_CURRENT_SOURCE_DIR}/PythonWindowsCheck.cmake")
endif(PYTHONLIBS_FOUND)
else(MINGW)
find_package(PythonInterp 3.0)
find_package(PythonLibrary 3.0)
endif(MINGW)
########################
#########################
......
# Check whether the found python is the same as ext_python
# HACK: Find pythonxx.dll and compare equality. Probably not the best idea...
# TODO: Check the python version
set(_check_python_dll "python36.dll")
if(NOT ${PYTHONLIBS_VERSION_STRING} VERSION_EQUAL "3.6.2")
message(FATAL_ERROR "Windows build with Python requires Python 3.6.2, found version ${PYTHONLIBS_VERSION_STRING} instead.")
else()
if(EXISTS "${CMAKE_INSTALL_PREFIX}/python/${_check_python_dll}")
message(STATUS "python36.dll is found in \"${CMAKE_INSTALL_PREFIX}/python/\".")
file(SHA1 "${CMAKE_INSTALL_PREFIX}/python/${_check_python_dll}" _ext_python_dll_sha1)
get_filename_component(_found_python_dir ${PYTHON_EXECUTABLE} DIRECTORY)
file(SHA1 "${_found_python_dir}/${_check_python_dll}" _found_python_dll_sha1)
if(NOT ${_ext_python_dll_sha1} STREQUAL ${_found_python_dll_sha1})
message(FATAL_ERROR "The found ${_check_python_dll} is not the same as the ${_check_python_dll} from ext_python.")
endif()
else()
message(FATAL_ERROR "${_check_python_dll} is NOT found in \"${CMAKE_INSTALL_PREFIX}/python/\".")
endif()
endif()
unset(_check_python_dll)
find_package(PythonLibrary)
# PythonLibrary should've been found in the root CMakeLists.txt
set_package_properties(PythonLibrary PROPERTIES
DESCRIPTION "Python Library"
URL "http://www.python.org"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment