Skip to content

Commit

Permalink
Explicitly set optimization to -O3 for release
Browse files Browse the repository at this point in the history
  • Loading branch information
kwryankrattiger committed Sep 7, 2021
1 parent 32a57c1 commit ac0c668
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMake/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ endif ()
if (NOT MSVC)
string(APPEND CMAKE_CXX_FLAGS "-Wall -Wextra")

# Need to explicitly set optimization level to -O3 because some systems default to -O2
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(optimization_flags " -mtune=native; -march=native")
foreach (flag ${optimization_flags})
check_cxx_compiler_flag(${flag} has_flag)
if(has_flag)
string(APPEND CMAKE_CXX_FLAGS ${flag})
string(APPEND CMAKE_CXX_FLAGS_RELEASE ${flag})
endif ()
endforeach ()

Expand Down

0 comments on commit ac0c668

Please sign in to comment.