aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2024-01-09 17:25:47 +0000
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2024-08-16 19:27:36 +0100
commitfd72d00ffe34c84e292b305f6797201040d31a72 (patch)
tree3ce00aebe4de37172df06085c43105c883d5eda2 /CMakeLists.txt
parent07069e2bb0bbdacf16cf34efd3a33390de030217 (diff)
downloadbitcoin-fd72d00ffe34c84e292b305f6797201040d31a72.tar.xz
cmake: Add position independent code support
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c83850f992..f03b5d6505 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,6 +63,17 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module)
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)
+
# The core_interface library aims to encapsulate common build flags.
# It is a usage requirement for all targets except for secp256k1, which
# gets its flags by other means.