[Openvpn-devel,XS] Change in openvpn[master]: Ensure that Python3 is available

Message ID 59b20daee30f48b3b71c1a299e838b7c9bb3652a-HTML@gerrit.openvpn.net
State New
Headers show
Series [Openvpn-devel,XS] Change in openvpn[master]: Ensure that Python3 is available | expand

Commit Message

plaisthos (Code Review) Dec. 25, 2024, 5:15 p.m. UTC
Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/846?usp=email

to review the following change.


Change subject: Ensure that Python3 is available
......................................................................

Ensure that Python3 is available

Use the more standard cmake find_package to search for Python3 and make it required. This also provides
a better error message than "version.cmake" not found when python3 is missing.

Change-Id: I350fd615ed8474d34392a057a5f8bded78173949
---
M CMakeLists.txt
1 file changed, 3 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/46/846/1

Patch

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61f0cc5..65fdbc7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,7 +74,6 @@ 
         /MP
         /W2
         /sdl
-        /Qspectre
         /guard:cf
         /FC
         /ZH:SHA_256
@@ -107,9 +106,9 @@ 
     endif ()
 endif ()
 
-find_program(PYTHON NAMES python3 python)
+find_package(Python3 REQUIRED COMPONENTS Interpreter)
 execute_process(
-    COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/parse-version.m4.py ${CMAKE_CURRENT_SOURCE_DIR}/version.m4
+    COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/parse-version.m4.py ${CMAKE_CURRENT_SOURCE_DIR}/version.m4
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     )
 include(${CMAKE_CURRENT_BINARY_DIR}/version.cmake)
@@ -339,7 +338,7 @@ 
 
 add_custom_command(
     OUTPUT always_rebuild config-version.h
-    COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/git-version.py
+    COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/git-version.py
     )
 set(HAVE_CONFIG_VERSION_H YES)