Files
isaac-port/CMakeLists.txt
T

109 lines
5.4 KiB
CMake

cmake_minimum_required(VERSION 3.24)
project(isaac LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_BUILD_TYPE Release)
endif()
# SDL: static, with only the window, OpenGL context, audio, events and gamepad pieces the game uses.
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
set(SDL_STATIC ON CACHE BOOL "" FORCE)
set(SDL_OPENGL ON CACHE BOOL "" FORCE)
set(SDL_JOYSTICK ON CACHE BOOL "" FORCE)
set(SDL_HIDAPI ON CACHE BOOL "" FORCE)
set(SDL_TEST_LIBRARY OFF CACHE BOOL "" FORCE)
set(SDL_EXAMPLES OFF CACHE BOOL "" FORCE)
foreach(OPTION RENDER GPU VULKAN CAMERA HAPTIC HIDAPI_LIBUSB POWER SENSOR DIALOG TRAY OPENGLES OFFSCREEN
DUMMYVIDEO DISKAUDIO DUMMYAUDIO OSS JACK SNDIO KMSDRM IBUS LIBURING)
set(SDL_${OPTION} OFF CACHE BOOL "" FORCE)
endforeach()
add_subdirectory(external/sdl EXCLUDE_FROM_ALL)
# Lua 5.3, which mods are written against: static, POSIX, no native modules.
file(GLOB LUA_SOURCES CONFIGURE_DEPENDS external/lua/l*.c)
list(REMOVE_ITEM LUA_SOURCES ${CMAKE_SOURCE_DIR}/external/lua/lua.c ${CMAKE_SOURCE_DIR}/external/lua/ltests.c)
add_library(lua STATIC ${LUA_SOURCES})
target_include_directories(lua SYSTEM PUBLIC external/lua)
target_compile_definitions(lua PRIVATE LUA_USE_POSIX)
# simdjson: its single-file build, static, without exceptions, for the JSON the import tool writes into resources/.
add_library(simdjson STATIC external/simdjson/singleheader/simdjson.cpp)
target_include_directories(simdjson SYSTEM PUBLIC external/simdjson/singleheader)
target_compile_definitions(simdjson PUBLIC SIMDJSON_EXCEPTIONS=0)
# Xiph's Ogg, Vorbis and Theora for the cutscene videos (.ogv): static, decoders only.
set(INCLUDE_INTTYPES_H 1)
set(INCLUDE_STDINT_H 1)
set(INCLUDE_SYS_TYPES_H 1)
set(SIZE16 int16_t)
set(USIZE16 uint16_t)
set(SIZE32 int32_t)
set(USIZE32 uint32_t)
set(SIZE64 int64_t)
set(USIZE64 uint64_t)
configure_file(external/ogg/include/ogg/config_types.h.in ${CMAKE_BINARY_DIR}/xiph/ogg/config_types.h @ONLY)
add_library(ogg STATIC external/ogg/src/bitwise.c external/ogg/src/framing.c)
target_include_directories(ogg SYSTEM PUBLIC external/ogg/include ${CMAKE_BINARY_DIR}/xiph)
file(GLOB VORBIS_SOURCES CONFIGURE_DEPENDS external/vorbis/lib/*.c)
foreach(TOOL barkmel psytune tone vorbisenc)
list(REMOVE_ITEM VORBIS_SOURCES ${CMAKE_SOURCE_DIR}/external/vorbis/lib/${TOOL}.c)
endforeach()
add_library(vorbis STATIC ${VORBIS_SOURCES})
target_include_directories(vorbis SYSTEM PUBLIC external/vorbis/include PRIVATE external/vorbis/lib)
target_link_libraries(vorbis PUBLIC ogg)
set(THEORA_DECODER apiwrapper bitpack decapiwrapper decinfo decode dequant fragment huffdec idct info internal quant state)
list(TRANSFORM THEORA_DECODER PREPEND external/theora/lib/)
list(TRANSFORM THEORA_DECODER APPEND .c)
add_library(theora STATIC ${THEORA_DECODER})
target_include_directories(theora SYSTEM PUBLIC external/theora/include)
target_link_libraries(theora PUBLIC ogg)
target_compile_options(theora PRIVATE -w)
# The developer overlay (src/ui/overlay/) in place of the drop-down console, on Dear ImGui's docking branch: its core,
# the std::string widgets and the SDL3 and OpenGL 3 backends, static. OFF builds the game without either.
option(ISAAC_OVERLAY "Build the developer overlay in place of the drop-down console" ON)
if(ISAAC_OVERLAY)
set(IMGUI_SOURCES imgui imgui_draw imgui_tables imgui_widgets misc/cpp/imgui_stdlib backends/imgui_impl_sdl3
backends/imgui_impl_opengl3)
list(TRANSFORM IMGUI_SOURCES PREPEND external/imgui/)
list(TRANSFORM IMGUI_SOURCES APPEND .cpp)
add_library(imgui STATIC ${IMGUI_SOURCES})
target_include_directories(imgui SYSTEM PUBLIC external/imgui external/imgui/backends external/imgui/misc/cpp)
target_link_libraries(imgui PRIVATE SDL3::SDL3-static ${CMAKE_DL_LIBS})
target_compile_options(imgui PRIVATE -w)
endif()
# REPENTOGON's modding API built in natively (src/repentogon/, its scripts in assets/repentogon/): inert without mods,
# with every change to the vanilla game behind its options and the vanilla parity switch. OFF builds the vanilla game.
option(ISAAC_REPENTOGON "Build REPENTOGON's modding API into the game" ON)
# The curated game: every .cpp under src/, sorted into subsystem folders and including each other by path from src/,
# written on top of the declarations generated-src/classes.h holds for every class.
# generated-src/'s own bodies stay out until they compile (scripts/source_tree.py --check reports how many do).
# generated-src/stubs.cpp defines everything not curated yet as a stub that stops the game where it is reached, so the
# executable always links and runs exactly as far as src/ goes.
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp)
if(NOT ISAAC_OVERLAY)
list(FILTER SOURCES EXCLUDE REGEX "/src/ui/overlay/")
endif()
if(NOT ISAAC_REPENTOGON)
list(FILTER SOURCES EXCLUDE REGEX "/src/repentogon/")
endif()
add_executable(isaac ${SOURCES} generated-src/stubs.cpp)
target_include_directories(isaac PRIVATE src)
target_include_directories(isaac SYSTEM PRIVATE generated-src external/stb)
target_link_libraries(isaac PRIVATE SDL3::SDL3-static lua simdjson theora vorbis ogg)
if(ISAAC_OVERLAY)
target_compile_definitions(isaac PRIVATE ISAAC_OVERLAY)
target_link_libraries(isaac PRIVATE imgui)
endif()
if(ISAAC_REPENTOGON)
target_compile_definitions(isaac PRIVATE ISAAC_REPENTOGON)
endif()