diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1610,6 +1610,8 @@ endif() endif() + target_link_options(${test_name} PRIVATE "${LLVM_UNITTEST_LINK_FLAGS}") + set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir}) # libpthreads overrides some standard library symbols, so main diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -1317,6 +1317,9 @@ set(LLVM_THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../third-party CACHE STRING "Directory containing third party software used by LLVM (e.g. googletest)") +set(LLVM_UNITTEST_LINK_FLAGS "" CACHE STRING + "Additional linker flags for unit tests") + if(LLVM_ENABLE_LLVM_LIBC) check_library_exists(llvmlibc printf "" HAVE_LLVM_LIBC) if(NOT HAVE_LLVM_LIBC)