cmake_minimum_required(VERSION 3.28 FATAL_ERROR)

include(SetupVulkan)
include(Utils)
include(CopyResourcesToExe)

file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/ExampleApps/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
if (IOS)
    file(GLOB_RECURSE SRC_IOS "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.m" "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.mm")
    list(APPEND SOURCES ${SRC_IOS})
endif ()
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})

set(MAIN_FILE main.cpp)
if (IOS)
    set(MAIN_FILE Host/iOS/main.mm)
endif ()
add_executable(OpenVulkano_Examples ${MAIN_FILE} ${SOURCES})
set_property(TARGET OpenVulkano_Examples PROPERTY CXX_STANDARD 20)

# Setup IOS
if(IOS)
    set(APP_BUNDLE_IDENTIFIER "eu.georgh93.openVulkano")
    set(MACOSX_BUNDLE_INFO_STRING ${APP_BUNDLE_IDENTIFIER})
    set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_BUNDLE_IDENTIFIER})
    set(MACOSX_BUNDLE_BUNDLE_NAME ${APP_BUNDLE_IDENTIFIER})
    set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})

    set(CMAKE_XCODE_EMBED_FRAMEWORKS ON)

    set_target_properties(OpenVulkano_Examples PROPERTIES XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "466MGSD624")
endif()
if(APPLE)
    LinkAppleFrameworks(OpenVulkano_Examples)
endif ()

CopyResourcesToExe(OpenVulkano_Examples "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" ".ttf")
CopyResourcesToExe(OpenVulkano_Examples "${CMAKE_CURRENT_SOURCE_DIR}/ExampleSources" "*")

target_include_directories(OpenVulkano_Examples PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(OpenVulkano_Examples PRIVATE openVulkanoCpp)

target_link_libraries(OpenVulkano_Examples PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,openVulkanoCpp>")
SetupVulkan(OpenVulkano_Examples)
SetGlmDefines(OpenVulkano_Examples)
SetWarningSettings(OpenVulkano_Examples)