From 5459c24d9234b0973a1f0709f35391c6ccfe0c6f Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Sat, 17 Jun 2023 12:12:49 -0700 Subject: [PATCH] Add PIE (Position Independent Executable) compiler flags. https://redmine.stoutner.com/issues/1021 --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62b0491..42b28dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,15 @@ include(ECMInstallIcons) include(ECMQtDeclareLoggingCategory) include(FeatureSummary) +# Include the Position Independent Executable checker. +include(CheckPIESupported) + +# Check to see if Position Independent Executable is supported in the current linker and environment. +check_pie_supported() + +# Add the Position Independent Executable compiler flag if it is supported in the current linker and environment. +set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + # Load the Qt components. find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core -- 2.45.2