From 07444e4e38ca32080d620219504dc3855ea3de6c Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 24 Apr 2021 17:35:17 -0700 Subject: [PATCH] build: use `find_package(Python3)` This bumps the CMake minimum version to 3.12 to enable the use of FindPython3. This allows the replacement of the `python3` with a CMake variable defined by the module. This avoids the additional handling for python being renamed to python3. This partially resolves #2049. --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1c91108d1..50e2ee7422 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.1 FATAL_ERROR) +cmake_minimum_required (VERSION 3.12 FATAL_ERROR) project (Graphviz) include(FeatureSummary) @@ -105,11 +105,13 @@ endif() # ============================ Set Graphviz version ============================ +find_package(Python3 COMPONENTS Interpreter REQUIRED) + if (DEFINED VERSION) set(GRAPHVIZ_VERSION_STRING "${VERSION}") else() execute_process( - COMMAND python3 gen_version.py + COMMAND "${Python3_EXECUTABLE}" gen_version.py WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE gen_version_result OUTPUT_VARIABLE GRAPHVIZ_VERSION_STRING @@ -127,7 +129,7 @@ if (DEFINED DATE) else() # Set GRAPHVIZ_VERSION_BUILD to time of last commit, or to 0 if that fails. execute_process( - COMMAND python3 gen_version.py --committer-date-graphviz + COMMAND "${Python3_EXECUTABLE}" gen_version.py --committer-date-graphviz WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE gen_date_result OUTPUT_VARIABLE GRAPHVIZ_VERSION_BUILD -- GitLab