112 lines
4.7 KiB
CMake
112 lines
4.7 KiB
CMake
cmake_minimum_required(VERSION 3.25)
|
|
project(FasetEngine VERSION 0.1.0 LANGUAGES C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
option(FASET_BUILD_RENDERER "Build the SDL3/Vulkan renderer and graphical applications" ON)
|
|
option(FASET_SANITIZERS "Enable address and undefined behavior sanitizers" OFF)
|
|
option(FASET_DEBUG_IMGUI "Build optional Dear ImGui diagnostics library" OFF)
|
|
option(FASET_BUILD_RUNTIME "Build ECS and physics runtime" ON)
|
|
option(FASET_BUILD_ASSETS "Build asset import tools" ON)
|
|
option(FASET_BUILD_AUTHORING "Build scene authoring and metadata" ON)
|
|
option(FASET_BUILD_EDITOR "Build retained UI and editor applications" ON)
|
|
include(CTest)
|
|
find_package(Threads REQUIRED)
|
|
|
|
if(FASET_SANITIZERS AND NOT MSVC)
|
|
add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer)
|
|
add_link_options(-fsanitize=address,undefined)
|
|
endif()
|
|
if(MSVC)
|
|
add_compile_options(/utf-8 /W4 /permissive-)
|
|
else()
|
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
|
endif()
|
|
|
|
include(cmake/Dependencies.cmake)
|
|
add_library(faset_core STATIC src/core/hash.cpp src/core/io.cpp src/core/process.cpp)
|
|
target_include_directories(faset_core PUBLIC include)
|
|
target_link_libraries(faset_core PUBLIC nlohmann_json::nlohmann_json Threads::Threads)
|
|
target_compile_definitions(faset_core PUBLIC FASET_VERSION="${PROJECT_VERSION}")
|
|
|
|
# Modules are independent targets; Player never links authoring, editor or MCP.
|
|
foreach(module Authoring Runtime Assets)
|
|
if(module STREQUAL "Authoring" AND NOT FASET_BUILD_AUTHORING)
|
|
continue()
|
|
endif()
|
|
if(module STREQUAL "Runtime" AND NOT FASET_BUILD_RUNTIME)
|
|
continue()
|
|
endif()
|
|
if(module STREQUAL "Assets" AND NOT FASET_BUILD_ASSETS)
|
|
continue()
|
|
endif()
|
|
if(EXISTS "${PROJECT_SOURCE_DIR}/cmake/${module}.cmake")
|
|
include(cmake/${module}.cmake)
|
|
endif()
|
|
endforeach()
|
|
if(FASET_BUILD_RENDERER AND EXISTS "${PROJECT_SOURCE_DIR}/cmake/Renderer.cmake")
|
|
include(cmake/Renderer.cmake)
|
|
endif()
|
|
if(TARGET faset_gameplay AND EXISTS "${PROJECT_SOURCE_DIR}/cmake/Player.cmake")
|
|
include(cmake/Player.cmake)
|
|
endif()
|
|
if(TARGET faset_authoring AND EXISTS "${PROJECT_SOURCE_DIR}/cmake/EditorCommands.cmake")
|
|
include(cmake/EditorCommands.cmake)
|
|
endif()
|
|
if(TARGET faset_assets AND TARGET faset_authoring AND EXISTS "${PROJECT_SOURCE_DIR}/cmake/BuildService.cmake")
|
|
include(cmake/BuildService.cmake)
|
|
endif()
|
|
if(TARGET faset_editor_commands AND TARGET faset_build_service)
|
|
include(cmake/Plugins.cmake)
|
|
add_library(faset_editor_session STATIC src/editor/session.cpp)
|
|
target_link_libraries(faset_editor_session PUBLIC faset_editor_commands faset_build_service faset_assets faset_editor_plugins)
|
|
if(BUILD_TESTING)
|
|
add_executable(faset_editor_session_tests tests/editor_session_tests.cpp)
|
|
target_link_libraries(faset_editor_session_tests PRIVATE faset_editor_session)
|
|
target_compile_definitions(faset_editor_session_tests PRIVATE FASET_TEST_ENGINE="${PROJECT_SOURCE_DIR}")
|
|
add_test(NAME editor_session_settings COMMAND faset_editor_session_tests)
|
|
endif()
|
|
endif()
|
|
foreach(module UI EditorUI Editor Applications)
|
|
if(NOT FASET_BUILD_EDITOR)
|
|
continue()
|
|
endif()
|
|
if(EXISTS "${PROJECT_SOURCE_DIR}/cmake/${module}.cmake")
|
|
include(cmake/${module}.cmake)
|
|
endif()
|
|
endforeach()
|
|
|
|
if(TARGET faset_editor_session)
|
|
add_executable(faset_editor apps/editor_main.cpp)
|
|
target_link_libraries(faset_editor PRIVATE faset_editor_session)
|
|
target_compile_definitions(faset_editor PRIVATE FASET_ENGINE_SOURCE="${PROJECT_SOURCE_DIR}")
|
|
if(BUILD_TESTING)
|
|
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
|
add_test(NAME editor_mcp_stdio COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tests/mcp_stdio_test.py $<TARGET_FILE:faset_editor>)
|
|
set_tests_properties(editor_mcp_stdio PROPERTIES TIMEOUT 60)
|
|
endif()
|
|
if(TARGET faset_editor_ui)
|
|
target_link_libraries(faset_editor PRIVATE faset_editor_ui faset_project_launcher)
|
|
target_link_libraries(faset_editor PRIVATE faset_stb)
|
|
target_compile_definitions(faset_editor PRIVATE FASET_HAS_EDITOR_UI=1)
|
|
target_sources(faset_editor PRIVATE apps/editor_gui.cpp)
|
|
if(BUILD_TESTING)
|
|
add_test(NAME editor_gui_mcp COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tests/editor_gui_mcp_test.py $<TARGET_FILE:faset_editor>)
|
|
set_tests_properties(editor_gui_mcp PROPERTIES LABELS "gpu;window" TIMEOUT 180)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if(BUILD_TESTING)
|
|
add_executable(faset_core_tests tests/core_tests.cpp)
|
|
target_link_libraries(faset_core_tests PRIVATE faset_core)
|
|
add_test(NAME core COMMAND faset_core_tests)
|
|
endif()
|
|
|
|
include(cmake/Tutorials.cmake)
|
|
|
|
include(cmake/WindowsPlatform.cmake)
|