This repository has been archived on 2026-03-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SakuraVNE_old/CMakeLists.txt

158 lines
5.7 KiB
CMake

# Require a modern version of CMake
cmake_minimum_required(VERSION 3.15)
# Define the workspace/project
project(SakuraVNE LANGUAGES CXX)
# ------------------------------------------------------------------------------
# Default Build Type Configuration
# ------------------------------------------------------------------------------
# If the user didn't specify a build type, default to Debug
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting default build type to 'Debug'")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
# Provide dropdown options for tools like CMake GUI or IDEs
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# Enforce C++20 globally
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # Disables compiler-specific extensions (like gnu++20)
# ------------------------------------------------------------------------------
# Output Directory Configuration (Mirrors your Premake setup)
# ------------------------------------------------------------------------------
# This mimics: build/bin/{Config}-{System}-{Architecture}
set(OUTPUT_DIR_SUFFIX "$<CONFIG>-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${OUTPUT_DIR_SUFFIX}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${OUTPUT_DIR_SUFFIX}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${OUTPUT_DIR_SUFFIX}")
# ------------------------------------------------------------------------------
# Dependencies
# ------------------------------------------------------------------------------
# 1. SDL3
set(SDL_TESTS OFF CACHE BOOL "Disable SDL3 tests" FORCE)
set(SDL_EXAMPLES OFF CACHE BOOL "Disable SDL3 examples" FORCE)
add_subdirectory(libs/sdl3)
# 2. spdlog
set(SPDLOG_BUILD_COMPILED ON CACHE BOOL "Build spdlog as a compiled library" FORCE)
set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "Disable spdlog examples" FORCE)
set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "Disable spdlog tests" FORCE)
add_subdirectory(libs/spdlog)
# 3. ImGui & ImGui Node Editor
add_subdirectory(libs/imgui)
add_subdirectory(libs/imgui-node-editor)
# 4. Catch2
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CMAKE_BUILD_TYPE)
add_subdirectory(libs/catch2)
endif()
# ------------------------------------------------------------------------------
# Source Gathering
# ------------------------------------------------------------------------------
# Gather all .cpp and .h files in the src folder
file(GLOB_RECURSE SAKURA_SRCS "SakuraVNE/src/*.cpp" "SakuraVNE/src/*.h")
# CRITICAL: Remove main.cpp from the list so Catch2 can provide its own main()
list(REMOVE_ITEM SAKURA_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/SakuraVNE/src/main.cpp")
# ------------------------------------------------------------------------------
# SakuraVNE Executable Target
# ------------------------------------------------------------------------------
# Create the ConsoleApp executable (explicitly adding main.cpp back in here)
add_executable(SakuraVNE "SakuraVNE/src/main.cpp" ${SAKURA_SRCS})
# Tell the compiler where the headers are
target_include_directories(SakuraVNE PRIVATE
"SakuraVNE/src"
"libs/spdlog/include"
"libs/imgui"
"libs/imgui/misc"
"libs/imgui/backends"
"libs/imgui-node-editor"
"libs/sdl3/include"
)
# Link the libraries. CMake handles all the libdirs automatically! [cite: 5]
target_link_libraries(SakuraVNE PRIVATE
ImGui
ImGuiNodeEditor
SDL3::SDL3
spdlog::spdlog
)
# ------------------------------------------------------------------------------
# Tests Executable Target
# ------------------------------------------------------------------------------
# These tests can use the Catch2-provided main, plus ALL your engine source files
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CMAKE_BUILD_TYPE)
add_executable(tests "SakuraVNE/test/test.cpp" ${SAKURA_SRCS})
# The tests need the exact same include directories so your engine #includes work
target_include_directories(tests PRIVATE
"SakuraVNE/src"
"libs/spdlog/include"
"libs/imgui"
"libs/imgui/misc"
"libs/imgui/backends"
"libs/imgui-node-editor"
"libs/sdl3/include"
)
# Link Catch2 AND the exact same dependencies your game uses
target_link_libraries(tests PRIVATE
Catch2::Catch2WithMain
ImGui
ImGuiNodeEditor
SDL3::SDL3
spdlog::spdlog
)
endif()
# ------------------------------------------------------------------------------
# Platform & Configuration Filters
# ------------------------------------------------------------------------------
if(WIN32)
# Apply to Game
target_compile_definitions(SakuraVNE PRIVATE PLATFORM_WINDOWS)
target_link_options(SakuraVNE PRIVATE "/NODEFAULTLIB:MSVCRT")
# Apply to Tests
target_compile_definitions(tests PRIVATE PLATFORM_WINDOWS)
target_link_options(tests PRIVATE "/NODEFAULTLIB:MSVCRT")
elseif(UNIX AND NOT APPLE)
# Apply to Game
target_compile_definitions(SakuraVNE PRIVATE PLATFORM_LINUX)
target_link_libraries(SakuraVNE PRIVATE dl pthread)
# Apply to Tests
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CMAKE_BUILD_TYPE)
target_compile_definitions(tests PRIVATE PLATFORM_LINUX)
target_link_libraries(tests PRIVATE dl pthread)
endif()
endif()
# Debug vs Release definitions for Game
target_compile_definitions(SakuraVNE PRIVATE
$<$<CONFIG:Debug>:DEBUG>
$<$<CONFIG:Release>:RELEASE>
)
# Debug vs Release definitions for Tests
target_compile_definitions(tests PRIVATE
$<$<CONFIG:Debug>:DEBUG>
$<$<CONFIG:Release>:RELEASE>
)