# The game: the play session (rooms, exits, death), the title and the attract demos, all
# platform-independent; and the dgen executable around them (src/shell/).
add_library(dgen_app STATIC attract.cpp play_session.cpp)
target_include_directories(dgen_app PUBLIC ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(dgen_app PUBLIC dgen_assets)
dgen_set_warnings(dgen_app)

add_executable(dgen main.cpp)
target_link_libraries(dgen PRIVATE dgen_shell)
dgen_set_warnings(dgen)

# A released dgen runs from its folder with SDL3 beside it (packaging/): it finds libSDL3 there
# on Linux, and needs no compiler runtime installed on either system.
option(DGEN_STATIC_RUNTIME "Link the C++ runtime into dgen (for a release)" OFF)
if(WIN32)
    configure_file(windows/dgen.rc.in ${CMAKE_CURRENT_BINARY_DIR}/dgen.rc @ONLY)
    configure_file(windows/dgen.manifest ${CMAKE_CURRENT_BINARY_DIR}/dgen.manifest COPYONLY)
    target_sources(dgen PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/dgen.rc)
    # A windowed program: no console opens with it (problems are shown in a message box).
    set_target_properties(dgen PROPERTIES WIN32_EXECUTABLE ON)
    if(MINGW)
        target_link_options(dgen PRIVATE -static)
    endif()
else()
    set_target_properties(dgen PROPERTIES INSTALL_RPATH "$ORIGIN")
    if(DGEN_STATIC_RUNTIME)
        target_link_options(dgen PRIVATE -static-libstdc++ -static-libgcc)
    endif()
endif()
