diff --git a/cmake/Modules/UseOptimization.cmake b/cmake/Modules/UseOptimization.cmake new file mode 100644 index 00000000..7a86631b --- /dev/null +++ b/cmake/Modules/UseOptimization.cmake @@ -0,0 +1,19 @@ +# - Turn on optimizations based on build type + +include (AddOptions) + +# if we are building a debug target, then disable all optimizations +# otherwise, turn them on. indicate to the code what we have done +# so it can turn on assertions etc. +if (CMAKE_COMPILER_IS_GNUCXX) + add_options ( + ALL_LANGUAGES + "Debug" + "-O0" "-DDEBUG" + ) + add_options ( + ALL_LANGUAGES + "Release;RelWithDebInfo;MinSizeRel" + "-O3" "-DNDEBUG" "-flto" + ) +endif (CMAKE_COMPILER_IS_GNUCXX)