cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_COMPILER icpx)
set(CMAKE_C_COMPILER icx)

project(polypartiCL LANGUAGES CXX)

if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_compile_options(-fsycl -fsycl-targets=spir64)
add_link_options(-fsycl -fsycl-targets=spir64)

find_package(raylib 6.0 QUIET)
if (NOT raylib_FOUND)
    include(FetchContent)
    FetchContent_Declare(
        raylib
        GIT_REPOSITORY https://github.com/raysan5/raylib.git
        GIT_TAG 5.5
    )
    set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
    set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
    FetchContent_MakeAvailable(raylib)
endif()

add_executable(${PROJECT_NAME}
    src/main.cpp
    src/polypartiCL.cpp
)

target_compile_options(polypartiCL PRIVATE $<$<CONFIG:Debug>:-g -O0 -fsanitize=address>
                                               $<$<CONFIG:Release>:-O3 -DNDEBUG>
                      )

target_link_options(polypartiCL PRIVATE $<$<CONFIG:Debug>:-fsanitize=address>)
target_include_directories(${PROJECT_NAME} PRIVATE
    ${CMAKE_SOURCE_DIR}/include
    ${CMAKE_SOURCE_DIR}/src
)

target_link_libraries(${PROJECT_NAME} PRIVATE raylib)

#find_package(IntelSYCL REQUIRED)

#file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/*.cpp")
#set(PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR/include/}")

#add_executable(${PROJECT_NAME}) 
#target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES})
#target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE})
#add_sycl_to_target(TARGET ${PROJECT_NAME} SOURCES polypartiCL.hpp)
#target_link_libraries(${PROJECT_NAME} PRIVATE raylib)


