diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 3669026d5325ca..1ed05adf95724f 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.20.0) +include(CMakeDependentOption) + set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake NO_POLICY_SCOPE) @@ -839,11 +841,6 @@ endif() if(MSVC) option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" ON) - if(NOT LLVM_BUILD_LLVM_DYLIB_VIS) - # Set this variable to OFF here so it can't be set with a command-line - # argument. - set (LLVM_LINK_LLVM_DYLIB OFF) - endif() if (BUILD_SHARED_LIBS) message(FATAL_ERROR "BUILD_SHARED_LIBS options is not supported on Windows.") endif() @@ -851,22 +848,29 @@ if(MSVC) option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF) endif() +set(CAN_BUILD_LLVM_DYLIB Off) if(NOT MSVC OR LLVM_BUILD_LLVM_DYLIB_VIS) - option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" 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}) + 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) # Build llvm dynamic library with explicit symbol visibility on windows and default hidden symbol visibility on Linux if(LLVM_BUILD_LLVM_DYLIB_VIS) set(LLVM_BUILD_LLVM_DYLIB ON) - if(MSVC) - option(LLVM_DYLIB_EXPORT_INLINES "Force inline members of class to be dll exported when - building with clang-cl so the libllvm dll is compatible with MSVC" OFF) - endif() endif() if (LLVM_LINK_LLVM_DYLIB AND BUILD_SHARED_LIBS)