From 55fc9c4832323711142f75fd681794dea1bf022d Mon Sep 17 00:00:00 2001 From: Markus Blatt <markus@dr-blatt.de> Date: Tue, 8 Nov 2016 10:28:07 +0100 Subject: [PATCH] Allow using object libraries in conjunction with shared libs. CMake's object libraries cannot judge whether they will be used in shared libraries. To allow ease of in core and downstream modules we resort to compiling position independent code whenever shared DUNE libraries are requested. This is done by setting CMAKE_POSITION_INDEPENDENT_CODE to ON. Please not that the can be overriding manually by setting the target property POSITION_INDEPENDENT_CODE to something else where needed. --- cmake/modules/DuneMacros.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake index 42051ca74..b5a913eff 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. -- GitLab