Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

epic: Add compiler optimizations #2170

Merged
merged 2 commits into from
Mar 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,29 @@ else()
message(STATUS "CORTEX_CQA is OFF.")
endif()

if(NOT CORTEX_CQA)
message(STATUS "Setting up optimization flags for Release builds")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
# Add optimization flags for GCC/Clang
add_compile_options($<$<CONFIG:Release>:-O3>)
add_compile_options($<$<CONFIG:Release>:-flto>)
add_link_options($<$<CONFIG:Release>:-flto>)
elseif(MSVC)
# Add optimization flags for MSVC
add_compile_options($<$<CONFIG:Release>:/O2>)
# Optional: Link-time optimization
add_compile_options($<$<CONFIG:Release>:/GL>)
add_link_options($<$<CONFIG:Release>:/LTCG>)
endif()
endif()

if(MSVC)
add_compile_options(
$<$<CONFIG:>:/MT> #---------|
$<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
$<$<CONFIG:Release>:/MT> #--|
$<$<CONFIG:Release>:/O2> #--|-- Optimize for speed in Release mode
$<$<CONFIG:Release>:/Ob2> #-|-- Inline any suitable function
)

add_compile_options(/utf-8)
Expand Down
Loading