Files
factory-hole-core/CMakeLists.txt
2026-02-22 15:19:54 +09:00

144 lines
3.5 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
cmake_minimum_required(VERSION 3.20)
project(factory-hole-core LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(FetchContent)
# ---- Core dependencies -------------------------------------------------------
# Flecs ECS
FetchContent_Declare(
flecs
GIT_REPOSITORY https://github.com/SanderMertens/flecs.git
GIT_TAG v4.1.4
GIT_SHALLOW TRUE
)
# Doctest
FetchContent_Declare(
doctest
GIT_REPOSITORY https://github.com/doctest/doctest.git
GIT_TAG v2.4.12
GIT_SHALLOW TRUE
)
# GLM vector/matrix math
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 1.0.1
GIT_SHALLOW TRUE
)
# nlohmann/json graph serialisation
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
GIT_SHALLOW TRUE
)
# ---- World-generation dependencies ------------------------------------------
# FastNoise2 noise nodes
FetchContent_Declare(
FastNoise2
GIT_REPOSITORY https://github.com/Auburn/FastNoise2.git
GIT_TAG master
GIT_SHALLOW TRUE
)
# ---- Frontend dependencies (used by tools/) ----------------------------------
# GLFW windowing for the node-editor tool
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.4
GIT_SHALLOW TRUE
)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
# Dear ImGui
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.91.6
GIT_SHALLOW TRUE
)
# ImNodes node-graph editor widget for ImGui
FetchContent_Declare(
imnodes
GIT_REPOSITORY https://github.com/Nelarius/imnodes.git
GIT_TAG v0.5
GIT_SHALLOW TRUE
)
# ImGuiFileDialog file browser widget for the node-editor tool
FetchContent_Declare(
ImGuiFileDialog
GIT_REPOSITORY https://github.com/aiekick/ImGuiFileDialog.git
GIT_TAG v0.6.7
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(flecs doctest glm nlohmann_json glfw imgui imnodes)
# ---- Core library ------------------------------------------------------------
set(SOURCES
src/Components/Config/WorldConfig.cpp
src/Components/Support.cpp
src/Core/WorldInstance.cpp
src/WorldGraph/WorldGraph.cpp
src/WorldGraph/WorldGraphSerializer.cpp
src/WorldGraph/WorldGraphChunk.cpp
)
add_library(factory-hole-core ${SOURCES})
target_include_directories(factory-hole-core PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(factory-hole-core PUBLIC
flecs::flecs_static
doctest::doctest
glm::glm
nlohmann_json::nlohmann_json
)
# ---- Main executable ---------------------------------------------------------
add_executable(factory-hole-app src/main.cpp)
target_link_libraries(factory-hole-app PRIVATE factory-hole-core)
# ---- Tests -------------------------------------------------------------------
enable_testing()
file(GLOB_RECURSE TEST_SOURCES tests/*.cpp)
add_executable(factory-hole-tests ${TEST_SOURCES})
target_include_directories(factory-hole-tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(factory-hole-tests PRIVATE
factory-hole-core
doctest::doctest_with_main
)
add_test(NAME factory-hole-tests COMMAND factory-hole-tests)
# ---- Tools -------------------------------------------------------------------
add_subdirectory(tools/node-editor)