summaryrefslogtreecommitdiff
path: root/Modules/CheckPIESupported.cmake
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-01-16 16:11:45 +0100
committerMarc Chevrier <marc.chevrier@gmail.com>2022-01-19 10:49:23 +0100
commit219dde4ea8469a9dea7fddbf5c8b8f0bfc875514 (patch)
treef896a2dd201f5bdc123c172ac6042597debaa79f /Modules/CheckPIESupported.cmake
parent4fa105d34ebc8f757f89cf81b746aae6f43605a1 (diff)
downloadcmake-219dde4ea8469a9dea7fddbf5c8b8f0bfc875514.tar.gz
CheckPIESupported: now uses any SYSROOT settings
Fixes: 23053
Diffstat (limited to 'Modules/CheckPIESupported.cmake')
-rw-r--r--Modules/CheckPIESupported.cmake26
1 files changed, 16 insertions, 10 deletions
diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake
index fb87822462..5919d4b717 100644
--- a/Modules/CheckPIESupported.cmake
+++ b/Modules/CheckPIESupported.cmake
@@ -25,7 +25,8 @@ property for executables will be honored at link time.
Set ``<output>`` variable with details about any error.
``LANGUAGES <lang>...``
Check the linkers used for each of the specified languages.
- Supported languages are ``C``, ``CXX``, and ``Fortran``.
+ Supported languages are ``C``, ``CXX``, ``OBJC``, ``OBJCXX``, ``Fortran``,
+ ``CUDA``, and ``HIP``.
It makes no sense to use this module when :policy:`CMP0083` is set to ``OLD``,
so the command will return an error in this case. See policy :policy:`CMP0083`
@@ -62,7 +63,7 @@ Examples
#]=======================================================================]
-include (Internal/CMakeTryCompilerOrLinkerFlag)
+include (Internal/CheckLinkerFlag)
function (check_pie_supported)
cmake_policy(GET CMP0083 cmp0083)
@@ -86,7 +87,7 @@ function (check_pie_supported)
if (CHECK_PIE_LANGUAGES)
set (unsupported_languages "${CHECK_PIE_LANGUAGES}")
- list (REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran")
+ list (REMOVE_ITEM unsupported_languages "C" "CXX" "OBJC" "OBJCXX" "Fortran" "CUDA" "HIP")
if(unsupported_languages)
message(FATAL_ERROR "check_pie_supported: language(s) '${unsupported_languages}' not supported")
endif()
@@ -97,7 +98,7 @@ function (check_pie_supported)
return()
endif()
- list (FILTER enabled_languages INCLUDE REGEX "^(C|CXX|Fortran)$")
+ list (FILTER enabled_languages INCLUDE REGEX "^(C|CXX|OBJC|OBJCXX|Fortran|CUDA|HIP)$")
if (NOT enabled_languages)
return()
endif()
@@ -105,24 +106,29 @@ function (check_pie_supported)
set (CHECK_PIE_LANGUAGES ${enabled_languages})
endif()
+ set(CMAKE_REQUIRED_QUIET TRUE)
set (outputs)
foreach(lang IN LISTS CHECK_PIE_LANGUAGES)
if(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER)
- cmake_try_compiler_or_linker_flag(${lang}
+ if(NOT DEFINED CMAKE_${lang}_LINK_PIE_SUPPORTED)
+ cmake_check_linker_flag(${lang}
"${CMAKE_${lang}_LINK_OPTIONS_PIE}"
CMAKE_${lang}_LINK_PIE_SUPPORTED
OUTPUT_VARIABLE output)
- if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED)
- string (APPEND outputs "PIE (${lang}): ${output}\n")
+ if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED)
+ string (APPEND outputs "PIE (${lang}): ${output}\n")
+ endif()
endif()
- cmake_try_compiler_or_linker_flag(${lang}
+ if(NOT DEFINED CMAKE_${lang}_LINK_NO_PIE_SUPPORTED)
+ cmake_check_linker_flag(${lang}
"${CMAKE_${lang}_LINK_OPTIONS_NO_PIE}"
CMAKE_${lang}_LINK_NO_PIE_SUPPORTED
OUTPUT_VARIABLE output)
- if (NOT CMAKE_${lang}_LINK_NO_PIE_SUPPORTED)
- string (APPEND outputs "NO_PIE (${lang}): ${output}\n")
+ if (NOT CMAKE_${lang}_LINK_NO_PIE_SUPPORTED)
+ string (APPEND outputs "NO_PIE (${lang}): ${output}\n")
+ endif()
endif()
else()
# no support at link time. Set cache variables to NO