# エンジン：どのゲームでも使うクラスをまとめた静的ライブラリ
# The engine: a static library with the classes every game uses
#
#   engine/include/engine/*.hh  公開ヘッダー（#include "engine/sprite_batch.hh"） / public headers
#   engine/src/*.cc             実装 / the implementation
#   engine/shaders/*            エンジンのシェーダー（実行時にプロジェクトのルートから読む） / the engine's shaders
#                               (loaded at run time, relative to the project root)

# stb_image：実装は src/stb_image_impl.cc だけ。他人のコードなので警告フラグなしの別ライブラリにする
# stb_image: the implementation lives in src/stb_image_impl.cc only. It is someone else's code,
# so it is a separate library built without our warning flags
add_library(stb_image STATIC src/stb_image_impl.cc)
target_include_directories(stb_image PUBLIC ${PROJECT_SOURCE_DIR}/external/stb)

add_library(engine STATIC
  # 第1〜24章 / chapters 1-24
  src/window.cc
  src/gl_debug.cc
  src/buffer.cc
  src/mesh.cc
  src/file_util.cc
  src/shader.cc
  src/texture.cc
  src/shapes.cc
  src/camera.cc
  src/material.cc
  src/lights.cc
  src/json.cc
  src/gltf.cc
  src/model.cc
  src/framebuffer.cc
  src/cubemap.cc
  src/gpu_timer.cc
  src/tangents.cc
  src/ibl.cc
  src/pbr_material.cc
  src/renderer3d.cc
  # 第25章：2D / chapter 25: 2D
  src/camera2d.cc
  src/pixel_canvas.cc
  src/sprite_batch.cc
  src/sprite_sheet.cc
  src/animation.cc
  # 第26章：ゲームの道具 / chapter 26: the game toolkit
  src/font.cc
  src/input.cc
  src/game_loop.cc
  src/scene.cc
  src/collision.cc
  src/rng.cc)

# PUBLIC：エンジンを使う側（ゲーム）にも include/、linalg.hh、GLAD、GLFWが見える
# PUBLIC: whoever links the engine (the games) also sees include/, linalg.hh, GLAD and GLFW
target_include_directories(engine PUBLIC include ${PROJECT_SOURCE_DIR}/external/linalg)
target_link_libraries(engine PRIVATE stb_image PUBLIC glad glfw)
enable_warnings(engine)
