# SPDX-License-Identifier: Apache-2.0
wirelink_wlc_generate_codec(TARGET calculator_codec SCHEMA "${CMAKE_CURRENT_SOURCE_DIR}/calculator.wl")
wirelink_wlc_generate_runtime(TARGET calculator_protocol CODEC_TARGET calculator_codec
  PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/calculator.bind.wl")
foreach(role client client_async server server_deferred)
  add_executable(calculator_${role} ${role}.c)
  target_link_libraries(calculator_${role} PRIVATE calculator_protocol wirelink_tutorial_host)
endforeach()
if(TARGET Wirelink::storage AND BUILD_TESTING)
  add_subdirectory(../../tests/endpoint_storage ${CMAKE_CURRENT_BINARY_DIR}/endpoint_storage)
endif()
if(TARGET Wirelink::host AND BUILD_TESTING)
  add_executable(wirelink_rpc_executor_tests ../../runtime/host/tests/rpc_endpoint.cpp)
  target_link_libraries(wirelink_rpc_executor_tests PRIVATE calculator_protocol Wirelink::host Wirelink::asio_udp)
  target_include_directories(wirelink_rpc_executor_tests PRIVATE ${WIRELINK_ASIO_INCLUDE_DIR})
  target_compile_definitions(wirelink_rpc_executor_tests PRIVATE ASIO_STANDALONE)
  add_test(NAME wirelink_rpc_executor COMMAND wirelink_rpc_executor_tests)
  set_tests_properties(wirelink_rpc_executor PROPERTIES TIMEOUT 30)
endif()
