[llvm] Initial changes for llvm shared library build using explicit visibility annotations (PR #96630)
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 15:11:40 PDT 2024
================
@@ -839,20 +841,36 @@ endif()
if(MSVC)
option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" ON)
- # Set this variable to OFF here so it can't be set with a command-line
- # argument.
- set (LLVM_LINK_LLVM_DYLIB OFF)
if (BUILD_SHARED_LIBS)
message(FATAL_ERROR "BUILD_SHARED_LIBS options is not supported on Windows.")
endif()
-else()
- option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF)
+ else()
option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF)
- set(LLVM_BUILD_LLVM_DYLIB_default OFF)
- if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
- set(LLVM_BUILD_LLVM_DYLIB_default ON)
- endif()
- option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default})
+endif()
+
+set(CAN_BUILD_LLVM_DYLIB Off)
+if(NOT MSVC OR LLVM_BUILD_LLVM_DYLIB_VIS)
+ set(CAN_BUILD_LLVM_DYLIB On)
+endif()
+
+CMAKE_DEPENDENT_OPTION(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF
+ "CAN_BUILD_LLVM_DYLIB" OFF)
+
+set(LLVM_BUILD_LLVM_DYLIB_default OFF)
+if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
+ set(LLVM_BUILD_LLVM_DYLIB_default ON)
+endif()
+CMAKE_DEPENDENT_OPTION(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default}
+ "CAN_BUILD_LLVM_DYLIB" OFF)
+
+CMAKE_DEPENDENT_OPTION(LLVM_DYLIB_EXPORT_INLINES "Force inline members of classes to be DLL exported when
+ building with clang-cl so the libllvm DLL is compatible with MSVC"
+ OFF
+ "MSVC;LLVM_BUILD_LLVM_DYLIB_VIS" OFF)
----------------
petrhosek wrote:
We prefer lowercase spelling for CMake function.
```suggestion
cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF
"CAN_BUILD_LLVM_DYLIB" OFF)
set(LLVM_BUILD_LLVM_DYLIB_default OFF)
if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
set(LLVM_BUILD_LLVM_DYLIB_default ON)
endif()
cmake_dependent_option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default}
"CAN_BUILD_LLVM_DYLIB" OFF)
cmake_dependent_option(LLVM_DYLIB_EXPORT_INLINES "Force inline members of classes to be DLL exported when
building with clang-cl so the libllvm DLL is compatible with MSVC"
OFF
"MSVC;LLVM_BUILD_LLVM_DYLIB_VIS" OFF)
```
https://github.com/llvm/llvm-project/pull/96630
More information about the llvm-commits
mailing list