Files
Faset_Engine/CMakeLists.txt
T

67 lines
2.4 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)
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()
foreach(module UI Editor Applications)
if(NOT FASET_BUILD_EDITOR)
continue()
endif()
if(EXISTS "${PROJECT_SOURCE_DIR}/cmake/${module}.cmake")
include(cmake/${module}.cmake)
endif()
endforeach()
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()