cmake: Add CheckLinkerSupportsPIE module

This new module serves as a wrapper around CMake's `CheckPIESupported`
module and addresses an upstream bug:
- https://gitlab.kitware.com/cmake/cmake/-/issues/26463
- https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10034
This commit is contained in:
Hennadii Stepanov committed 2025-01-15 16:09:16 +00:00
1 parent 2638fdb4f9
commit 65a0920ca6
2 files changed
+29 -10

No files matched your search

+2 -10
View File
@@ -186,16 +186,8 @@ string(APPEND CMAKE_CXX_LINK_EXECUTABLE " ${APPEND_LDFLAGS}")
set(configure_warnings)
include(CheckPIESupported)
check_pie_supported(OUTPUT_VARIABLE check_pie_output LANGUAGES CXX)
if(CMAKE_CXX_LINK_PIE_SUPPORTED)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
elseif(NOT WIN32)
# The warning is superfluous for Windows.
message(WARNING "PIE is not supported at link time: ${check_pie_output}")
list(APPEND configure_warnings "Position independent code disabled.")
endif()
unset(check_pie_output)
include(CheckLinkerSupportsPIE)
check_linker_supports_pie(configure_warnings)
# The core_interface library aims to encapsulate common build flags.
# It is a usage requirement for all targets except for secp256k1, which