From 35f129d173c445b0c62ef63205fc88844ef76b32 Mon Sep 17 00:00:00 2001 From: Deniz Evrenci Date: Fri, 26 Oct 2018 17:44:28 +0900 Subject: [PATCH] [C++] Add option to enable Ofast in release builds. 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. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df64c6e944..8ad35b0a6c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -184,7 +187,9 @@ if(UNIX) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") endif(COVERAGE_BUILD) - add_compile_options($<$:-Ofast>) + if (AERON_ENABLE_NONSTANDARD_OPTIMIZATIONS) + add_compile_options($<$:-Ofast>) + endif () endif() # platform specific flags