CMake: try harder to find the right Python version

The FindPythonInterp module does not verify that a discovered 'python'
program is actually Python 3. Replace this deprecated module by a modern
version that was introduced with CMake 3.12.

Remove PYTHON_EXECUTABLE from WSDG now that it is much more likely that
CMake discovers the right version.

Change-Id: I1f8438baced3d5bf9e1e2732980ad177d3257ca3
Reviewed-on: https://code.wireshark.org/review/31468
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Peter Wu 2019-01-09 19:34:57 +01:00 committed by Anders Broman
parent 1243976ccd
commit 3cc0cfc48c
3 changed files with 17 additions and 6 deletions

View File

@ -913,7 +913,7 @@ endif()
# - set HAVE_XXX
# The minimum package list
set(PACKAGELIST Git GLIB2 GMODULE2 GTHREAD2 GCRYPT LEX YACC Perl PythonInterp)
set(PACKAGELIST Git GLIB2 GMODULE2 GTHREAD2 GCRYPT LEX YACC Perl)
set(LEX_OPTIONS REQUIRED)
set(GLIB2_OPTIONS REQUIRED)
set(GLIB2_FIND_OPTIONS REQUIRED)
@ -921,9 +921,21 @@ set(GLIB2_MIN_VERSION 2.32.0)
set(GTHREAD2_OPTIONS REQUIRED)
set(GCRYPT_OPTIONS "1.4.2" REQUIRED)
set(Perl_OPTIONS REQUIRED)
set(PythonInterp_OPTIONS "3.4" REQUIRED)
set(YACC_OPTIONS REQUIRED)
if(CMAKE_VERSION VERSION_LESS "3.12")
# Locate the Python interpreter. Finds the wrong (Python 2) version if:
# - PATH contains python3.6, but not python3 (3.4). Affects RHEL7+EPEL.
# - Path contains C:\Python27 but not C:\Python37 (which is installed,
# but not present in PATH).
find_package(PythonInterp 3.4 REQUIRED)
else()
find_package(Python3 3.4 REQUIRED)
# Several files (including LocatePythonModule) still use the old name
# from FindPythonInterp, let's stick to it for now.
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
endif()
if (NOT WIN32)
set(PACKAGELIST ${PACKAGELIST} Gettext M)
set(M_OPTIONS REQUIRED)

View File

@ -6,7 +6,9 @@
# After PATHS additional paths for python to search can be provided.
# When REQUIRED is set, the function will abort the cmake execution is the module is not found
function(LOCATE_PYTHON_MODULE module)
find_package(PythonInterp)
if(NOT PYTHON_EXECUTABLE)
find_package(PythonInterp)
endif()
# Parse (additional) arguments
set(options REQUIRED)

View File

@ -117,9 +117,6 @@ Let you set the path to a locally-compiled version of c-ares. Most
optional libraries have xxx_INCLUDE_DIR and xxx_LIB flags that let you
control their discovery.
-DPYTHON_EXECUTABLE=c:/Python36/python:: Force the Python path.
-DENABLE_APPLICATION_BUNDLE=OFF:: Disable building an application bundle (Wireshark.app) on macOS
You can list all build variables (with help) by running `cmake -LH [options]