From f4e0945b13a70225684e7421d9542efae6a47c89 Mon Sep 17 00:00:00 2001 From: Naios Date: Sun, 20 Mar 2016 00:50:21 +0100 Subject: Core/Build: Add the possibility to link libraries dynamically. * makes it possible to access exported singletons from other shared lib's. * reduces binary size --- cmake/compiler/clang/settings.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'cmake/compiler/clang/settings.cmake') diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake index 261a55b285f..9a8cb85275e 100644 --- a/cmake/compiler/clang/settings.cmake +++ b/cmake/compiler/clang/settings.cmake @@ -18,3 +18,16 @@ endif() # -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-narrowing -Wno-deprecated-register") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1") + +if (WITH_DYNAMIC_LINKING) + # -fPIC is needed to allow static linking in shared libs. + # -fvisibility=hidden sets the default visibility to hidden to prevent exporting of all symbols. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden") + + # --no-undefined to throw errors when there are undefined symbols + # (caused through missing TRINITY_*_API macros). + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --no-undefined") + + message(STATUS "Clang: Disallow undefined symbols") +endif() -- cgit v1.2.3