cmake_minimum_required(VERSION 3.15)
project(CreateEngine VERSION 1.0 LANGUAGES C CXX)

# --- Standards ---
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# --- Compiler flags ---
if(MSVC)
    add_compile_definitions(GLM_ENABLE_EXPERIMENTAL)
    add_compile_options(/W4 /Zi)
else()
    add_compile_definitions(GLM_ENABLE_EXPERIMENTAL)
    add_compile_options(-Wall -g)
    add_compile_options(-O2 -static -static-libstdc++ -static-libgcc)
endif()

# --- Include directories ---
include_directories(
        ${CMAKE_SOURCE_DIR}/src/include
        ${CMAKE_SOURCE_DIR}/src/include/lua
        ${CMAKE_SOURCE_DIR}/src/vendor
        ${CMAKE_SOURCE_DIR}/src/vendor/imgui
        ${CMAKE_SOURCE_DIR}/src/vendor/imguizmo
        ${CMAKE_SOURCE_DIR}/src/vendor/box2d
        ${CMAKE_SOURCE_DIR}/src/vendor/box2d/include
        ${CMAKE_SOURCE_DIR}/src/vendor/xxhash
        ${CMAKE_SOURCE_DIR}/src/vendor/miniaudio
)

# --- Gather source files ---
file(GLOB_RECURSE SOURCE_FILES
        ${CMAKE_SOURCE_DIR}/src/src/*.cpp
        ${CMAKE_SOURCE_DIR}/src/src/*.c
        ${CMAKE_SOURCE_DIR}/src/vendor/*.cpp
        ${CMAKE_SOURCE_DIR}/src/vendor/*.c
        ${CMAKE_SOURCE_DIR}/src/include/lua/*.c
)


# --- Define target ---
add_executable(${PROJECT_NAME} ${SOURCE_FILES})

# --- Link libraries ---
target_link_libraries(${PROJECT_NAME} PRIVATE
        glfw3
        glew32
        opengl32
        gdi32
        yaml-cpp
        comdlg32
        ssl
        crypto
        dbghelp
        z
        freetype
)

# --- Output dir ---
set_target_properties(${PROJECT_NAME} PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/src/build"
)
