cmake_minimum_required(VERSION 3.28)

project(glerminal
  VERSION 0.1.0
  LANGUAGES C CXX
)

option(GLERMINAL_OPENGL_DEBUG_CONTEXT "" OFF)
option(GLERMINAL_TEST "" OFF)
set(GLERMINAL_GRID_WIDTH 40 CACHE STRING "")
set(GLERMINAL_GRID_HEIGHT 25 CACHE STRING "")
set(GLERMINAL_LAYER_COUNT 64 CACHE STRING "")
set(GLERMINAL_CELL_SCALE 4 CACHE STRING "")
set(GLERMINAL_CELL_SIZE 8 CACHE STRING "")

configure_file(source/glerminal-config.h.in glerminal-config.h @ONLY)

add_subdirectory(glfw)

add_library(glerminal STATIC
  ${CMAKE_CURRENT_BINARY_DIR}/glerminal-config.h
  include/glerminal.h

  source/stb_image.h
  source/glerminal-private.h
  source/glerminal.cpp

  source/glad/glad.h
  source/KHR/khrplatform.h
  source/glad.c

  source/miniaudio.h
  source/miniaudio.c
)

set_target_properties(glerminal
  PROPERTIES
    CXX_STANDARD 11
)

target_include_directories(glerminal
  PUBLIC
    include
    ${CMAKE_CURRENT_BINARY_DIR}
  PRIVATE
    source
)

target_link_libraries(glerminal
  PUBLIC
    glfw
)

target_compile_definitions(glerminal
  PUBLIC
    GLERMINAL_VERSION=${PROJECT_VERSION}
    GLERMINAL_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
    GLERMINAL_VERSION_MINOR=${PROJECT_VERSION_MINOR}
    GLERMINAL_VERSION_PATCH=${PROJECT_VERSION_PATCH}
)

if(PROJECT_IS_TOP_LEVEL)
  add_subdirectory(examples examples)
endif()

if(GLERMINAL_TEST)
  add_subdirectory(tests tests)
endif()
