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

Commit bfe2b05

Browse files
authored
epic: Add compiler optimizations (#2170)
* epic: Add compiler optimizations * Remove -march=native flag
1 parent b31878d commit bfe2b05

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

engine/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,29 @@ else()
4545
message(STATUS "CORTEX_CQA is OFF.")
4646
endif()
4747

48+
if(NOT CORTEX_CQA)
49+
message(STATUS "Setting up optimization flags for Release builds")
50+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
51+
# Add optimization flags for GCC/Clang
52+
add_compile_options($<$<CONFIG:Release>:-O3>)
53+
add_compile_options($<$<CONFIG:Release>:-flto>)
54+
add_link_options($<$<CONFIG:Release>:-flto>)
55+
elseif(MSVC)
56+
# Add optimization flags for MSVC
57+
add_compile_options($<$<CONFIG:Release>:/O2>)
58+
# Optional: Link-time optimization
59+
add_compile_options($<$<CONFIG:Release>:/GL>)
60+
add_link_options($<$<CONFIG:Release>:/LTCG>)
61+
endif()
62+
endif()
63+
4864
if(MSVC)
4965
add_compile_options(
5066
$<$<CONFIG:>:/MT> #---------|
5167
$<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
5268
$<$<CONFIG:Release>:/MT> #--|
69+
$<$<CONFIG:Release>:/O2> #--|-- Optimize for speed in Release mode
70+
$<$<CONFIG:Release>:/Ob2> #-|-- Inline any suitable function
5371
)
5472

5573
add_compile_options(/utf-8)

0 commit comments

Comments
 (0)