aboutsummaryrefslogtreecommitdiff
path: root/cmake/compiler/clang
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 02:38:54 +0100
commit2613413608337d61994503df0e2d9ed05d3c4ee4 (patch)
treec560bb1832b8a9aa13837dd662bfb9fa514475f4 /cmake/compiler/clang
parentf37682b7edd0d711e1120cbdd9d627fb5b9dbde1 (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 (cherry picked from commit f4e0945b13a70225684e7421d9542efae6a47c89)
Diffstat (limited to 'cmake/compiler/clang')
-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()