From 9c4bdc1168aca8e878833a5b6ee42e8caa06a70a Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 29 Mar 2023 13:01:27 -0500 Subject: [PATCH] CMake: set POSITION_INDEPENDENT_CODE compiler variable --- cmake/macros/macro_populate_target_properties.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmake/macros/macro_populate_target_properties.cmake b/cmake/macros/macro_populate_target_properties.cmake index 7e3572b649..255398e8d0 100644 --- a/cmake/macros/macro_populate_target_properties.cmake +++ b/cmake/macros/macro_populate_target_properties.cmake @@ -87,6 +87,18 @@ function(populate_target_properties _target _build) ${DEAL_II_DEFINITIONS} ${DEAL_II_DEFINITIONS_${_build}} ) + # + # Add target properties: + # + # - set POSITION_INDEPENDENT_CODE to true to compile everything with + # the -fpic/-fPIC compiler flag. This ensures that we can link all + # object targets into a relocatable library at the end. + # + + set_target_properties(${_target} PROPERTIES + POSITION_INDEPENDENT_CODE TRUE + ) + # # Add compile and link options with private scope, and add the link # interface: -- 2.39.5