From 2c3d045efc9cd19c5917604979c7b9db6166ccca Mon Sep 17 00:00:00 2001 From: Brecht Sanders Date: Wed, 8 Feb 2023 20:47:58 +0100 Subject: [PATCH] Fix common\cmake\gnu.cmake for MinGW MinGW/MinGW-w64 doesn't support `-z`. --- common/cmake/gnu.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/cmake/gnu.cmake b/common/cmake/gnu.cmake index 365212bdda..7c85fe5543 100644 --- a/common/cmake/gnu.cmake +++ b/common/cmake/gnu.cmake @@ -95,10 +95,12 @@ IF (APPLE) ELSE(APPLE) IF (CMAKE_CXX_COMPILER_ID MATCHES "GNU") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") # issues link error for undefined symbols in shared library - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security + IF(NOT MINGW) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") # we do not need an executable stack + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z relro -z now") # re-arranges data sections to increase security + ENDIF () ENDIF () SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") # enables position independent execution for executable ENDIF(APPLE)