cmake_minimum_required(VERSION 3.24)

project(benefactor-port LANGUAGES C CXX)

# One version for every product surface. The release tag is checked against this
# file (tools/publish_release.py), Android's versionName is derived from it, and
# the pause menu prints it, so a release cannot ship two different numbers.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" BENEFACTOR_VERSION_RAW)
string(STRIP "${BENEFACTOR_VERSION_RAW}" BENEFACTOR_VERSION)
if(NOT BENEFACTOR_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
    message(FATAL_ERROR "version.txt must hold a MAJOR.MINOR.PATCH version, got '${BENEFACTOR_VERSION}'")
endif()

if(MINGW)
    # GitHub's MinGW environment can inherit MSVC-style linker flags from its
    # toolchain setup. GNU ld treats those as input paths, so remove them at
    # the project boundary while retaining the user's other linker options.
    foreach(linker_flags CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
                          CMAKE_MODULE_LINKER_FLAGS)
        foreach(msvc_flag /OPT:REF /OPT:ICF /INCREMENTAL:NO -OPT:REF -OPT:ICF
                           -INCREMENTAL:NO)
            string(REPLACE "${msvc_flag}" "" ${linker_flags}
                   "${${linker_flags}}")
        endforeach()
    endforeach()
endif()

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(BENEFACTOR_WEB)
    # The shared runtime and the SDL/Lucent subprojects are compiled before
    # the product target is declared. Apply the Emscripten pthread feature at
    # this directory boundary so every object linked into the shared-memory
    # module is compiled with atomics and bulk-memory support.
    add_compile_options(-pthread)
endif()

set(BENEFACTOR_AMIGAPORT_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/../shared/amigaport")
if(DEFINED ENV{BENEFACTOR_AMIGAPORT_DIR} AND NOT "$ENV{BENEFACTOR_AMIGAPORT_DIR}" STREQUAL "")
    set(BENEFACTOR_AMIGAPORT_DEFAULT "$ENV{BENEFACTOR_AMIGAPORT_DIR}")
endif()
set(BENEFACTOR_AMIGAPORT_DIR "${BENEFACTOR_AMIGAPORT_DEFAULT}"
    CACHE PATH "Path to the shared amigaport runtime")
get_filename_component(BENEFACTOR_AMIGAPORT_DIR "${BENEFACTOR_AMIGAPORT_DIR}"
    ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
if(NOT IS_DIRECTORY "${BENEFACTOR_AMIGAPORT_DIR}")
    message(FATAL_ERROR
        "Benefactor requires shared/amigaport at ${BENEFACTOR_AMIGAPORT_DIR}; "
        "provide -DBENEFACTOR_AMIGAPORT_DIR=<checkout>")
endif()
set(AMIGAPORT_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory("${BENEFACTOR_AMIGAPORT_DIR}" "${CMAKE_BINARY_DIR}/amigaport")

# lucent — the logging, configuration and loopback HTTP control channel this
# product had hand-rolled three times over. Same checkout convention as
# amigaport: a sibling directory, overridable for CI.
set(BENEFACTOR_LUCENT_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/../lucent")
if(DEFINED ENV{BENEFACTOR_LUCENT_DIR} AND NOT "$ENV{BENEFACTOR_LUCENT_DIR}" STREQUAL "")
    set(BENEFACTOR_LUCENT_DEFAULT "$ENV{BENEFACTOR_LUCENT_DIR}")
endif()
set(BENEFACTOR_LUCENT_DIR "${BENEFACTOR_LUCENT_DEFAULT}"
    CACHE PATH "Path to the lucent library")
get_filename_component(BENEFACTOR_LUCENT_DIR "${BENEFACTOR_LUCENT_DIR}"
    ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
if(NOT IS_DIRECTORY "${BENEFACTOR_LUCENT_DIR}")
    message(FATAL_ERROR
        "Benefactor requires lucent at ${BENEFACTOR_LUCENT_DIR}; "
        "provide -DBENEFACTOR_LUCENT_DIR=<checkout>")
endif()
set(LUCENT_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(LUCENT_BUILD_ZIP ON CACHE BOOL "" FORCE)
if(EMSCRIPTEN)
    # Emscripten provides zlib as a port, and the port is built on first use —
    # which is after CMake's FindZLIB probe has already run. Compiling this one
    # line makes the port exist so the probe finds the same zlib the browser
    # build links, instead of a second copy built by hand.
    set(BENEFACTOR_ZLIB_PORT_PROBE "${CMAKE_CURRENT_BINARY_DIR}/emscripten-zlib-port.c")
    file(WRITE "${BENEFACTOR_ZLIB_PORT_PROBE}" "int benefactor_zlib_port_probe(void);\n")
    execute_process(
        COMMAND "${CMAKE_C_COMPILER}" -sUSE_ZLIB=1 -c "${BENEFACTOR_ZLIB_PORT_PROBE}"
                -o "${BENEFACTOR_ZLIB_PORT_PROBE}.o"
        RESULT_VARIABLE BENEFACTOR_ZLIB_PORT_RESULT
        OUTPUT_QUIET ERROR_QUIET)
    if(NOT BENEFACTOR_ZLIB_PORT_RESULT EQUAL 0)
        message(FATAL_ERROR "the Emscripten zlib port could not be prepared")
    endif()
elseif(MINGW)
    set(ZLIB_USE_STATIC_LIBS ON)
endif()
if(MINGW AND LUCENT_BUILD_ZIP)
    find_package(ZLIB REQUIRED)
    include(CheckIncludeFileCXX)
    check_include_file_cxx(zlib.h BENEFACTOR_ZLIB_HEADER_IN_COMPILER_PATH)
    if(BENEFACTOR_ZLIB_HEADER_IN_COMPILER_PATH)
        # FindZLIB re-exports MinGW's implicit system include as -isystem.
        # That moves stdlib.h before libstdc++'s cstdlib and breaks include_next.
        set_property(TARGET ZLIB::ZLIB PROPERTY INTERFACE_INCLUDE_DIRECTORIES "")
    endif()
endif()
add_subdirectory("${BENEFACTOR_LUCENT_DIR}" "${CMAKE_BINARY_DIR}/lucent")

if(ANDROID)
    set(BENEFACTOR_SDL3_PREFIX "" CACHE PATH "Shared Android-port SDL3 prefix")
    if(NOT IS_DIRECTORY "${BENEFACTOR_SDL3_PREFIX}")
        message(FATAL_ERROR "Android requires -DBENEFACTOR_SDL3_PREFIX=<directory>")
    endif()
    set(SDL3_DIR "${BENEFACTOR_SDL3_PREFIX}/lib/cmake/SDL3" CACHE PATH
        "Shared Android-port SDL3 CMake package")
    find_package(SDL3 CONFIG REQUIRED)
    set(BENEFACTOR_SDL_TARGET SDL3::SDL3)
else()
    set(BENEFACTOR_SDL3_DIR "$ENV{BENEFACTOR_SDL3_DIR}" CACHE PATH
        "Optional SDL3 source checkout")
    if(IS_DIRECTORY "${BENEFACTOR_SDL3_DIR}")
        set(SDL_SHARED OFF CACHE BOOL "" FORCE)
        set(SDL_STATIC ON CACHE BOOL "" FORCE)
        set(SDL_TESTS OFF CACHE BOOL "" FORCE)
        set(SDL_X11_XSCRNSAVER OFF CACHE BOOL "" FORCE)
        add_subdirectory("${BENEFACTOR_SDL3_DIR}" "${CMAKE_BINARY_DIR}/sdl3" EXCLUDE_FROM_ALL)
        if(TARGET SDL3::SDL3-static)
            set(BENEFACTOR_SDL_TARGET SDL3::SDL3-static)
        elseif(TARGET SDL3::SDL3)
            set(BENEFACTOR_SDL_TARGET SDL3::SDL3)
        else()
            message(FATAL_ERROR "SDL3 checkout did not expose a usable CMake target")
        endif()
    else()
        find_package(SDL3 CONFIG REQUIRED)
        if(TARGET SDL3::SDL3)
            set(BENEFACTOR_SDL_TARGET SDL3::SDL3)
        else()
            message(FATAL_ERROR "SDL3 package did not expose SDL3::SDL3")
        endif()
    endif()
endif()

# setup-ui needs the SDL3 target this build selected, so it is added after
# the SDL3 block above.
# setup-ui — the shared in-app first-run setup screen, on every product including
# the browser one. A local checkout sits beside this repository; CI checks the
# shared tree out inside it, so both are candidates.
set(BENEFACTOR_SETUP_UI_CANDIDATES
    "$ENV{BENEFACTOR_SETUP_UI_DIR}"
    "${CMAKE_CURRENT_SOURCE_DIR}/../shared/setup-ui"
    "${CMAKE_CURRENT_SOURCE_DIR}/shared/setup-ui")
set(BENEFACTOR_SETUP_UI_DEFAULT "")
foreach(candidate IN LISTS BENEFACTOR_SETUP_UI_CANDIDATES)
    if(NOT "${candidate}" STREQUAL "" AND IS_DIRECTORY "${candidate}")
        set(BENEFACTOR_SETUP_UI_DEFAULT "${candidate}")
        break()
    endif()
endforeach()
if(ANDROID)
    # The Android dependency prefix ships FreeType for the shared SDL3
    # prefix; hand its paths to RmlUi's dependency probe.
    set(FREETYPE_DIR "${BENEFACTOR_SDL3_PREFIX}/lib/cmake/freetype" CACHE PATH "" FORCE)
    list(APPEND CMAKE_PREFIX_PATH "${BENEFACTOR_SDL3_PREFIX}")
endif()
set(BENEFACTOR_SETUP_UI_DIR "${BENEFACTOR_SETUP_UI_DEFAULT}"
    CACHE PATH "Path to the setup-ui library")
if("${BENEFACTOR_SETUP_UI_DIR}" STREQUAL "")
    # A configure that ran before the checkout existed cached an empty path.
    # Re-resolve it, so checking the tree out is enough to recover.
    set(BENEFACTOR_SETUP_UI_DIR "${BENEFACTOR_SETUP_UI_DEFAULT}"
        CACHE PATH "Path to the setup-ui library" FORCE)
endif()
# An empty path resolves to this source directory, which is a directory, so it
# would pass the check below and add Benefactor to itself as a subdirectory.
# That reports duplicate binary directories and targets instead of the miss.
if("${BENEFACTOR_SETUP_UI_DIR}" STREQUAL "")
    message(FATAL_ERROR
        "Benefactor requires shared/setup-ui; tried "
        "${BENEFACTOR_SETUP_UI_CANDIDATES}. "
        "Run ./run.sh, which checks the pinned shared trees out, or provide "
        "-DBENEFACTOR_SETUP_UI_DIR=<checkout> (and set SETUP_UI_RMLUI_DIR to "
        "an RmlUi checkout).")
endif()
get_filename_component(BENEFACTOR_SETUP_UI_DIR "${BENEFACTOR_SETUP_UI_DIR}"
    ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
if(NOT IS_DIRECTORY "${BENEFACTOR_SETUP_UI_DIR}")
    message(FATAL_ERROR
        "Benefactor requires shared/setup-ui; tried "
        "${BENEFACTOR_SETUP_UI_CANDIDATES}. "
        "Run ./run.sh, which checks the pinned shared trees out, or provide "
        "-DBENEFACTOR_SETUP_UI_DIR=<checkout> (and set SETUP_UI_RMLUI_DIR to "
        "an RmlUi checkout).")
endif()
set(SETUP_UI_LUCENT_DIR "${BENEFACTOR_LUCENT_DIR}" CACHE PATH "" FORCE)
add_subdirectory("${BENEFACTOR_SETUP_UI_DIR}" "${CMAKE_BINARY_DIR}/setup-ui")


# touch-ui — the shared on-screen controls. The Android product is the only one
# that ships them today, so nothing else carries the dependency.
if(ANDROID)
    set(BENEFACTOR_TOUCH_UI_CANDIDATES
        "$ENV{BENEFACTOR_TOUCH_UI_DIR}"
        "${CMAKE_CURRENT_SOURCE_DIR}/../shared/touch-ui"
        "${CMAKE_CURRENT_SOURCE_DIR}/shared/touch-ui")
    set(BENEFACTOR_TOUCH_UI_DIR "")
    foreach(candidate IN LISTS BENEFACTOR_TOUCH_UI_CANDIDATES)
        if(NOT "${candidate}" STREQUAL "" AND IS_DIRECTORY "${candidate}")
            set(BENEFACTOR_TOUCH_UI_DIR "${candidate}")
            break()
        endif()
    endforeach()
    if(NOT IS_DIRECTORY "${BENEFACTOR_TOUCH_UI_DIR}")
        message(FATAL_ERROR
            "Benefactor requires shared/touch-ui for the Android product; tried "
            "${BENEFACTOR_TOUCH_UI_CANDIDATES}. Provide -DBENEFACTOR_TOUCH_UI_DIR=<checkout>.")
    endif()
    set(TOUCH_UI_LUCENT_DIR "${BENEFACTOR_LUCENT_DIR}" CACHE PATH "" FORCE)
    add_subdirectory("${BENEFACTOR_TOUCH_UI_DIR}" "${CMAKE_BINARY_DIR}/touch-ui")
endif()

find_package(Threads REQUIRED)

set(BENEFACTOR_SOURCES
    src/main.c
    src/common/log.c
    src/engine/disk_boot.c
    src/engine/gameplay_handoff.c
    src/engine/frame_pacer.cpp
    src/engine/frame_pacer_sdl.cpp
    src/engine/hw.c
    src/engine/hw_beam.c
    src/engine/hw_audio.c
    src/engine/hw_blitter.c
    src/engine/hw_testrun.c
    src/common/version.c
    src/engine/hw_watchdog.c
    src/engine/overlay_load.c
    src/port/config.c
    src/port/crash_report.c
    src/port/freecam.c
    src/port/frame_accounting.cpp
    src/port/frame_signature.c
    src/port/lockstep.c
    src/port/state_dump.c
    src/port/guest_profile.cpp
    src/port/game_loop.c
    src/port/savestate.c
    src/port/update_check.cpp
    src/platform/update_transport.cpp
    src/port/guest_vectors.c
    src/port/level_layout.c
    src/port/guest_trace.c
    src/port/control/control_server.cpp
    src/port/control/input_script.cpp
    src/port/debug/debugger.cpp
    src/port/hud_icons.c
    src/port/input.c
    src/port/level_select_ui.c
    src/port/overrides/audio.c
    src/port/overrides/boot.c
    src/port/overrides/copper.c
    src/port/overrides/gameplay.c
    src/port/overrides/level_load.c
    src/port/overrides/hw.c
    src/port/overrides/pickup.c
    src/port/overrides/platformer.c
    src/port/overrides/register.c
    src/port/overrides/wait_idioms.c
    src/port/overrides/render.c
    src/port/pause_menu.c
    src/port/pause_menu_draw.c
    src/port/profile.c
    src/port/project_paths.c
    src/render/engine_view.c
    src/render/native_effects.c
    src/render/native_renderer.c
    src/render/present_sdl.c
    src/render/scene.c
    src/render/scene_sdl.c
    src/runtime/guest_call_policy.cpp
    src/runtime/guest_runtime.cpp)

if(NOT ANDROID AND NOT BENEFACTOR_WEB)
    list(APPEND BENEFACTOR_SOURCES
        src/platform/desktop_setup.cpp
        src/platform/disk_identity.cpp
        src/platform/disk_selection_store.cpp
        src/platform/setup_flow.cpp
        src/platform/staged_disks.cpp)
endif()

if(BENEFACTOR_WEB)
    list(REMOVE_ITEM BENEFACTOR_SOURCES src/main.c)
    list(APPEND BENEFACTOR_SOURCES
        src/platform/disk_identity.cpp
        src/platform/disk_selection_store.cpp
        src/platform/selection_report.cpp
        src/platform/setup_flow.cpp
        src/platform/staged_disks.cpp
        src/platform/web_setup.cpp
        src/platform/web_update.cpp)
endif()

if(BENEFACTOR_WEB)
    add_executable(benefactor_web ${BENEFACTOR_SOURCES})
    set_target_properties(benefactor_web PROPERTIES OUTPUT_NAME benefactor)
elseif(ANDROID)
    list(APPEND BENEFACTOR_SOURCES
        src/platform/android_setup.cpp
        src/platform/disk_identity.cpp
        src/platform/disk_selection_store.cpp
        src/platform/selection_report.cpp
        src/platform/setup_flow.cpp
        src/platform/staged_disks.cpp
        src/port/touch_controls.cpp
        src/platform/android_update.cpp)
    add_library(benefactor-pc SHARED ${BENEFACTOR_SOURCES})
    set_target_properties(benefactor-pc PROPERTIES OUTPUT_NAME main)
else()
    add_executable(benefactor-pc ${BENEFACTOR_SOURCES})
    if(APPLE)
        set_target_properties(benefactor-pc PROPERTIES
            MACOSX_BUNDLE TRUE
            MACOSX_BUNDLE_ICON_FILE Benefactor.icns
            OUTPUT_NAME Benefactor)
        # A bundle shows the icon named by CFBundleIconFile, and only if the file
        # is actually inside Resources; both halves are needed.
        target_sources(benefactor-pc PRIVATE platforms/macos/Benefactor.icns)
        set_source_files_properties(platforms/macos/Benefactor.icns PROPERTIES
            MACOSX_PACKAGE_LOCATION Resources)
    endif()
    if(WIN32)
        # The icon a Windows build carries is an executable resource, compiled
        # from the .rc the icon tool writes beside the .ico it names — which is
        # why that directory, and only the resource, needs to be on windres'
        # include path.
        enable_language(RC)
        set_source_files_properties(platforms/windows/benefactor.rc PROPERTIES
            INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/platforms/windows)
        target_sources(benefactor-pc PRIVATE platforms/windows/benefactor.rc)
    endif()
endif()

if(BENEFACTOR_WEB)
    set(BENEFACTOR_PRODUCT_TARGET benefactor_web)
else()
    set(BENEFACTOR_PRODUCT_TARGET benefactor-pc)
endif()

target_include_directories(${BENEFACTOR_PRODUCT_TARGET} PRIVATE src)
target_compile_definitions(${BENEFACTOR_PRODUCT_TARGET} PRIVATE
    BENEFACTOR_VERSION="${BENEFACTOR_VERSION}")
target_link_libraries(${BENEFACTOR_PRODUCT_TARGET} PRIVATE
    amigaport::amigaport
    lucent::lucent
    ${BENEFACTOR_SDL_TARGET}
    Threads::Threads)
# Every product shows the shared setup screen and accepts a ZIP install archive
# through the same validator, the browser included.
target_link_libraries(${BENEFACTOR_PRODUCT_TARGET} PRIVATE setup_ui::setup_ui lucent::zip)
if(NOT WIN32 AND NOT BENEFACTOR_WEB)
    target_link_libraries(${BENEFACTOR_PRODUCT_TARGET} PRIVATE m)
endif()
if(WIN32)
    # ws2_32 for the socket helpers, winhttp for the platform's own HTTP client.
    target_link_libraries(${BENEFACTOR_PRODUCT_TARGET} PRIVATE ws2_32 winhttp)
    # The Windows HTTP transport is the one owner no other host's build can
    # exercise, so it ships with a runnable check for this platform's CI to run
    # natively. It is not part of the package.
    add_executable(benefactor-winhttp-transport
        tests/winhttp_transport.cpp
        src/common/log.c
        src/platform/winhttp_update.cpp
        src/port/update_check.cpp)
    target_include_directories(benefactor-winhttp-transport PRIVATE src)
    target_compile_definitions(benefactor-winhttp-transport PRIVATE
        BENEFACTOR_VERSION="${BENEFACTOR_VERSION}")
    target_link_libraries(benefactor-winhttp-transport PRIVATE lucent::lucent winhttp)
    if(MINGW)
        target_link_options(benefactor-winhttp-transport PRIVATE -static)
    endif()
endif()
if(MINGW)
    # The Windows ZIP ships one executable, without a MinGW runtime prefix.
    target_link_options(${BENEFACTOR_PRODUCT_TARGET} PRIVATE -static)
endif()
if(ANDROID)
    target_link_libraries(benefactor-pc PRIVATE touch_ui::touch_ui android log)
    target_compile_definitions(benefactor-pc PRIVATE BENEFACTOR_ANDROID)
endif()
if(BENEFACTOR_WEB)
    # The setup screen draws real text, and the browser has no system font: the
    # face is embedded in the module's own filesystem.
    set(BENEFACTOR_WEB_FONT
        "${CMAKE_CURRENT_SOURCE_DIR}/platforms/web/fonts/LiberationSans-Regular.ttf")
    if(NOT EXISTS "${BENEFACTOR_WEB_FONT}")
        message(FATAL_ERROR "the browser product needs its setup font at ${BENEFACTOR_WEB_FONT}")
    endif()
    # Embedded, not preloaded: the package stays the two files the browser
    # deployment publishes, with no separate data file to fetch and cache.
    target_link_options(benefactor_web PRIVATE
        "--embed-file=${BENEFACTOR_WEB_FONT}@/setup-font.ttf")
    target_compile_definitions(benefactor_web PRIVATE BENEFACTOR_WEB)
    target_link_options(benefactor_web PRIVATE
        -pthread
        "-sPTHREAD_POOL_SIZE=1"
        "-sALLOW_MEMORY_GROWTH=1"
        "-sNO_EXIT_RUNTIME=1"
        "-sENVIRONMENT=web,worker"
        "-sEXPORTED_FUNCTIONS=['_main','_benefactor_web_pick_begin','_benefactor_web_pick_add','_benefactor_web_pick_end','_benefactor_web_update_result']"
        "-sEXPORTED_RUNTIME_METHODS=['ccall','FS']")
elseif(NOT MSVC)
    target_compile_options(${BENEFACTOR_PRODUCT_TARGET} PRIVATE -Wall -Wextra)
endif()

if(NOT ANDROID AND NOT BENEFACTOR_WEB)
    # The desktop update check uses the host's own HTTP client. Windows uses
    # WinHTTP, so its package stays one executable with nothing to bundle;
    # elsewhere it is libcurl when the platform provides one, and a build without
    # it reports that the check could not run rather than claiming this build is
    # current.
    if(WIN32)
        target_sources(${BENEFACTOR_PRODUCT_TARGET} PRIVATE src/platform/winhttp_update.cpp)
    else()
        target_sources(${BENEFACTOR_PRODUCT_TARGET} PRIVATE src/platform/curl_update.cpp)
        find_package(CURL QUIET)
        if(CURL_FOUND)
            target_compile_definitions(${BENEFACTOR_PRODUCT_TARGET} PRIVATE BENEFACTOR_HAVE_CURL=1)
            target_link_libraries(${BENEFACTOR_PRODUCT_TARGET} PRIVATE CURL::libcurl)
        endif()
    endif()
endif()

if(NOT ANDROID AND NOT BENEFACTOR_WEB)
    include(GNUInstallDirs)
    install(TARGETS benefactor-pc
        BUNDLE DESTINATION .
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
    install(FILES platforms/freedesktop/io.github.SomeoneIsWorking.benefactor.desktop
        DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
    install(FILES platforms/icons/benefactor.svg
        DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps
        RENAME io.github.SomeoneIsWorking.benefactor.svg)
endif()

add_custom_target(benefactor_product DEPENDS ${BENEFACTOR_PRODUCT_TARGET})

enable_testing()
find_program(BENEFACTOR_UV_EXECUTABLE uv)
if(BENEFACTOR_UV_EXECUTABLE)
    add_test(
        NAME benefactor_source_policy
        COMMAND "${BENEFACTOR_UV_EXECUTABLE}" run --frozen python -m tools.verify)
    set_tests_properties(benefactor_source_policy PROPERTIES
        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
