cmake_minimum_required(VERSION 3.20)
project(HammerPP VERSION 0.1.0 DESCRIPTION "Hammer++ map editor" LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()

option(HPP_BUILD_EDITOR "Build the Hammer++ editor (raylib + Dear ImGui + rlImGui)" ON)
option(HPP_BUILD_VIEWER "Build the minimal raylib example viewer"                    ON)
option(HPP_BUILD_TOOLS  "Build the command line tools (hmap_info, hmap_sample)"      ON)
option(HPP_BUILD_TESTS  "Build the libhmap test-suite"                               ON)

# libhmap: map model, BSP/CSG compiler, lighting, .hmap format, FBX/OBJ export. No third-party dependencies.
add_subdirectory(libhmap)

if(HPP_BUILD_TOOLS)
  add_subdirectory(tools)
endif()

if(HPP_BUILD_TESTS)
  enable_testing()
  add_subdirectory(tests)
endif()

if(HPP_BUILD_EDITOR OR HPP_BUILD_VIEWER)
  include(cmake/Dependencies.cmake)   # raylib (+ Dear ImGui and rlImGui for the editor)
  if(HPP_BUILD_VIEWER)
    add_subdirectory(examples)
  endif()
  if(HPP_BUILD_EDITOR)
    add_subdirectory(editor)
  endif()
endif()
