cmake_minimum_required(VERSION 3.28)
project(Prog3B)

set(EXECUTABLE_NAME Prog3B)

# -------------------------------------------------
# Global settings
# -------------------------------------------------
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# -------------------------------------------------
# Main executable
# -------------------------------------------------
set(SRC_FILES
        src/main.cpp
        src/gamecube.cpp
        src/gamematrix.cpp
)

add_executable(${EXECUTABLE_NAME} ${SRC_FILES})

target_include_directories(${EXECUTABLE_NAME} PRIVATE
        ${CMAKE_CURRENT_LIST_DIR}/includes
        ${CMAKE_CURRENT_LIST_DIR}/raylib
)

# -------------------------------------------------
# Tests executable
# -------------------------------------------------
set(TEST_FILES
        src/gamematrix.cpp
)

add_executable(tests ${TEST_FILES})

target_include_directories(tests PRIVATE
        ${CMAKE_CURRENT_LIST_DIR}/includes
)

# -------------------------------------------------
# Platform specific linking
# -------------------------------------------------
if (WIN32)

    message(STATUS "Configuring for Windows")

    target_link_libraries(${EXECUTABLE_NAME} PRIVATE
            ${CMAKE_CURRENT_LIST_DIR}/windows/libraylib.a
            opengl32
            gdi32
            winmm
    )

elseif (APPLE)

    message(STATUS "Configuring for macOS")

    target_link_libraries(${EXECUTABLE_NAME} PRIVATE
            ${CMAKE_CURRENT_LIST_DIR}/mac_x86/libraylib.a
            "-framework Cocoa"
            "-framework OpenGL"
            "-framework IOKit"
    )

else ()

    message(STATUS "Configuring for Linux")

    target_link_libraries(${EXECUTABLE_NAME} PRIVATE
            ${CMAKE_CURRENT_LIST_DIR}/linux/libraylib.a
            GL
            X11
            m
            pthread
            dl
    )

    target_link_libraries(tests PRIVATE
            m
    )

endif ()
