1 parent
52ab1ca24c
commit
a3715201e1
23 files changed
+2226
-37
No files matched your search
+54
-2
@@ -1,6 +1,31 @@
|
||||
cmake_minimum_required(VERSION 4.0.0)
|
||||
project(Echoion VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
# Default to a Release build when the developer/CI did not pick a config.
|
||||
# Without this, single-config generators leave CMAKE_BUILD_TYPE empty and GCC
|
||||
# falls back to -O0, so "production" builds shipped unoptimised. Set this before
|
||||
# any CPMAddPackage() below so fetched dependencies (Void, Boost, quickjs) are
|
||||
# compiled with the same optimisation level as Echoion itself.
|
||||
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
Debug Release RelWithDebInfo MinSizeRel)
|
||||
message(STATUS "No CMAKE_BUILD_TYPE set; defaulting to Release")
|
||||
endif()
|
||||
|
||||
# Use ccache (or sccache) as a compiler launcher when available to speed up
|
||||
# incremental and clean-from-cache rebuilds. Opt-out with -DECHOION_USE_CCACHE=OFF.
|
||||
option(ECHOION_USE_CCACHE "Use ccache/sccache compiler launcher if found" ON)
|
||||
if(ECHOION_USE_CCACHE AND NOT CMAKE_CXX_COMPILER_LAUNCHER)
|
||||
find_program(ECHOION_CCACHE_PROGRAM NAMES ccache sccache)
|
||||
if(ECHOION_CCACHE_PROGRAM)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${ECHOION_CCACHE_PROGRAM}")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${ECHOION_CCACHE_PROGRAM}")
|
||||
message(STATUS "Compiler cache enabled: ${ECHOION_CCACHE_PROGRAM}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Include CPM
|
||||
file(
|
||||
DOWNLOAD
|
||||
@@ -26,7 +51,7 @@ CPMAddPackage(
|
||||
CPMAddPackage(
|
||||
NAME Void
|
||||
GIT_REPOSITORY http://git.faumaray.ru/void/voidlibrary.git
|
||||
GIT_TAG 2c3ff56b677529ed91decf8d4cfb415ffec51042
|
||||
GIT_TAG main
|
||||
OPTIONS
|
||||
"VOID_ENABLE_TESTING OFF"
|
||||
)
|
||||
@@ -44,6 +69,33 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_G
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-freflection>)
|
||||
endif()
|
||||
|
||||
# Link-time optimisation for Release configs only (keeps Debug builds fast).
|
||||
# Experimental C++26 reflection (-freflection) is a front-end feature and is
|
||||
# orthogonal to GCC's LTO, but gate behind an option so it can be disabled if a
|
||||
# given toolchain rejects the combination.
|
||||
option(ECHOION_ENABLE_LTO "Enable interprocedural optimisation for Release builds" ON)
|
||||
if(ECHOION_ENABLE_LTO)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT _ipoSupported OUTPUT _ipoError LANGUAGES CXX)
|
||||
if(_ipoSupported)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON)
|
||||
message(STATUS "Interprocedural optimisation (LTO) enabled for Release")
|
||||
else()
|
||||
message(STATUS "IPO/LTO not supported by toolchain: ${_ipoError}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Unity builds batch translation units to cut compile time. Kept OFF by default
|
||||
# because reflection TUs and Glaze-heavy headers can blow up unity batch memory;
|
||||
# enable per-machine with -DECHOION_UNITY_BUILD=ON.
|
||||
option(ECHOION_UNITY_BUILD "Enable CMake unity (jumbo) builds" OFF)
|
||||
if(ECHOION_UNITY_BUILD)
|
||||
set(CMAKE_UNITY_BUILD ON)
|
||||
set(CMAKE_UNITY_BUILD_BATCH_SIZE 8)
|
||||
message(STATUS "Unity build enabled (batch size 8)")
|
||||
endif()
|
||||
|
||||
# Enable folder organization in IDEs
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
@@ -86,7 +138,7 @@ endif()
|
||||
# Tests
|
||||
if(BUILD_TESTS)
|
||||
enable_testing()
|
||||
# add_subdirectory(tests)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
# Packaging configuration
|
||||
|
||||
Reference in new issue
Block a user