cmake_minimum_required(VERSION 3.20)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
project(XML1DX8 LANGUAGES CXX)
add_executable(window-geometry-test ../tests/window_geometry_test.cpp)
target_compile_features(window-geometry-test PRIVATE cxx_std_17)
if(NOT WIN32 OR NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
    message(FATAL_ERROR "Build the genuine D3D8 renderer with -A Win32")
endif()
add_executable(xml1-dx8-worker dx8_worker.cpp)
target_compile_features(xml1-dx8-worker PRIVATE cxx_std_17)
target_include_directories(xml1-dx8-worker PRIVATE ../external/dx8-headers)
target_compile_definitions(xml1-dx8-worker PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS)
target_link_libraries(xml1-dx8-worker PRIVATE user32 gdi32 ole32 windowscodecs)
# Replacement textures need address space beyond 2 GiB in this 32-bit renderer.
target_link_options(xml1-dx8-worker PRIVATE /LARGEADDRESSAWARE)
add_library(xml1-pc-controls STATIC ../src/input/pc_controls.cpp ../src/input/pc_input_channel.cpp ../src/ui/pc_options_model.cpp)
target_sources(xml1-pc-controls PRIVATE ../src/input/pc_gamepad.cpp)
target_sources(xml1-pc-controls PRIVATE ../src/ui/pc_prompts.cpp)
target_sources(xml1-pc-controls PRIVATE ../src/ui/pc_native_options.cpp)
target_compile_features(xml1-pc-controls PUBLIC cxx_std_17)
target_compile_definitions(xml1-pc-controls PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
target_include_directories(xml1-pc-controls PUBLIC ../src)
target_link_libraries(xml1-dx8-worker PRIVATE xml1-pc-controls)
add_executable(pc-controls-test ../tests/input/pc_controls_test.cpp)
target_link_libraries(pc-controls-test PRIVATE xml1-pc-controls)
add_executable(dx8-readback-test ../tests/dx8_readback_test.cpp)
target_compile_features(dx8-readback-test PRIVATE cxx_std_17)
target_include_directories(dx8-readback-test PRIVATE ../external/dx8-headers)
target_compile_definitions(dx8-readback-test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
target_link_libraries(dx8-readback-test PRIVATE user32)

add_executable(pipe-ready-test ../tests/pipe_ready_test.cpp)
target_compile_features(pipe-ready-test PRIVATE cxx_std_17)
target_link_libraries(pipe-ready-test PRIVATE user32)
add_executable(native-vblank-test ../tests/native_vblank_test.cpp)
target_compile_features(native-vblank-test PRIVATE cxx_std_17)
target_compile_definitions(native-vblank-test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
target_link_libraries(native-vblank-test PRIVATE user32 gdi32)
add_executable(dx8-submission-test ../tests/dx8_submission_test.cpp)
target_compile_features(dx8-submission-test PRIVATE cxx_std_17)
target_include_directories(dx8-submission-test PRIVATE ../external/dx8-headers)
target_compile_definitions(dx8-submission-test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS)
target_link_libraries(dx8-submission-test PRIVATE xml1-pc-controls user32 gdi32 ole32 windowscodecs)

add_executable(performance-report-test ../tests/performance_report_test.cpp)
target_compile_features(performance-report-test PRIVATE cxx_std_17)
target_include_directories(performance-report-test PRIVATE ../external/dx8-headers)
target_compile_definitions(performance-report-test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS)

add_executable(texture-pack-test ../tests/texture_pack_test.cpp)
target_compile_features(texture-pack-test PRIVATE cxx_std_17)
target_include_directories(texture-pack-test PRIVATE ../external/dx8-headers)
target_compile_definitions(texture-pack-test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS)
target_link_libraries(texture-pack-test PRIVATE xml1-pc-controls user32 gdi32 ole32 windowscodecs)
