From: Matthias Maier Date: Wed, 29 Mar 2023 18:01:27 +0000 (-0500) Subject: CMake: set POSITION_INDEPENDENT_CODE compiler variable X-Git-Tag: v9.5.0-rc1~399^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c4bdc1168aca8e878833a5b6ee42e8caa06a70a;p=dealii.git CMake: set POSITION_INDEPENDENT_CODE compiler variable --- 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: