Просмотр исходного кода

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 год назад
Родитель
Сommit
467d6f00cc
1 измененных файлов с 3 добавлено и 0 удалено
  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)
   foreach(lang IN LISTS CHECK_PIE_LANGUAGES)
     if(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER)
     if(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER)
       if(NOT DEFINED CMAKE_${lang}_LINK_PIE_SUPPORTED)
       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_check_linker_flag(${lang}
                                 "${CMAKE_${lang}_LINK_OPTIONS_PIE}"
                                 "${CMAKE_${lang}_LINK_OPTIONS_PIE}"
                                 CMAKE_${lang}_LINK_PIE_SUPPORTED
                                 CMAKE_${lang}_LINK_PIE_SUPPORTED
@@ -127,6 +129,7 @@ function (check_pie_supported)
         if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED)
         if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED)
           string (APPEND outputs "PIE (${lang}): ${output}\n")
           string (APPEND outputs "PIE (${lang}): ${output}\n")
         endif()
         endif()
+        unset(CMAKE_REQUIRED_FLAGS)
       endif()
       endif()
 
 
       if(NOT DEFINED CMAKE_${lang}_LINK_NO_PIE_SUPPORTED)
       if(NOT DEFINED CMAKE_${lang}_LINK_NO_PIE_SUPPORTED)