cmake_minimum_required(VERSION 3.15)
project(Engine2026 LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(OpenGL REQUIRED)
find_package(glfw3 3.3 QUIET)

if(NOT glfw3_FOUND)
    message(STATUS "glfw3 not found via find_package")
    if(WIN32)
        set(GLFW_LIB "${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw/libglfw3.a")
    else()
        message(FATAL_ERROR "GLFW not found")
    endif()
endif()

add_executable(Engine2026
        main.cpp
        engine/shader.h
        engine/texture.h
        engine/mesh.h
        vendor/glad/glad.c
        engine/camera.h
)

target_include_directories(Engine2026 PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}/vendor
)

if(glfw3_FOUND)
    target_link_libraries(Engine2026 PRIVATE glfw OpenGL::GL)
else()
    target_link_libraries(Engine2026 PRIVATE
            ${GLFW_LIB}
            opengl32
            gdi32
            user32
    )
endif()

# Copy assets to build dir
add_custom_command(
        TARGET Engine2026 POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${CMAKE_CURRENT_SOURCE_DIR}/assets
        $<TARGET_FILE_DIR:Engine2026>/assets
        COMMENT "Copying assets to output directory"
)