set(cdroot ${CMAKE_BINARY_DIR})

add_custom_command(OUTPUT ${cdroot}/${PROJECT_NAME}.exe
        COMMAND i386-mingw32-strip ${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}
            -o ${cdroot}/${PROJECT_NAME}.exe
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
        DEPENDS ${PROJECT_NAME}
        VERBATIM)
add_custom_target(stripped-exe ALL DEPENDS ${cdroot}/${PROJECT_NAME}.exe)

target_link_libraries(SDL::SDL INTERFACE gdi32 user32 winmm dxguid)
target_link_libraries(ENET INTERFACE wsock32)

add_compile_options(-march=i386)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    # i386-mingw32-gcc 3.4.5 does not support -Og.
    set(cflags ${cflags} -O0)
else()
    set(cflags ${cflags} -Os)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/fetch-libfixmath.cmake")
add_subdirectory(libfixmath)
