# Define the minimum CMAKE version required:
cmake_minimum_required(VERSION 3.10)

# Define the project:
project(Mandelbrot C CXX CUDA)

# Set C++ stardard:
set(CMAKE_CXX_STANDARD 11)

# Enable automatic include of generated files (like paths.h):
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Include IMGUI (which already includes GLFW):
add_subdirectory(lib/imgui-1.88/)

# Include GLAD for OpenGL 3.3 Core functionalities:
add_subdirectory(lib/glad)

# Define all header files we want to compile:
set(HEADERS
    src/CudaGLImage.h
    src/Mandelbrot.h
)

# Define all source files we want to compile:
set(SOURCES 
    src/main.cu

    src/Mandelbrot.cu
)

# Define shader & resources which should be listed in IDE:
set(RESOURCES
)

# Allow to include files directly in this paths
# (without the need to specify folders):
include_directories(src)

# Define executables with source files and resources:
add_executable(Mandelbrot ${SOURCES} ${HEADERS} ${RESOURCES})

set_target_properties(Mandelbrot PROPERTIES CUDA_SEPARABLE_COMPILATION ON)

# IMGUI specific compile definition:
target_compile_definitions(Mandelbrot PUBLIC -DCMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")

# Define the libraries to link against:
target_link_libraries(Mandelbrot PUBLIC imgui glad)

if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "13.0")
    set_property(TARGET ${name} PROPERTY CUDA_ARCHITECTURES 50 61 72 75)
else()
    set_property(TARGET ${name} PROPERTY CUDA_ARCHITECTURES 75)
endif()

