aboutsummaryrefslogtreecommitdiff
path: root/cmake/compiler/clang/settings.cmake
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2016-03-20 00:50:21 +0100
committerNaios <naios-dev@live.de>2016-03-24 01:28:55 +0100
commitf4e0945b13a70225684e7421d9542efae6a47c89 (patch)
treefe974b35c5bd7f10be660c6b776db07d7998a9c0 /cmake/compiler/clang/settings.cmake
parent3d32fd6ce08e99bdb56d258edbeb8590c481f815 (diff)
Core/Build: Add the possibility to link libraries dynamically.
* makes it possible to access exported singletons from other shared lib's. * reduces binary size
Diffstat (limited to 'cmake/compiler/clang/settings.cmake')
-rw-r--r--cmake/compiler/clang/settings.cmake13
1 files changed, 13 insertions, 0 deletions
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()