diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt index ef4cfa3acdb59..c64bf3e90fcd4 100644 --- a/llvm/cmake/modules/CMakeLists.txt +++ b/llvm/cmake/modules/CMakeLists.txt @@ -80,11 +80,6 @@ if (LLVM_BUILD_UTILS) endif() endif() -if (LLVM_LINK_LLVM_DYLIB) - set(LLVM_CONFIG_LINK_LLVM_DYLIB - "set(LLVM_LINK_LLVM_DYLIB ${LLVM_LINK_LLVM_DYLIB})") -endif() - # We need to use the full path to the LLVM Exports file to make sure we get the # one from the build tree. This is due to our cmake files being split between # this source dir and the binary dir in the build tree configuration and the diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in index 5ccc66b8039bf..1fe78238644c4 100644 --- a/llvm/cmake/modules/LLVMConfig.cmake.in +++ b/llvm/cmake/modules/LLVMConfig.cmake.in @@ -22,7 +22,11 @@ set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@) set(LLVM_AVAILABLE_LIBS @LLVM_AVAILABLE_LIBS@) -@LLVM_CONFIG_LINK_LLVM_DYLIB@ +# By only exporting the setting if it was not yet defined, out-of-tree +# clients get the correct default, but may still choose if they can. +if(@LLVM_LINK_LLVM_DYLIB@ AND NOT DEFINED LLVM_LINK_LLVM_DYLIB) + set(LLVM_LINK_LLVM_DYLIB @LLVM_LINK_LLVM_DYLIB@) +endif() set(LLVM_DYLIB_COMPONENTS @LLVM_DYLIB_COMPONENTS@)