cmake_minimum_required(VERSION 3.20)
project(TrailMateWaypoint LANGUAGES CXX)
add_library(trailmate_core_waypoint src/waypoint.cpp src/record_codec.cpp)
target_include_directories(trailmate_core_waypoint PUBLIC include)
target_compile_features(trailmate_core_waypoint PUBLIC cxx_std_17)
include(CTest)
if(BUILD_TESTING)
    add_executable(waypoint_test tests/test_waypoint.cpp)
    target_link_libraries(waypoint_test PRIVATE trailmate_core_waypoint)
    if(MSVC)
        target_compile_options(waypoint_test PRIVATE /UNDEBUG)
    else()
        target_compile_options(waypoint_test PRIVATE -UNDEBUG)
    endif()
    add_test(NAME waypoint_query COMMAND waypoint_test)
    add_executable(waypoint_codec_test tests/test_record_codec.cpp)
    target_link_libraries(waypoint_codec_test PRIVATE trailmate_core_waypoint)
    if(MSVC)
        target_compile_options(waypoint_codec_test PRIVATE /UNDEBUG)
    else()
        target_compile_options(waypoint_codec_test PRIVATE -UNDEBUG)
    endif()
    add_test(NAME waypoint_codec COMMAND waypoint_codec_test)
    add_executable(waypoint_file_test tests/test_file_store.cpp
        ../../platform/esp/common/src/storage/waypoint_file_store.cpp)
    target_include_directories(waypoint_file_test PRIVATE ../../platform/esp/common/include)
    target_link_libraries(waypoint_file_test PRIVATE trailmate_core_waypoint)
    if(MSVC)
        target_compile_options(waypoint_file_test PRIVATE /UNDEBUG)
    else()
        target_compile_options(waypoint_file_test PRIVATE -UNDEBUG)
    endif()
    add_test(NAME waypoint_file COMMAND waypoint_file_test)
    add_executable(waypoint_torn_test tests/test_torn_write.cpp
        ../../platform/esp/common/src/storage/waypoint_file_store.cpp)
    target_include_directories(waypoint_torn_test PRIVATE ../../platform/esp/common/include)
    target_link_libraries(waypoint_torn_test PRIVATE trailmate_core_waypoint)
    if(MSVC)
        target_compile_options(waypoint_torn_test PRIVATE /UNDEBUG)
    else()
        target_compile_options(waypoint_torn_test PRIVATE -UNDEBUG)
    endif()
    add_test(NAME waypoint_torn_write COMMAND waypoint_torn_test)
    add_executable(waypoint_presentation_test tests/test_presentation.cpp)
    target_include_directories(waypoint_presentation_test PRIVATE ../ui_presentation/include)
    target_link_libraries(waypoint_presentation_test PRIVATE trailmate_core_waypoint)
    if(MSVC)
        target_compile_options(waypoint_presentation_test PRIVATE /UNDEBUG)
    else()
        target_compile_options(waypoint_presentation_test PRIVATE -UNDEBUG)
    endif()
    add_test(NAME waypoint_presentation COMMAND waypoint_presentation_test)
    add_executable(agenda_waypoint_test tests/test_agenda_waypoint.cpp)
    target_include_directories(agenda_waypoint_test PRIVATE ../ui_presentation/include ../core_agenda/include)
    target_link_libraries(agenda_waypoint_test PRIVATE trailmate_core_waypoint)
    if(MSVC)
        target_compile_options(agenda_waypoint_test PRIVATE /UNDEBUG)
    else()
        target_compile_options(agenda_waypoint_test PRIVATE -UNDEBUG)
    endif()
    add_test(NAME agenda_waypoint_selection COMMAND agenda_waypoint_test)
endif()
