CMake: Look for Python in more places.

According to PEP 514, Python.org's Windows installer stores its
installation path in

HKEY_LOCAL_MACHINE\Software\Python\<Company>\<Tag>\InstallPath

where <Tag> is the value of sys.winver. Newer versions of python add "-32"
and "-64" to the version in order to allow side by side installations.
Adjust LocatePythonExecutable accordingly.

Change-Id: I8c7f8b4c31b37e7f687ce9909f97d62a779cfa91
Reviewed-on: https://code.wireshark.org/review/22048
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2017-06-08 15:30:35 -07:00
parent 49a55b9666
commit 6a16f158c8
1 changed files with 8 additions and 5 deletions

View File

@ -5,14 +5,17 @@
if(NOT PYTHON_EXECUTABLE AND WIN32)
foreach(_major_version 3 2)
foreach(_minor_version 7 6 5 4 3 2 1)
find_program(PYTHON_EXECUTABLE
python.exe
PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_major_version}.${_minor_version}\\InstallPath]
NO_DEFAULT_PATH
)
if (PYTHON_EXECUTABLE)
break()
endif()
find_program(PYTHON_EXECUTABLE
python.exe
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_major_version}.${_minor_version}\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_major_version}.${_minor_version}-32\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_major_version}.${_minor_version}-64\\InstallPath]
NO_DEFAULT_PATH
)
endforeach()
endforeach()
endif()