[llvm] 76de2f4 - CMake: allow overriding CMAKE_CXX_VISIBILITY_PRESET

Wenlei He via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 15 15:58:02 PDT 2021


Author: Wenlei He
Date: 2021-06-15T15:51:18-07:00
New Revision: 76de2f4a9c023d06717536ccb089f9959c4ef4bb

URL: https://github.com/llvm/llvm-project/commit/76de2f4a9c023d06717536ccb089f9959c4ef4bb
DIFF: https://github.com/llvm/llvm-project/commit/76de2f4a9c023d06717536ccb089f9959c4ef4bb.diff

LOG: 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

Added: 
    

Modified: 
    llvm/lib/Target/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/CMakeLists.txt b/llvm/lib/Target/CMakeLists.txt
index e87ccde22c12..417fd83c9a72 100644
--- a/llvm/lib/Target/CMakeLists.txt
+++ b/llvm/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)


        


More information about the llvm-commits mailing list