Browse Source

Merge topic 'CheckPIESupported-Add-PIE-compile-flags'

a322aead0f CheckPIESupported: ensure PIE compile flags are specified

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !10034
Brad King 1 year ago
parent
commit
467d6f00cc
1 changed files with 3 additions and 0 deletions
  1. 3 0
      Modules/CheckPIESupported.cmake

+ 3 - 0
Modules/CheckPIESupported.cmake

@@ -120,6 +120,8 @@ function (check_pie_supported)
   foreach(lang IN LISTS CHECK_PIE_LANGUAGES)
     if(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER)
       if(NOT DEFINED CMAKE_${lang}_LINK_PIE_SUPPORTED)
+        # ensure PIE compile flags are also used
+        list(JOIN CMAKE_${lang}_COMPILE_OPTIONS_PIE " " CMAKE_REQUIRED_FLAGS)
         cmake_check_linker_flag(${lang}
                                 "${CMAKE_${lang}_LINK_OPTIONS_PIE}"
                                 CMAKE_${lang}_LINK_PIE_SUPPORTED
@@ -127,6 +129,7 @@ function (check_pie_supported)
         if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED)
           string (APPEND outputs "PIE (${lang}): ${output}\n")
         endif()
+        unset(CMAKE_REQUIRED_FLAGS)
       endif()
 
       if(NOT DEFINED CMAKE_${lang}_LINK_NO_PIE_SUPPORTED)