cmake_minimum_required(VERSION 3.25.1)

set(CMAKE_CXX_STANDARD 23)

set(PROJECT_EXECUTABLE_NAME open_engine)

project(OpenEngine
    VERSION 0.0.1
)

add_definitions( -DOE_ENABLE_ASSERTS )

find_package(imgui REQUIRED)
find_package(EnTT REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(Jolt REQUIRED)
find_package(fastgltf REQUIRED)
find_package(spdlog REQUIRED)
find_package(glm REQUIRED)
find_package(glfw3 REQUIRED)
find_package(shaderc REQUIRED)
find_package(spirv-cross REQUIRED)

file(GLOB_RECURSE SRC_FILES "src/*.cpp")
file(GLOB IMGUIZMO_SRC_FILES "${CMAKE_SOURCE_DIR}/vendor/ImGuizmo/*.cpp")
add_library(${PROJECT_EXECUTABLE_NAME} STATIC
    ${SRC_FILES}
    "vendor/stb_image/stb_image.cpp"
    ${IMGUIZMO_SRC_FILES}
)

target_precompile_headers(${PROJECT_EXECUTABLE_NAME} PRIVATE
    include/open_engine/pch.hpp
)

target_include_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
    "${CMAKE_CURRENT_SOURCE_DIR}/include/open_engine"
    "${CMAKE_CURRENT_SOURCE_DIR}/vendor/stb_image"
)

target_include_directories(${PROJECT_EXECUTABLE_NAME} PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/include"
    #"/home/erris/.conan2/p/b/imguic69fe98538919/p/include"
    "vendor/nativefiledialog-extended/src/include"
    "${CMAKE_SOURCE_DIR}/vendor/ImGuizmo"
)

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
#set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")

target_link_libraries(${PROJECT_EXECUTABLE_NAME} PUBLIC
    imgui::imgui
    spdlog::spdlog
    glad
    glfw
    glm::glm
    dl
    EnTT::EnTT
    X11
    yaml-cpp::yaml-cpp
    nfd
    shaderc::shaderc
    glslang
    glslang-default-resource-limits
    SPIRV
    SPIRV-Tools
    SPIRV-Tools-opt
    spirv-cross-core
    spirv-cross-glsl
    spirv-cross-reflect
    Jolt::Jolt
    fastgltf::fastgltf
)

#target_link_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
#    ${PROJECT_SOURCE_DIR}/lib
#)

add_subdirectory(vendor/glad
    ./glad
)

add_subdirectory("vendor/nativefiledialog-extended")

target_compile_options(open_engine PRIVATE -msse4.1 -msse4.2 -mavx -mavx2)
