From b21c2ae643b1dc92ae7a0426dcb406a65ff8ec83 Mon Sep 17 00:00:00 2001 From: Username404 Date: Sat, 27 Mar 2021 11:10:08 +0100 Subject: [PATCH] Check if PIE is supported on MSVC too in the CMakeLists.txt file. --- CMakeLists.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48a38d9..64f7e74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,15 +20,18 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) set(CMAKE_CXX_FLAGS "-Wall") -if (NOT MSVC) - if (CMAKE_POSITION_INDEPENDENT_CODE) - include(CheckPIESupported) +if (CMAKE_POSITION_INDEPENDENT_CODE) + include(CheckPIESupported) + if (NOT MSVC) add_link_options("-pie") - check_pie_supported() - endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + endif () + check_pie_supported() +endif() + +if (NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + set(CMAKE_CXX_FLAGS_RELEASE "-Os") endif() -set(CMAKE_CXX_FLAGS_RELEASE "-Os") if ((${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) OR (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0)