diff --git a/CMakeLists.txt b/CMakeLists.txt index f734fce96a..e9dbcb9aa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,14 +230,6 @@ if(NOT MSVC) endif() endif(NOT MSVC) -if(ENABLE_LTO) - check_and_add_flag(LTO -flto) - if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) - set(CMAKE_AR gcc-ar) - set(CMAKE_RANLIB gcc-ranlib) - endif() -endif() - if(APPLE) # This doesn't play well with the packaging script that doesn't understand @rpath set(CMAKE_MACOSX_RPATH OFF) @@ -292,6 +284,14 @@ if(APPLE) ) endif() +if(ENABLE_LTO) + check_and_add_flag(LTO -flto) + if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) + set(CMAKE_AR gcc-ar) + set(CMAKE_RANLIB gcc-ranlib) + endif() +endif() + if(WIN32) add_definitions(-D_SECURE_SCL=0) add_definitions(-D_CRT_SECURE_NO_WARNINGS)