cmake_minimum_required(VERSION 3.28)
project(sfz2al_windows LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(TOOLKIT "${CMAKE_SOURCE_DIR}/work/cps2recomp")
find_package(SDL3 3.4 REQUIRED CONFIG)
if(NOT WIN32 OR NOT MSVC)
  message(FATAL_ERROR "The local launcher currently requires Windows and MSVC.")
endif()
add_compile_options(/utf-8 /W4)
add_compile_definitions(UNICODE _UNICODE NOMINMAX)
set(COMMON "${TOOLKIT}/recomp-common/settings.cpp")
enable_language(RC)
add_executable(SFZ2AL WIN32 src/windows/launcher_windows.cpp src/windows/launcher.rc "${COMMON}")
set_source_files_properties(src/windows/launcher.rc PROPERTIES COMPILE_FLAGS "/I\"${CMAKE_SOURCE_DIR}/src/windows\"")
target_include_directories(SFZ2AL PRIVATE "${TOOLKIT}/port")
target_link_libraries(SFZ2AL PRIVATE SDL3::SDL3 user32 gdi32 comdlg32 comctl32)
include(CTest)
if(BUILD_TESTING)
  add_executable(test_controls tests/test_controls.cpp "${COMMON}")
  target_include_directories(test_controls PRIVATE src/windows "${TOOLKIT}/port")
  target_link_libraries(test_controls PRIVATE SDL3::SDL3 user32)
  add_executable(test_themes tests/test_themes.cpp "${TOOLKIT}/port/present.cpp")
  target_include_directories(test_themes PRIVATE "${TOOLKIT}/port")
  target_link_libraries(test_themes PRIVATE SDL3::SDL3)
  target_compile_options(test_controls PRIVATE /UNDEBUG)
  target_compile_options(test_themes PRIVATE /UNDEBUG)
  add_executable(test_menu_audio tests/test_menu_audio.cpp)
  target_include_directories(test_menu_audio PRIVATE src/windows)
  target_compile_options(test_menu_audio PRIVATE /UNDEBUG)
  add_test(NAME menu_audio COMMAND test_menu_audio)
  add_executable(test_game_preview tests/test_game_preview.cpp)
  target_include_directories(test_game_preview PRIVATE src/windows "${TOOLKIT}/port")
  target_compile_options(test_game_preview PRIVATE /UNDEBUG)
  add_test(NAME game_preview COMMAND test_game_preview "${CMAKE_BINARY_DIR}/test-animation")
  add_test(NAME controls COMMAND test_controls "${CMAKE_BINARY_DIR}/test-profiles")
  add_test(NAME themes COMMAND test_themes "${CMAKE_BINARY_DIR}/test-previews")
endif()
