From ae701483d2ca23631a73610fbd84fbbf0e07b3eb Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 8 May 2019 13:47:56 -0700 Subject: [PATCH 1/2] Use FindPython3.cmake rather than the deprecated FindPythonInterp.cmake --- tools/FindPythonLibsNew.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/FindPythonLibsNew.cmake b/tools/FindPythonLibsNew.cmake index 919a384ea4..caf447bc1e 100644 --- a/tools/FindPythonLibsNew.cmake +++ b/tools/FindPythonLibsNew.cmake @@ -57,12 +57,12 @@ endif() # Use the Python interpreter to find the libs. if(PythonLibsNew_FIND_REQUIRED) - find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED) + find_package(Python3 ${PythonLibsNew_FIND_VERSION} REQUIRED) else() - find_package(PythonInterp ${PythonLibsNew_FIND_VERSION}) + find_package(Python3 ${PythonLibsNew_FIND_VERSION}) endif() -if(NOT PYTHONINTERP_FOUND) +if(NOT Python3_FOUND) set(PYTHONLIBS_FOUND FALSE) return() endif() @@ -73,7 +73,7 @@ endif() # # The library suffix is from the config var LDVERSION sometimes, otherwise # VERSION. VERSION will typically be like "2.7" on unix, and "27" on windows. -execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" +execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "from distutils import sysconfig as s;import sys;import struct; print('.'.join(str(v) for v in sys.version_info)); print(sys.prefix); @@ -191,8 +191,8 @@ SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") -find_package_message(PYTHON +find_package_message(Python3 "Found PythonLibs: ${PYTHON_LIBRARY}" - "${PYTHON_EXECUTABLE}${PYTHON_VERSION}") + "${Python3_EXECUTABLE}${PYTHON_VERSION}") set(PYTHONLIBS_FOUND TRUE) From d9c29462f3e8b96113ab3c2ac0cf328d2349c5b9 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 8 May 2019 15:55:25 -0700 Subject: [PATCH 2/2] Upgrade the minimum required CMake to the first one providing FindPython. Use FindPython rather than FindPython3, as pybind11 still supports Python2 --- CMakeLists.txt | 2 +- tools/FindPythonLibsNew.cmake | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85ecd9028f..e24286023d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ # All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.12.4) if (POLICY CMP0048) # cmake warns if loaded from a min-3.0-required parent dir, so silence the warning: diff --git a/tools/FindPythonLibsNew.cmake b/tools/FindPythonLibsNew.cmake index caf447bc1e..04336a651c 100644 --- a/tools/FindPythonLibsNew.cmake +++ b/tools/FindPythonLibsNew.cmake @@ -57,12 +57,12 @@ endif() # Use the Python interpreter to find the libs. if(PythonLibsNew_FIND_REQUIRED) - find_package(Python3 ${PythonLibsNew_FIND_VERSION} REQUIRED) + find_package(Python ${PythonLibsNew_FIND_VERSION} REQUIRED) else() - find_package(Python3 ${PythonLibsNew_FIND_VERSION}) + find_package(Python ${PythonLibsNew_FIND_VERSION}) endif() -if(NOT Python3_FOUND) +if(NOT Python_FOUND) set(PYTHONLIBS_FOUND FALSE) return() endif() @@ -73,7 +73,7 @@ endif() # # The library suffix is from the config var LDVERSION sometimes, otherwise # VERSION. VERSION will typically be like "2.7" on unix, and "27" on windows. -execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" +execute_process(COMMAND "${Python_EXECUTABLE}" "-c" "from distutils import sysconfig as s;import sys;import struct; print('.'.join(str(v) for v in sys.version_info)); print(sys.prefix); @@ -191,8 +191,8 @@ SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") -find_package_message(Python3 +find_package_message(PYTHON "Found PythonLibs: ${PYTHON_LIBRARY}" - "${Python3_EXECUTABLE}${PYTHON_VERSION}") + "${Python_EXECUTABLE}${PYTHON_VERSION}") set(PYTHONLIBS_FOUND TRUE)