diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index 5867392c3076be..14cd3e678891b5 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -21,8 +21,10 @@ endif() set_compiler_property(PROPERTY optimization_speed -O2) set_compiler_property(PROPERTY optimization_size -Os) -set_compiler_property(PROPERTY optimization_lto -flto) -set_compiler_property(PROPERTY prohibit_lto -fno-lto) +if(CMAKE_C_COMPILER_VERSION GREATER_EQUAL "4.5.0") + set_compiler_property(PROPERTY optimization_lto -flto) + set_compiler_property(PROPERTY prohibit_lto -fno-lto) +endif() ####################################################### # This section covers flags related to warning levels #