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
This commit is contained in:
parent
6de32e5359
commit
19a2cc5634
Notes:
sideshowbarker
2024-07-17 11:29:41 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/19a2cc5634 Pull-request: https://github.com/SerenityOS/serenity/pull/21792
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue