Skip to content

Commit

Permalink
Attempt to use CMAKE_DEPENDENT_OPTION
Browse files Browse the repository at this point in the history
  • Loading branch information
fsfod committed Aug 14, 2024
1 parent 4cc7b41 commit 94cbc38
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -839,34 +841,36 @@ 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()
else()
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)
Expand Down

0 comments on commit 94cbc38

Please sign in to comment.