From 5b18faff1a0e27e7c8e8744c16945b5059115f67 Mon Sep 17 00:00:00 2001 From: Wenlei He Date: Tue, 15 Jun 2021 15:50:52 -0700 Subject: [PATCH] CMake: allow overriding CMAKE_CXX_VISIBILITY_PRESET This allows overriding the `CMAKE_CXX_VISIBILITY_PRESET` on the command line. For example, setting the value to `default` lets PIC LLVM static libraries be converted to DSOs, without the need to rebuild LLVM with BUILD_SHARED_LIBS=ON. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D104168 --- lib/Target/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Target/CMakeLists.txt b/lib/Target/CMakeLists.txt index e87ccde22c1..417fd83c9a7 100644 --- a/lib/Target/CMakeLists.txt +++ b/lib/Target/CMakeLists.txt @@ -21,7 +21,8 @@ add_llvm_component_library(LLVMTarget # When building shared objects for each target there are some internal APIs # that are used across shared objects which we can't hide. -if (NOT BUILD_SHARED_LIBS AND NOT APPLE) +if (NOT BUILD_SHARED_LIBS AND NOT APPLE AND + NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) # Set default visibility to hidden, so we don't export all the Target classes # in libLLVM.so. set(CMAKE_CXX_VISIBILITY_PRESET hidden)