From 4c65aa572dfccbc2934b542582aee1cdec6803e8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 10 May 2023 18:48:47 -0400 Subject: [PATCH] Prefer custom python interpreter set via -DPython_EXECUTABLE if possible --- cmake/Modules/CodingStandard.cmake | 4 ++++ cmake/Modules/Documentation.cmake | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 6bb607be12..4efd373d22 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -5,6 +5,10 @@ if(CMAKE_VERSION VERSION_LESS 3.12) set(Python3_VERSION ${PYTHON_VERSION_STRING}) endif() else() + # use default (or custom) Python executable, if version is sufficient + if(Python_VERSION VERSION_GREATER_EQUAL 3.5) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) + endif() find_package(Python3 COMPONENTS Interpreter QUIET) endif() diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake index 46295feea3..0b01407cd9 100644 --- a/cmake/Modules/Documentation.cmake +++ b/cmake/Modules/Documentation.cmake @@ -4,14 +4,18 @@ option(BUILD_DOC "Build LAMMPS HTML documentation" OFF) if(BUILD_DOC) - # Sphinx 3.x requires at least Python 3.5 + # Current Sphinx versions require at least Python 3.8 if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.5 REQUIRED) + find_package(PythonInterp 3.8 REQUIRED) set(VIRTUALENV ${PYTHON_EXECUTABLE} -m venv) else() + # use default (or custom) Python executable, if version is sufficient + if(Python_VERSION VERSION_GREATER_EQUAL 3.8) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) + endif() find_package(Python3 REQUIRED COMPONENTS Interpreter) - if(Python3_VERSION VERSION_LESS 3.5) - message(FATAL_ERROR "Python 3.5 and up is required to build the HTML documentation") + if(Python3_VERSION VERSION_LESS 3.8) + message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") endif() set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) endif()