Skip to content

Commit

Permalink
[C++] Add option to enable Ofast in release builds.
Browse files Browse the repository at this point in the history
CMake automatically adds -O3 for release builds. Ofast adds potentially
breaking non-standard optimizations during compilation. This change
keeps -Ofast enabled for stand alone builds but disables it when Aeron
is added with add_subdirectory command.
  • Loading branch information
denizevrenci committed Dec 5, 2018
1 parent 89b7451 commit b84abb5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ option(AERON_TESTS "Enable tests" ${STANDALONE_BUILD})
option(AERON_BUILD_SAMPLES "Enable building the sample projects" ${STANDALONE_BUILD})
option(AERON_BUILD_DOCUMENTATION "Build Aeron documentation" ${STANDALONE_BUILD})
option(AERON_INSTALL_TARGETS "Enable installation step" ${STANDALONE_BUILD})
if (UNIX)
option(AERON_ENABLE_NONSTANDARD_OPTIMIZATIONS "Enable Ofast for release builds" ${STANDALONE_BUILD})
endif ()

unset(STANDALONE_BUILD)

Expand Down Expand Up @@ -188,7 +191,9 @@ if(UNIX)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif(COVERAGE_BUILD)

add_compile_options($<$<CONFIG:Release>:-Ofast>)
if (AERON_ENABLE_NONSTANDARD_OPTIMIZATIONS)
add_compile_options($<$<CONFIG:Release>:-Ofast>)
endif ()
endif()

# platform specific flags
Expand Down

0 comments on commit b84abb5

Please sign in to comment.