diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake index 42051ca74822fd90183270f9d72446e69d98d9e2..b5a913effcaf6ca43e78beb3f79b58a9dd3e4ce6 100644 --- a/cmake/modules/DuneMacros.cmake +++ b/cmake/modules/DuneMacros.cmake @@ -659,6 +659,14 @@ macro(dune_project) option(DUNE_BUILD_BOTH_LIBS "If set to ON, shared and static libs will be built" ${_default_enable_static}) + # As default request position independent code if shared libraries are built + # This should allow DUNE modules to use CMake's object libraries. + # This can be overwritten for targets by setting the target property + # POSITION_INDEPENDENT_CODE to false/OFF + if(BUILD_SHARED_LIBS) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + endif() + if(DUNE_USE_ONLY_STATIC_LIBS) # Use only static libraries. # We do this by overriding the library suffixes.