cmake_minimum_required(VERSION 3.14)
project(window_chrome_tests LANGUAGES CXX)
set(PACKAGE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../..")
set(NATIVE_SOURCES "${PACKAGE_ROOT}/windows")
set(WRAPPER "${PACKAGE_ROOT}/../../windows/flutter/ephemeral/cpp_client_wrapper")
if(NOT EXISTS "${WRAPPER}/standard_codec.cc")
  message(FATAL_ERROR "Run flutter build windows once to prepare the Flutter wrapper")
endif()
add_executable(window_chrome_tests
  "window_chrome_tests.cpp" "${NATIVE_SOURCES}/window_chrome.cpp" "${WRAPPER}/standard_codec.cc"
  "${WRAPPER}/core_implementations.cc")
target_include_directories(window_chrome_tests PRIVATE "${NATIVE_SOURCES}" "${WRAPPER}/include" "${WRAPPER}/..")
target_compile_features(window_chrome_tests PRIVATE cxx_std_17)
target_compile_definitions(window_chrome_tests PRIVATE UNICODE _UNICODE NOMINMAX)
target_compile_options(window_chrome_tests PRIVATE /W4 /WX /wd4100 /EHsc)
target_link_libraries(window_chrome_tests PRIVATE dwmapi comctl32 "${WRAPPER}/../flutter_windows.dll.lib")
add_custom_command(TARGET window_chrome_tests POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E copy_if_different "${WRAPPER}/../flutter_windows.dll" "$<TARGET_FILE_DIR:window_chrome_tests>")
enable_testing()
add_test(NAME window_chrome COMMAND window_chrome_tests)
