From 60dfc28e98a077a94c8a1f93475ebb19b72b84f0 Mon Sep 17 00:00:00 2001 From: jesperpedersen Date: Mon, 18 Oct 2021 10:42:33 -0400 Subject: [PATCH] [#180] Do not link shared library parts with -pie -fPIE as it breaks LTO --- src/CMakeLists.txt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8d22c264..6b69453a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,14 +140,11 @@ if (CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") endif() - if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - check_c_compiler_flag(-fPIE HAS_PIE) - if (HAS_PIE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") - set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pie") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") - endif() + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + check_c_compiler_flag(-fPIE HAS_PIE) + if (HAS_PIE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") endif() endif()