From 7c56b43afc0e22cb9b00142225b6632c4f2b554b Mon Sep 17 00:00:00 2001 From: dehnert Date: Thu, 10 Nov 2016 21:40:57 +0100 Subject: [PATCH] adding linker flags that make lto work Former-commit-id: 2a7e2cb2ff9a621683c6a78df91de468476c635a [formerly 230d50f0751f5741f85699144a3d4b9be1e89c40] Former-commit-id: 7a250517c3a443c4ec525f4d7a456f4ff5b269e1 --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 451ce6076..bb72f3b26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,8 +131,11 @@ if(CMAKE_COMPILER_IS_GNUCC) # Fix thanks to: https://github.com/freeorion/freeorion/issues/777 add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -flto -Wall -pedantic -fprefetch-loop-arrays -ffast-math -fno-finite-math-only -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -fprefetch-loop-arrays -ffast-math -fno-finite-math-only") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) message(FATAL_ERROR "GCC version must be at least 5.0.") endif() @@ -166,6 +169,8 @@ else(CLANG) set (CLANG ON) # Set standard flags for clang set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -ffast-math -fno-finite-math-only") + set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export_dynamic") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export_dynamic") if(UNIX AND NOT APPLE) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)