File tree Expand file tree Collapse file tree 2 files changed +29
-10
lines changed Expand file tree Collapse file tree 2 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -186,16 +186,8 @@ string(APPEND CMAKE_CXX_LINK_EXECUTABLE " ${APPEND_LDFLAGS}")
186186
187187set (configure_warnings)
188188
189- include (CheckPIESupported)
190- check_pie_supported(OUTPUT_VARIABLE check_pie_output LANGUAGES CXX)
191- if (CMAKE_CXX_LINK_PIE_SUPPORTED)
192- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
193- elseif (NOT WIN32 )
194- # The warning is superfluous for Windows.
195- message (WARNING "PIE is not supported at link time: ${check_pie_output} " )
196- list (APPEND configure_warnings "Position independent code disabled." )
197- endif ()
198- unset (check_pie_output)
189+ include (CheckLinkerSupportsPIE)
190+ check_linker_supports_pie(configure_warnings)
199191
200192# The core_interface library aims to encapsulate common build flags.
201193# It is a usage requirement for all targets except for secp256k1, which
Original file line number Diff line number Diff line change 1+ # Copyright (c) 2024-present The Bitcoin Core developers
2+ # Distributed under the MIT software license, see the accompanying
3+ # file COPYING or https://opensource.org/license/mit/.
4+
5+ include_guard (GLOBAL )
6+
7+ function (check_linker_supports_pie warnings)
8+ # Workaround for a bug in the check_pie_supported() function.
9+ # See:
10+ # - https://gitlab.kitware.com/cmake/cmake/-/issues/26463
11+ # - https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10034
12+ if (CMAKE_VERSION VERSION_LESS 3.32)
13+ # CMAKE_CXX_COMPILE_OPTIONS_PIE is a list, whereas CMAKE_REQUIRED_FLAGS
14+ # must be a string. Therefore, a proper conversion is required.
15+ list (JOIN CMAKE_CXX_COMPILE_OPTIONS_PIE " " CMAKE_REQUIRED_FLAGS)
16+ endif ()
17+
18+ include (CheckPIESupported)
19+ check_pie_supported(OUTPUT_VARIABLE output LANGUAGES CXX)
20+ if (CMAKE_CXX_LINK_PIE_SUPPORTED)
21+ set (CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE)
22+ elseif (NOT WIN32 )
23+ # The warning is superfluous for Windows.
24+ message (WARNING "PIE is not supported at link time: ${output} " )
25+ set (${warnings} ${${warnings} } "Position independent code disabled." PARENT_SCOPE)
26+ endif ()
27+ endfunction ()
You can’t perform that action at this time.
0 commit comments