diff options
author | Zachary Michaels <mikezackles@gmail.com> | 2014-08-06 12:52:25 -0400 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2014-09-15 22:29:39 +0200 |
commit | 729d4bb91da9458df2da05ca5c214ee1ab331aa9 (patch) | |
tree | abdfeb097535f60e08be6ee9f6bceef2a28298be /CMakeLists.txt | |
parent | Remove unnecessary else (diff) | |
download | monero-729d4bb91da9458df2da05ca5c214ee1ab331aa9.tar.xz |
User setting to turn LTO on and off
This isn't currently working on mingw
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ecb166661..857e927ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,11 +92,6 @@ else() else() set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized") endif() - # Since gcc 4.9 the LTO format is non-standard (slim), so we need the gcc-specific ar and ranlib binaries - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0)) - set(CMAKE_AR "gcc-ar") - set(CMAKE_RANLIB "gcc-ranlib") - endif() if(MINGW) set(WARNINGS "${WARNINGS} -Wno-error=unused-value -Wno-error=unused-but-set-variable") set(MINGW_FLAG "${MINGW_FLAG} -DWIN32_LEAN_AND_MEAN") @@ -121,14 +116,23 @@ else() else() set(DEBUG_FLAGS "-g3 -O0") endif() + set(RELEASE_FLAGS "-Ofast -DNDEBUG -Wno-unused-variable") - if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + + set(USE_LTO false CACHE BOOL "Use Link-Time Optimization (Release mode only)") + if(USE_LTO) # There is a clang bug that does not allow to compile code that uses AES-NI intrinsics if -flto is enabled set(RELEASE_FLAGS "${RELEASE_FLAGS} -flto") + if(STATIC) + set(RELEASE_FLAGS "${RELEASE_FLAGS} -ffat-lto-objects") + endif() + # Since gcc 4.9 the LTO format is non-standard (slim), so we need the gcc-specific ar and ranlib binaries + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0)) + set(CMAKE_AR "gcc-ar") + set(CMAKE_RANLIB "gcc-ranlib") + endif() endif() - #if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW) - # set(RELEASE_FLAGS "${RELEASE_FLAGS} -fno-fat-lto-objects") - #endif() + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}") |