-set(enable_lto OFF)
-if(enable_compile_optimizations
- AND CMAKE_COMPILER_IS_GNUCC
- AND (NOT enable_model-checking))
- if(WIN32)
- if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8")
- # On windows, we need 4.8 or higher to enable lto because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50293
- #
- # We are experiencing assertion failures even with 4.8 on MinGW.
- # Push the support forward: will see if 4.9 works when we test it.
+if(enable_lto) # User wants LTO. Try if we can do that
+ set(enable_lto OFF)
+ if(enable_compile_optimizations
+ AND CMAKE_COMPILER_IS_GNUCC
+ AND (NOT enable_model-checking))
+ if(WIN32)
+ if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8")
+ # On windows, we need 4.8 or higher to enable lto because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50293
+ #
+ # We are experiencing assertion failures even with 4.8 on MinGW.
+ # Push the support forward: will see if 4.9 works when we test it.
+ set(enable_lto ON)
+ endif()
+ elseif(LINKER_VERSION STRGREATER "2.22")