cmake_minimum_required(VERSION 3.13)

project(FGGL VERSION 0.1 LANGUAGES CXX)

set(FGGL_WAYLAND True)

# Set C++ version
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Doxygen Support
# Based on https://vicrucann.github.io/tutorials/quick-cmake-doxygen/
option(BUILD_DOC "Build Documentation" ON)
find_package( Doxygen )
if (DOXYGEN_FOUND)
	# Set docs folder
	set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
	set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

	# configure file
	configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
	message("Doxygen build started")

	# note the option ALL which allows to build the docs together with the application
	add_custom_target( doc_doxygen ALL
		COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
		COMMENT "Generating API documentation with Doxygen"
		VERBATIM )
endif (DOXYGEN_FOUND)

# depedencies
find_package( glfw3 )
if ( NOT glfw3_FOUND )
  include(FetchContent)
  set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
  set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
  set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
  if ( FGGL_WAYLAND )
    set(GLFW_USE_WAYLAND True)
  endif ()
  FetchContent_Declare(
    glfw3
    URL https://github.com/glfw/glfw/releases/download/3.3.4/glfw-3.3.4.zip
  )
  FetchContent_MakeAvailable( glfw3 )
endif ()
add_subdirectory(vendor/imgui/)

# header-only vendored libraries
add_subdirectory(vendor/headers)

# engine
add_subdirectory(fggl)

# extras
add_subdirectory(tests)
add_subdirectory(demo)