cmake_minimum_required(VERSION 3.20)
project(GeocachingCoreTests LANGUAGES C CXX)
include_directories(../../core_gps/include ../../core_sys/include)
add_library(geocaching_lxmf_wire_compile OBJECT ../../core_chat/src/infra/lxmf/lxmf_wire.cpp)
target_include_directories(geocaching_lxmf_wire_compile PRIVATE ../../core_chat/include)
target_compile_features(geocaching_lxmf_wire_compile PRIVATE cxx_std_17)
enable_testing()
add_executable(geocaching_publication_operation_filter_test test_publication_operation_filter.cpp)
target_include_directories(geocaching_publication_operation_filter_test PRIVATE ../include)
target_compile_features(geocaching_publication_operation_filter_test PRIVATE cxx_std_17)
if(MSVC)
    target_compile_options(geocaching_publication_operation_filter_test PRIVATE /UNDEBUG)
else()
    target_compile_options(geocaching_publication_operation_filter_test PRIVATE -UNDEBUG)
endif()
add_test(NAME geocaching_publication_operation_filter COMMAND geocaching_publication_operation_filter_test)
set(LVGL_RUNTIME "${CMAKE_CURRENT_SOURCE_DIR}/../../../platform/esp/arduino_common/src/LV_Helper_v9.cpp")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${LVGL_RUNTIME}")
file(READ "${LVGL_RUNTIME}" LVGL_RUNTIME_TEXT)
string(FIND "${LVGL_RUNTIME_TEXT}" "extern \"C\" void* lv_malloc_core(" ALLOCATOR_BEGIN)
string(FIND "${LVGL_RUNTIME_TEXT}" "extern \"C\" void lv_mem_monitor_core(" ALLOCATOR_END)
math(EXPR ALLOCATOR_LENGTH "${ALLOCATOR_END} - ${ALLOCATOR_BEGIN}")
string(SUBSTRING "${LVGL_RUNTIME_TEXT}" ${ALLOCATOR_BEGIN} ${ALLOCATOR_LENGTH} ALLOCATOR_TEXT)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/geocaching_lvgl_allocator.inc" "${ALLOCATOR_TEXT}")
add_executable(geocaching_psram_ownership_test test_psram_ownership.cpp)
target_include_directories(geocaching_psram_ownership_test PRIVATE memory_fakes "${CMAKE_CURRENT_BINARY_DIR}")
target_compile_features(geocaching_psram_ownership_test PRIVATE cxx_std_17)
target_compile_definitions(geocaching_psram_ownership_test PRIVATE ESP_PLATFORM=1 HAS_PSRAM=1)
if(MSVC)
    target_compile_options(geocaching_psram_ownership_test PRIVATE /UNDEBUG)
else()
    target_compile_options(geocaching_psram_ownership_test PRIVATE -UNDEBUG)
endif()
add_test(NAME geocaching_psram_ownership COMMAND geocaching_psram_ownership_test)
add_executable(geocaching_record_shape_test test_record_shape.cpp)
target_include_directories(geocaching_record_shape_test PRIVATE ../include ../../core_sys/include)
target_compile_features(geocaching_record_shape_test PRIVATE cxx_std_17)
add_test(NAME geocaching_record_shape COMMAND geocaching_record_shape_test)
add_executable(geocaching_index_cursor_test test_transaction_index_cursor.cpp)
target_include_directories(geocaching_index_cursor_test PRIVATE ../include ../../core_sys/include)
target_compile_features(geocaching_index_cursor_test PRIVATE cxx_std_17)
add_test(NAME geocaching_index_cursor COMMAND geocaching_index_cursor_test)
add_executable(geocaching_query_timeout_test test_query_timeout.cpp)
target_include_directories(geocaching_query_timeout_test PRIVATE ../include)
target_compile_features(geocaching_query_timeout_test PRIVATE cxx_std_17)
add_test(NAME geocaching_query_timeout COMMAND geocaching_query_timeout_test)
add_executable(geocaching_generated_state_test test_generated_state.cpp)
target_include_directories(geocaching_generated_state_test PRIVATE ../include)
target_compile_features(geocaching_generated_state_test PRIVATE cxx_std_17)
add_test(NAME geocaching_generated_state COMMAND geocaching_generated_state_test)
add_executable(geocaching_transaction_stream_test test_transaction_stream.cpp)
target_include_directories(geocaching_transaction_stream_test PRIVATE ../include)
target_compile_features(geocaching_transaction_stream_test PRIVATE cxx_std_17)
add_test(NAME geocaching_transaction_stream COMMAND geocaching_transaction_stream_test)
add_executable(geocaching_shared_track_test test_shared_track.cpp)
target_compile_features(geocaching_shared_track_test PRIVATE cxx_std_17)
add_test(NAME geocaching_shared_track COMMAND geocaching_shared_track_test)
add_executable(geocaching_track_options_test test_track_options.cpp)
target_compile_features(geocaching_track_options_test PRIVATE cxx_std_17)
add_test(NAME geocaching_track_options COMMAND geocaching_track_options_test)
add_executable(geocaching_track_motion_test test_track_motion.cpp)
target_compile_features(geocaching_track_motion_test PRIVATE cxx_std_17)
add_test(NAME geocaching_track_motion COMMAND geocaching_track_motion_test ${CMAKE_CURRENT_BINARY_DIR}/track-motion.gpx)
add_executable(geocaching_cmp_test test_cmp.cpp)
target_include_directories(geocaching_cmp_test PRIVATE ../include)
target_compile_features(geocaching_cmp_test PRIVATE cxx_std_17)
add_test(NAME geocaching_cmp COMMAND geocaching_cmp_test)
add_executable(geocaching_record_test test_record.cpp)
target_include_directories(geocaching_record_test PRIVATE ../include)
target_compile_features(geocaching_record_test PRIVATE cxx_std_17)
add_test(NAME geocaching_record COMMAND geocaching_record_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/record-v1.bin)
add_executable(geocaching_verify_test test_verify.cpp)
target_include_directories(geocaching_verify_test PRIVATE ../include)
target_compile_features(geocaching_verify_test PRIVATE cxx_std_17)
add_test(NAME geocaching_verify COMMAND geocaching_verify_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin)
set(ED25519_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../core_chat/src/infra/meshcore/crypto/ed25519)
add_executable(geocaching_verify_peer_capture verify_peer_capture.cpp $<TARGET_OBJECTS:geocaching_lxmf_wire_compile>
    ${ED25519_DIR}/verify.c ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
target_include_directories(geocaching_verify_peer_capture PRIVATE ../include)
target_link_libraries(geocaching_verify_peer_capture PRIVATE geocaching_native_hash)
target_compile_features(geocaching_verify_peer_capture PRIVATE cxx_std_17)
add_executable(geocaching_publish_attempt_test test_publish_attempt.cpp
    ${ED25519_DIR}/verify.c ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
target_include_directories(geocaching_publish_attempt_test PRIVATE ../include ../../core_chat/include)
target_link_libraries(geocaching_publish_attempt_test PRIVATE geocaching_native_hash)
target_compile_features(geocaching_publish_attempt_test PRIVATE cxx_std_17)
add_test(NAME geocaching_publish_attempt COMMAND geocaching_publish_attempt_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/publish-response-v1.bin)
add_executable(geocaching_publication_receipt_test test_publication_receipt.cpp
    ${ED25519_DIR}/verify.c ${ED25519_DIR}/sign.c ${ED25519_DIR}/keypair.c ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
target_include_directories(geocaching_publication_receipt_test PRIVATE ../include ../../core_chat/include)
target_link_libraries(geocaching_publication_receipt_test PRIVATE geocaching_native_hash)
target_compile_features(geocaching_publication_receipt_test PRIVATE cxx_std_17)
add_test(NAME geocaching_publication_receipt COMMAND geocaching_publication_receipt_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin)
add_executable(geocaching_record_signing_test test_record_signing.cpp
    ${ED25519_DIR}/sign.c ${ED25519_DIR}/keypair.c ${ED25519_DIR}/fe.c
    ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
target_include_directories(geocaching_record_signing_test PRIVATE ../include ../../core_chat/include)
target_compile_features(geocaching_record_signing_test PRIVATE cxx_std_17)
add_test(NAME geocaching_record_signing COMMAND geocaching_record_signing_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin)
add_executable(geocaching_ed25519_test test_ed25519.cpp
    ${ED25519_DIR}/verify.c ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c
    ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
target_include_directories(geocaching_ed25519_test PRIVATE ../include ../../core_chat/include)
target_compile_features(geocaching_ed25519_test PRIVATE cxx_std_17)
add_test(NAME geocaching_ed25519 COMMAND geocaching_ed25519_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin)
add_executable(geocaching_writer_test test_writer.cpp)
target_include_directories(geocaching_writer_test PRIVATE ../include)
target_compile_features(geocaching_writer_test PRIVATE cxx_std_17)
add_test(NAME geocaching_writer COMMAND geocaching_writer_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/get-v1.bin)
add_executable(geocaching_query_test test_query.cpp)
target_include_directories(geocaching_query_test PRIVATE ../include)
target_compile_features(geocaching_query_test PRIVATE cxx_std_17)
add_test(NAME geocaching_query COMMAND geocaching_query_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/capabilities-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/query-v1.bin)
add_executable(geocaching_capabilities_test test_capabilities.cpp)
target_include_directories(geocaching_capabilities_test PRIVATE ../include)
target_compile_features(geocaching_capabilities_test PRIVATE cxx_std_17)
add_test(NAME geocaching_capabilities COMMAND geocaching_capabilities_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/capabilities-response-v1.bin)
add_executable(geocaching_get_response_test test_get_response.cpp)
target_include_directories(geocaching_get_response_test PRIVATE ../include)
target_compile_features(geocaching_get_response_test PRIVATE cxx_std_17)
add_test(NAME geocaching_get_response COMMAND geocaching_get_response_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/get-response-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin)
add_executable(geocaching_query_response_test test_query_response.cpp)
target_include_directories(geocaching_query_response_test PRIVATE ../include)
target_compile_features(geocaching_query_response_test PRIVATE cxx_std_17)
add_test(NAME geocaching_query_response COMMAND geocaching_query_response_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/query-response-v1.bin)
add_executable(geocaching_discovery_test test_discovery.cpp)
target_include_directories(geocaching_discovery_test PRIVATE ../include)
target_compile_features(geocaching_discovery_test PRIVATE cxx_std_17)
add_test(NAME geocaching_discovery COMMAND geocaching_discovery_test)
add_executable(geocaching_publish_test test_publish.cpp)
target_include_directories(geocaching_publish_test PRIVATE ../include)
target_compile_features(geocaching_publish_test PRIVATE cxx_std_17)
add_test(NAME geocaching_publish COMMAND geocaching_publish_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/publish-v1.bin)
add_executable(geocaching_publish_response_test test_publish_response.cpp)
target_include_directories(geocaching_publish_response_test PRIVATE ../include)
target_compile_features(geocaching_publish_response_test PRIVATE cxx_std_17)
add_test(NAME geocaching_publish_response COMMAND geocaching_publish_response_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/publish-response-v1.bin)
add_executable(geocaching_request_tracker_test test_request_tracker.cpp)
target_include_directories(geocaching_request_tracker_test PRIVATE ../include)
target_compile_features(geocaching_request_tracker_test PRIVATE cxx_std_17)
add_test(NAME geocaching_request_tracker COMMAND geocaching_request_tracker_test)
add_executable(geocaching_gpx_text_test test_gpx_text.cpp)
target_include_directories(geocaching_gpx_text_test PRIVATE ../include)
target_compile_features(geocaching_gpx_text_test PRIVATE cxx_std_17)
add_test(NAME geocaching_gpx_text COMMAND geocaching_gpx_text_test)
add_executable(geocaching_buffered_test test_buffered.cpp)
target_include_directories(geocaching_buffered_test PRIVATE ../include)
target_compile_features(geocaching_buffered_test PRIVATE cxx_std_17)
add_test(NAME geocaching_buffered COMMAND geocaching_buffered_test)
add_executable(geocaching_gpx_record_test test_gpx_record.cpp)
target_include_directories(geocaching_gpx_record_test PRIVATE ../include)
target_compile_features(geocaching_gpx_record_test PRIVATE cxx_std_17)
add_test(NAME geocaching_gpx_record COMMAND geocaching_gpx_record_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/gpx-metadata.bin ${CMAKE_CURRENT_BINARY_DIR}/generated.gpx)
add_executable(geocaching_version_test test_version.cpp)
target_include_directories(geocaching_version_test PRIVATE ../include)
target_compile_features(geocaching_version_test PRIVATE cxx_std_17)
add_test(NAME geocaching_version COMMAND geocaching_version_test)
add_executable(geocaching_install_test test_install.cpp)
target_include_directories(geocaching_install_test PRIVATE ../include)
target_compile_features(geocaching_install_test PRIVATE cxx_std_17)
add_test(NAME geocaching_install COMMAND geocaching_install_test)
add_executable(geocaching_directory_pool_test test_directory_pool.cpp)
target_include_directories(geocaching_directory_pool_test PRIVATE ../include)
target_compile_features(geocaching_directory_pool_test PRIVATE cxx_std_17)
add_test(NAME geocaching_directory_pool COMMAND geocaching_directory_pool_test)
add_executable(geocaching_query_client_test test_query_client.cpp)
target_include_directories(geocaching_query_client_test PRIVATE ../include)
target_compile_features(geocaching_query_client_test PRIVATE cxx_std_17)
add_test(NAME geocaching_query_client COMMAND geocaching_query_client_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/capabilities-response-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/query-response-v1.bin)
add_executable(geocaching_paging_test test_paging.cpp)
target_include_directories(geocaching_paging_test PRIVATE ../include)
target_compile_features(geocaching_paging_test PRIVATE cxx_std_17)
add_test(NAME geocaching_paging COMMAND geocaching_paging_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/capabilities-response-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/query-page1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/query-page2.bin)
add_executable(geocaching_router_regression
    ../../core_chat/tests/test_mesh_adapter_router_core.cpp
    ../../core_chat/src/infra/mesh_adapter_router_core.cpp)
target_include_directories(geocaching_router_regression PRIVATE ../../core_chat/include ../../core_sys/include)
target_compile_features(geocaching_router_regression PRIVATE cxx_std_17)
add_test(NAME geocaching_router_regression COMMAND geocaching_router_regression)
add_executable(geocaching_service_backend_test test_service_backend.cpp ../../core_chat/src/infra/mesh_adapter_router_core.cpp)
target_include_directories(geocaching_service_backend_test PRIVATE ../../core_chat/include ../../core_sys/include)
target_compile_features(geocaching_service_backend_test PRIVATE cxx_std_17)
add_test(NAME geocaching_service_backend COMMAND geocaching_service_backend_test)
add_executable(geocaching_service_poll_test test_service_poll.cpp ../../core_chat/src/infra/mesh_adapter_router_core.cpp)
target_include_directories(geocaching_service_poll_test PRIVATE ../../core_chat/include ../../core_sys/include)
target_compile_features(geocaching_service_poll_test PRIVATE cxx_std_17)
add_test(NAME geocaching_service_poll COMMAND geocaching_service_poll_test)
add_executable(geocaching_service_ownership_test test_service_ownership.cpp ../../core_chat/src/infra/mesh_adapter_router_core.cpp)
target_include_directories(geocaching_service_ownership_test PRIVATE ../../core_chat/include ../../core_sys/include)
target_compile_features(geocaching_service_ownership_test PRIVATE cxx_std_17)
add_test(NAME geocaching_service_ownership COMMAND geocaching_service_ownership_test)
add_executable(gpx_attributes_test test_gpx_attributes.cpp)
add_executable(geocaching_transaction_validation_test test_transaction_validation.cpp)
target_include_directories(geocaching_transaction_validation_test PRIVATE ../include)
target_compile_features(geocaching_transaction_validation_test PRIVATE cxx_std_17)
add_test(NAME geocaching_transaction_validation COMMAND geocaching_transaction_validation_test)
add_executable(geocaching_record_read_budget_test test_record_read_budget.cpp)
target_include_directories(geocaching_record_read_budget_test PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_record_read_budget_test PRIVATE cxx_std_17)
add_test(NAME geocaching_record_read_budget COMMAND geocaching_record_read_budget_test)
add_executable(geocaching_attempt_timeout_test test_attempt_timeout.cpp)
target_include_directories(geocaching_attempt_timeout_test PRIVATE ../include)
target_compile_features(geocaching_attempt_timeout_test PRIVATE cxx_std_17)
add_test(NAME geocaching_attempt_timeout COMMAND geocaching_attempt_timeout_test)
add_executable(geocaching_tx_attempt_test test_tx_attempt.cpp)
target_include_directories(geocaching_tx_attempt_test PRIVATE ../include)
target_compile_features(geocaching_tx_attempt_test PRIVATE cxx_std_17)
add_test(NAME geocaching_tx_attempt COMMAND geocaching_tx_attempt_test)
add_executable(geocaching_pending_request_test test_pending_request.cpp)
target_include_directories(geocaching_pending_request_test PRIVATE ../include)
target_compile_features(geocaching_pending_request_test PRIVATE cxx_std_17)
add_test(NAME geocaching_pending_request COMMAND geocaching_pending_request_test)
add_executable(geocaching_author_issue_test test_author_issue.cpp)
target_include_directories(geocaching_author_issue_test PRIVATE ../include)
target_compile_features(geocaching_author_issue_test PRIVATE cxx_std_17)
add_test(NAME geocaching_author_issue COMMAND geocaching_author_issue_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin)
add_executable(geocaching_author_history_test test_author_history.cpp)
target_include_directories(geocaching_author_history_test PRIVATE ../include)
target_compile_features(geocaching_author_history_test PRIVATE cxx_std_17)
add_test(NAME geocaching_author_history COMMAND geocaching_author_history_test)
add_executable(geocaching_author_issued_test test_author_issued.cpp)
target_include_directories(geocaching_author_issued_test PRIVATE ../include)
target_compile_features(geocaching_author_issued_test PRIVATE cxx_std_17)
add_test(NAME geocaching_author_issued COMMAND geocaching_author_issued_test)
add_executable(geocaching_record_encoder_test test_record_encoder.cpp)
target_include_directories(geocaching_record_encoder_test PRIVATE ../include)
target_compile_features(geocaching_record_encoder_test PRIVATE cxx_std_17)
add_test(NAME geocaching_record_encoder COMMAND geocaching_record_encoder_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin)
add_executable(geocaching_gpx_hash_test test_gpx_hash.cpp)
target_include_directories(geocaching_gpx_hash_test PRIVATE ../include ../../../platform/esp/arduino_common/include)
target_link_libraries(geocaching_gpx_hash_test PRIVATE geocaching_native_hash)
target_compile_features(geocaching_gpx_hash_test PRIVATE cxx_std_17)
add_test(NAME geocaching_gpx_hash COMMAND geocaching_gpx_hash_test)
add_executable(geocaching_install_record_test test_install_record.cpp)
target_include_directories(geocaching_install_record_test PRIVATE ../include)
target_compile_features(geocaching_install_record_test PRIVATE cxx_std_17)
add_test(NAME geocaching_install_record COMMAND geocaching_install_record_test)
add_executable(geocaching_cache_head_test test_cache_head.cpp)
target_include_directories(geocaching_cache_head_test PRIVATE ../include)
target_compile_features(geocaching_cache_head_test PRIVATE cxx_std_17)
add_test(NAME geocaching_cache_head COMMAND geocaching_cache_head_test)
add_executable(geocaching_snapshot_state_test test_snapshot_state.cpp)
target_include_directories(geocaching_snapshot_state_test PRIVATE ../include)
target_compile_features(geocaching_snapshot_state_test PRIVATE cxx_std_17)
add_test(NAME geocaching_snapshot_state COMMAND geocaching_snapshot_state_test)
add_executable(geocaching_task_references_test test_task_references.cpp)
target_include_directories(geocaching_task_references_test PRIVATE ../include)
target_compile_features(geocaching_task_references_test PRIVATE cxx_std_17)
add_test(NAME geocaching_task_references COMMAND geocaching_task_references_test)
add_executable(geocaching_logical_state_test test_logical_state.cpp)
target_include_directories(geocaching_logical_state_test PRIVATE ../include)
target_compile_features(geocaching_logical_state_test PRIVATE cxx_std_17)
add_test(NAME geocaching_logical_state COMMAND geocaching_logical_state_test)
add_executable(geocaching_checkpoint_selection_test test_checkpoint_selection.cpp)
target_include_directories(geocaching_checkpoint_selection_test PRIVATE ../include)
target_compile_features(geocaching_checkpoint_selection_test PRIVATE cxx_std_17)
add_test(NAME geocaching_checkpoint_selection COMMAND geocaching_checkpoint_selection_test)
add_executable(geocaching_sd_checkpoint_test test_sd_checkpoint.cpp)
target_include_directories(geocaching_sd_checkpoint_test PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_link_libraries(geocaching_sd_checkpoint_test PRIVATE geocaching_native_hash)
target_compile_features(geocaching_sd_checkpoint_test PRIVATE cxx_std_17)
add_test(NAME geocaching_sd_checkpoint COMMAND geocaching_sd_checkpoint_test)
add_executable(geocaching_checkpoint_verifier_test test_checkpoint_verifier.cpp)
target_include_directories(geocaching_checkpoint_verifier_test PRIVATE ../include ../../core_sys/include)
target_link_libraries(geocaching_checkpoint_verifier_test PRIVATE geocaching_native_hash)
target_compile_features(geocaching_checkpoint_verifier_test PRIVATE cxx_std_17)
add_test(NAME geocaching_checkpoint_verifier COMMAND geocaching_checkpoint_verifier_test)
add_executable(geocaching_checkpoint_writer_test test_checkpoint_writer.cpp)
target_include_directories(geocaching_checkpoint_writer_test PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_link_libraries(geocaching_checkpoint_writer_test PRIVATE geocaching_native_hash)
target_compile_features(geocaching_checkpoint_writer_test PRIVATE cxx_std_17)
add_test(NAME geocaching_checkpoint_writer COMMAND geocaching_checkpoint_writer_test)
add_executable(geocaching_checkpoint_build_test test_checkpoint_build.cpp runtime_fakes/sd_runtime.cpp)
target_include_directories(geocaching_checkpoint_build_test BEFORE PRIVATE runtime_fakes fakes)
target_include_directories(geocaching_checkpoint_build_test PRIVATE ../include ../../core_sys/include ../../ui_presentation/include ../../../platform/esp/arduino_common/include)
target_link_libraries(geocaching_checkpoint_build_test PRIVATE geocaching_native_hash)
target_compile_features(geocaching_checkpoint_build_test PRIVATE cxx_std_17)
add_test(NAME geocaching_checkpoint_build COMMAND geocaching_checkpoint_build_test)
add_executable(geocaching_index_scan_history_test test_index_scan_history.cpp runtime_fakes/sd_runtime.cpp)
target_include_directories(geocaching_index_scan_history_test BEFORE PRIVATE runtime_fakes fakes)
target_include_directories(geocaching_index_scan_history_test PRIVATE ../include ../../core_sys/include ../../ui_presentation/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_index_scan_history_test PRIVATE cxx_std_17)
target_link_libraries(geocaching_index_scan_history_test PRIVATE geocaching_native_hash)
add_test(NAME geocaching_index_scan_history COMMAND geocaching_index_scan_history_test)
add_executable(geocaching_journal_reclaim_test test_journal_reclaim.cpp runtime_fakes/sd_runtime.cpp)
target_include_directories(geocaching_journal_reclaim_test BEFORE PRIVATE runtime_fakes fakes)
target_include_directories(geocaching_journal_reclaim_test PRIVATE ../include ../../core_sys/include ../../ui_presentation/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_journal_reclaim_test PRIVATE cxx_std_17)
target_link_libraries(geocaching_journal_reclaim_test PRIVATE geocaching_native_hash)
add_test(NAME geocaching_journal_reclaim COMMAND geocaching_journal_reclaim_test)
add_executable(geocaching_index_reference_proofs_test test_index_reference_proofs.cpp runtime_fakes/sd_runtime.cpp)
target_include_directories(geocaching_index_reference_proofs_test BEFORE PRIVATE runtime_fakes fakes)
target_include_directories(geocaching_index_reference_proofs_test PRIVATE ../include ../../core_sys/include ../../ui_presentation/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_index_reference_proofs_test PRIVATE cxx_std_17)
target_link_libraries(geocaching_index_reference_proofs_test PRIVATE geocaching_native_hash)
add_test(NAME geocaching_index_reference_proofs COMMAND geocaching_index_reference_proofs_test)
add_executable(geocaching_checkpoint_test test_checkpoint.cpp)
target_include_directories(geocaching_checkpoint_test PRIVATE ../include)
target_compile_features(geocaching_checkpoint_test PRIVATE cxx_std_17)
add_test(NAME geocaching_checkpoint COMMAND geocaching_checkpoint_test)
add_executable(geocaching_journal_segment_test test_journal_segment.cpp)
target_include_directories(geocaching_journal_segment_test PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_journal_segment_test PRIVATE cxx_std_17)
add_test(NAME geocaching_journal_segment COMMAND geocaching_journal_segment_test)
add_executable(geocaching_journal_inventory_test test_journal_inventory.cpp)
target_include_directories(geocaching_journal_inventory_test PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_journal_inventory_test PRIVATE cxx_std_17)
add_test(NAME geocaching_journal_inventory COMMAND geocaching_journal_inventory_test)
add_executable(geocaching_journal_replay_test test_journal_replay.cpp)
target_sources(geocaching_journal_replay_test PRIVATE ../../../platform/esp/arduino_common/src/geocaching/request_dispatcher.cpp)
target_include_directories(geocaching_journal_replay_test BEFORE PRIVATE fakes)
target_include_directories(geocaching_journal_replay_test PRIVATE ../include ../../core_sys/include ../../ui_presentation/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_journal_replay_test PRIVATE cxx_std_17)
target_link_libraries(geocaching_journal_replay_test PRIVATE geocaching_native_hash)
target_sources(geocaching_journal_replay_test PRIVATE ${ED25519_DIR}/verify.c ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
add_test(NAME geocaching_journal_replay COMMAND geocaching_journal_replay_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/get-response-v1.bin)
add_executable(geocaching_sd_volume_test test_sd_volume.cpp)
target_include_directories(geocaching_sd_volume_test PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_sd_volume_test PRIVATE cxx_std_17)
add_test(NAME geocaching_sd_volume COMMAND geocaching_sd_volume_test)
add_library(geocaching_sd_request_store_compile OBJECT compile_sd_request_store.cpp)
target_include_directories(geocaching_sd_request_store_compile PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_sd_request_store_compile PRIVATE cxx_std_17)
add_executable(geocaching_task_record_test test_task_record.cpp)
target_include_directories(geocaching_task_record_test PRIVATE ../include)
target_compile_features(geocaching_task_record_test PRIVATE cxx_std_17)
add_test(NAME geocaching_task_record COMMAND geocaching_task_record_test)
add_executable(geocaching_outgoing_record_test test_outgoing_record.cpp)
target_include_directories(geocaching_outgoing_record_test PRIVATE ../include)
target_compile_features(geocaching_outgoing_record_test PRIVATE cxx_std_17)
add_test(NAME geocaching_outgoing_record COMMAND geocaching_outgoing_record_test)
add_executable(geocaching_download_task_record_test test_download_task_record.cpp)
target_include_directories(geocaching_download_task_record_test PRIVATE ../include)
target_compile_features(geocaching_download_task_record_test PRIVATE cxx_std_17)
add_test(NAME geocaching_download_task_record COMMAND geocaching_download_task_record_test)
add_executable(geocaching_queued_request_test test_queued_request.cpp)
target_include_directories(geocaching_queued_request_test PRIVATE ../include)
target_compile_features(geocaching_queued_request_test PRIVATE cxx_std_17)
add_test(NAME geocaching_queued_request COMMAND geocaching_queued_request_test)
add_executable(geocaching_volume_format_test test_volume_format.cpp)
target_include_directories(geocaching_volume_format_test PRIVATE ../include ../../core_sys/include)
target_compile_features(geocaching_volume_format_test PRIVATE cxx_std_17)
add_test(NAME geocaching_volume_format COMMAND geocaching_volume_format_test)
add_library(geocaching_sd_journal_compile OBJECT compile_sd_journal.cpp)
add_executable(geocaching_journal_read_test test_journal_read.cpp)
target_include_directories(geocaching_journal_read_test PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_journal_read_test PRIVATE cxx_std_17)
add_test(NAME geocaching_journal_read COMMAND geocaching_journal_read_test)
add_executable(geocaching_sd_journal_test test_sd_journal.cpp)
target_sources(geocaching_sd_journal_test PRIVATE ../../../platform/esp/arduino_common/src/geocaching/request_dispatcher.cpp)
target_include_directories(geocaching_sd_journal_test BEFORE PRIVATE fakes)
target_include_directories(geocaching_sd_journal_test PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_sd_journal_test PRIVATE cxx_std_17)
target_link_libraries(geocaching_sd_journal_test PRIVATE geocaching_native_hash)
target_sources(geocaching_sd_journal_test PRIVATE ${ED25519_DIR}/verify.c ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
add_test(NAME geocaching_sd_journal COMMAND geocaching_sd_journal_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/publish-response-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/capabilities-response-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/query-response-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/get-response-v1.bin)
target_include_directories(geocaching_sd_journal_test PRIVATE ../../ui_presentation/include)
target_include_directories(geocaching_sd_journal_compile PRIVATE ../include ../../core_sys/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_sd_journal_compile PRIVATE cxx_std_17)
add_executable(geocaching_record_frame_test test_record_frame.cpp)
target_include_directories(geocaching_record_frame_test PRIVATE ../include ../../core_sys/include)
target_compile_features(geocaching_record_frame_test PRIVATE cxx_std_17)
add_test(NAME geocaching_record_frame COMMAND geocaching_record_frame_test)
add_executable(geocaching_crc_test test_crc.cpp)
target_include_directories(geocaching_crc_test PRIVATE ../../core_sys/include)
target_compile_features(geocaching_crc_test PRIVATE cxx_std_17)
add_test(NAME geocaching_crc COMMAND geocaching_crc_test)
add_executable(geocaching_transaction_test test_transaction.cpp)
target_include_directories(geocaching_transaction_test PRIVATE ../include)
target_compile_features(geocaching_transaction_test PRIVATE cxx_std_17)
add_test(NAME geocaching_transaction COMMAND geocaching_transaction_test)
add_executable(geocaching_transaction_decode_test test_transaction_decode.cpp)
target_include_directories(geocaching_transaction_decode_test PRIVATE ../include)
target_compile_features(geocaching_transaction_decode_test PRIVATE cxx_std_17)
add_test(NAME geocaching_transaction_decode COMMAND geocaching_transaction_decode_test)
add_library(geocaching_sd_stage_compile OBJECT compile_sd_gpx_stage.cpp)
add_executable(geocaching_sd_stage_test test_sd_stage.cpp)
target_include_directories(geocaching_sd_stage_test PRIVATE ../include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_sd_stage_test PRIVATE cxx_std_17)
add_test(NAME geocaching_sd_stage COMMAND geocaching_sd_stage_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin)
target_include_directories(geocaching_sd_stage_compile PRIVATE ../include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_sd_stage_compile PRIVATE cxx_std_17)
target_compile_features(gpx_attributes_test PRIVATE cxx_std_17)
add_test(NAME gpx_attributes COMMAND gpx_attributes_test)
add_library(geocaching_native_hash STATIC ../../core_chat/src/infra/reticulum/reticulum_wire.cpp)
target_include_directories(geocaching_native_hash PUBLIC ../../core_chat/include)
target_compile_definitions(geocaching_native_hash PRIVATE TRAIL_MATE_RETICULUM_HASH_ONLY=1)
target_compile_features(geocaching_native_hash PUBLIC cxx_std_17)

add_executable(geocaching_reticulum_wire_vectors
    ../../../tests/reticulum_conformance/test_reticulum_supported_subset_vectors.cpp
    $<TARGET_OBJECTS:geocaching_lxmf_wire_compile>
    ../../core_chat/src/infra/reticulum/lxst_telephony_wire.cpp
    ../../core_chat/src/infra/reticulum/lxst_call_state_machine.cpp)
target_link_libraries(geocaching_reticulum_wire_vectors PRIVATE geocaching_native_hash)
target_include_directories(geocaching_reticulum_wire_vectors PRIVATE ../../core_team/include)
if(MSVC)
    target_compile_options(geocaching_reticulum_wire_vectors PRIVATE /UNDEBUG)
else()
    target_compile_options(geocaching_reticulum_wire_vectors PRIVATE -UNDEBUG)
endif()
add_test(NAME geocaching_reticulum_wire_vectors COMMAND geocaching_reticulum_wire_vectors)
add_executable(geocaching_lxmf_custom_test test_lxmf_custom.cpp $<TARGET_OBJECTS:geocaching_lxmf_wire_compile>)
target_include_directories(geocaching_lxmf_custom_test PRIVATE ../include)
target_link_libraries(geocaching_lxmf_custom_test PRIVATE geocaching_native_hash)
add_test(NAME geocaching_lxmf_custom COMMAND geocaching_lxmf_custom_test)
add_executable(geocaching_discovery_admission_test test_discovery_admission.cpp)
target_include_directories(geocaching_discovery_admission_test PRIVATE ../../../platform/esp/arduino_common/include)
target_link_libraries(geocaching_discovery_admission_test PRIVATE geocaching_native_hash)
if(MSVC)
    target_compile_options(geocaching_discovery_admission_test PRIVATE /UNDEBUG)
else()
    target_compile_options(geocaching_discovery_admission_test PRIVATE -UNDEBUG)
endif()
add_test(NAME geocaching_discovery_admission COMMAND geocaching_discovery_admission_test)
add_executable(geocaching_custom_extract_test test_custom_extract.cpp $<TARGET_OBJECTS:geocaching_lxmf_wire_compile>)
target_link_libraries(geocaching_custom_extract_test PRIVATE geocaching_native_hash)
add_test(NAME geocaching_custom_extract COMMAND geocaching_custom_extract_test)
add_executable(geocaching_crypto_pipeline_test test_crypto_pipeline.cpp
    ${ED25519_DIR}/verify.c ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
target_include_directories(geocaching_crypto_pipeline_test PRIVATE ../include)
target_link_libraries(geocaching_crypto_pipeline_test PRIVATE geocaching_native_hash)
add_test(NAME geocaching_crypto_pipeline COMMAND geocaching_crypto_pipeline_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/signed-cache-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/identity-hashes.bin)
add_executable(geocaching_download_test test_download.cpp
    ${ED25519_DIR}/verify.c ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
target_include_directories(geocaching_download_test PRIVATE ../include)
target_link_libraries(geocaching_download_test PRIVATE geocaching_native_hash)
add_test(NAME geocaching_download COMMAND geocaching_download_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/query-response-v1.bin ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/get-response-v1.bin)

add_executable(geocaching_browse_runtime_test test_browse_runtime.cpp runtime_fakes/sd_runtime.cpp
    ../../../platform/esp/arduino_common/src/geocaching/browse_runtime.cpp
    ../../../platform/esp/arduino_common/src/geocaching/request_dispatcher.cpp
    ${ED25519_DIR}/verify.c ${ED25519_DIR}/sign.c ${ED25519_DIR}/keypair.c
    ${ED25519_DIR}/fe.c ${ED25519_DIR}/ge.c ${ED25519_DIR}/sc.c ${ED25519_DIR}/sha512.c)
set(RUNTIME_STORAGE_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../../../platform/esp/arduino_common/src/storage/storage_runtime.cpp")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${RUNTIME_STORAGE_SOURCE}")
file(READ "${RUNTIME_STORAGE_SOURCE}" RUNTIME_STORAGE_TEXT)
string(FIND "${RUNTIME_STORAGE_TEXT}" "class SdMaintenanceAdapter final" RUNTIME_ADAPTER_BEGIN)
string(FIND "${RUNTIME_STORAGE_TEXT}" "\nSdMaintenanceAdapter s_adapter" RUNTIME_ADAPTER_END)
if(RUNTIME_ADAPTER_BEGIN LESS 0 OR RUNTIME_ADAPTER_END LESS 0)
    message(FATAL_ERROR "Cannot locate production storage adapter for runtime acceptance")
endif()
math(EXPR RUNTIME_ADAPTER_LENGTH "${RUNTIME_ADAPTER_END} - ${RUNTIME_ADAPTER_BEGIN}")
string(SUBSTRING "${RUNTIME_STORAGE_TEXT}" ${RUNTIME_ADAPTER_BEGIN} ${RUNTIME_ADAPTER_LENGTH} RUNTIME_ADAPTER_TEXT)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/runtime_storage_adapter.inc" "${RUNTIME_ADAPTER_TEXT}")
target_include_directories(geocaching_browse_runtime_test BEFORE PRIVATE runtime_fakes fakes "${CMAKE_CURRENT_BINARY_DIR}")
target_include_directories(geocaching_browse_runtime_test PRIVATE ../../../platform/esp/common/include)
target_include_directories(geocaching_browse_runtime_test PRIVATE ../include ../../core_sys/include ../../ui_presentation/include ../../../platform/esp/arduino_common/include)
target_compile_features(geocaching_browse_runtime_test PRIVATE cxx_std_17)
target_compile_definitions(geocaching_browse_runtime_test PRIVATE ESP_PLATFORM=1)
target_link_libraries(geocaching_browse_runtime_test PRIVATE geocaching_native_hash)
add_test(NAME geocaching_browse_runtime COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures)
add_test(NAME geocaching_lazy_mutex COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures lazy-mutex)
add_test(NAME geocaching_web_draft_read COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures web-draft-read)
add_test(NAME geocaching_web_latest_revision COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures web-latest)
add_test(NAME geocaching_browse_runtime_close_detail COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures save-close-detail)
add_test(NAME geocaching_draft_only_map COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures local-draft-only)
add_test(NAME geocaching_legacy_index_upgrade COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures legacy-index-upgrade)
add_test(NAME geocaching_legacy_saved_projection COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures legacy-saved-projection)
add_test(NAME geocaching_legacy_saved_bad_signature COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures legacy-saved-bad-signature)
add_test(NAME geocaching_legacy_saved_projected_index COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures legacy-saved-projected-index)
add_test(NAME geocaching_legacy_saved_object_index COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures legacy-saved-object-index)
add_test(NAME geocaching_web_stop COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures web-stop)
add_test(NAME geocaching_web_signed_stop COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures web-signed-stop)
add_test(NAME geocaching_web_signature_restored COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures web-signature-restored)
add_test(NAME geocaching_web_signature_busy COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures web-signature-busy)
add_test(NAME geocaching_signature_input_recovery COMMAND geocaching_browse_runtime_test ${CMAKE_CURRENT_SOURCE_DIR}/fixtures signature-input-recovery)

add_executable(geocaching_local_map_test test_local_map_overlay.cpp)
set(GPS_RUNTIME "${CMAKE_CURRENT_SOURCE_DIR}/../../ui_shared/src/ui/screens/gps/gps_page_runtime.cpp")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${GPS_RUNTIME}")
file(READ "${GPS_RUNTIME}" GPS_RUNTIME_SOURCE)
string(FIND "${GPS_RUNTIME_SOURCE}" "void keep_only_current_position_overlay(" FILTER_START)
string(SUBSTRING "${GPS_RUNTIME_SOURCE}" ${FILTER_START} -1 FILTER_TAIL)
# Stop before the independent track-overlay cleanup helper; only the cache
# visibility filter belongs in this isolated compilation contract.
string(FIND "${FILTER_TAIL}" "void clear_map_track_overlay(" FILTER_LENGTH)
string(SUBSTRING "${FILTER_TAIL}" 0 ${FILTER_LENGTH} MAP_FILTER)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/geocaching_map_filter.inc" "${MAP_FILTER}")
target_include_directories(geocaching_local_map_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
target_include_directories(geocaching_local_map_test PRIVATE ../../ui_presentation/include)
target_compile_features(geocaching_local_map_test PRIVATE cxx_std_17)
if(MSVC)
    target_compile_options(geocaching_local_map_test PRIVATE /UNDEBUG)
else()
    target_compile_options(geocaching_local_map_test PRIVATE -UNDEBUG)
endif()
add_test(NAME geocaching_local_map COMMAND geocaching_local_map_test)

# These are ordinary user-mode tests. A 32-bit MinGW executable containing
# "install" in its name otherwise triggers Windows installer detection.
if(MINGW)
    enable_language(RC)
    target_sources(geocaching_install_test PRIVATE test_process.rc)
    target_sources(geocaching_install_record_test PRIVATE test_process.rc)
endif()
