From 19a2cc563495ad7aeb4c8e11ae0427bdaf183bdf Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sun, 5 Nov 2023 10:52:27 +0100 Subject: [PATCH] CMake: Query Python interpreter with `find_package` This lets us fail early at configure time if a suitable Python 3 interpreter is not present, instead of delaying the error until Ninja attempts to run `embed_as_string_view.py` to generate a header in the middle of the build. Refs #21791 --- Meta/CMake/code_generators.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Meta/CMake/code_generators.cmake b/Meta/CMake/code_generators.cmake index 78891ac208..63b8e7fb62 100644 --- a/Meta/CMake/code_generators.cmake +++ b/Meta/CMake/code_generators.cmake @@ -8,9 +8,10 @@ function(embed_as_string_view name source_file output source_variable_name) if (EMBED_STRING_VIEW_NAMESPACE) set(namespace_arg "-s ${EMBED_STRING_VIEW_NAMESPACE}") endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter) add_custom_command( OUTPUT "${output}" - COMMAND "python3" "${SerenityOS_SOURCE_DIR}/Meta/embed_as_string_view.py" "${source_file}" -o "${output}.tmp" -n "${source_variable_name}" ${namespace_arg} + COMMAND "${Python3_EXECUTABLE}" "${SerenityOS_SOURCE_DIR}/Meta/embed_as_string_view.py" "${source_file}" -o "${output}.tmp" -n "${source_variable_name}" ${namespace_arg} COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${output}.tmp" "${output}" COMMAND "${CMAKE_COMMAND}" -E remove "${output}.tmp" VERBATIM