Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -86,6 +86,10 @@ ) endif() +# Detect libraries needed to use std::thread. This seems to be necessary for +# LLVM_ENABLE_THREADS=OFF too. +find_package(Threads) + add_subdirectory(lib) add_subdirectory(tools) Index: COFF/CMakeLists.txt =================================================================== --- COFF/CMakeLists.txt +++ COFF/CMakeLists.txt @@ -27,6 +27,8 @@ Target Option Support + LINK_LIBS + ${CMAKE_THREAD_LIBS_INIT} ) add_dependencies(lldCOFF COFFOptionsTableGen) Index: lib/Driver/CMakeLists.txt =================================================================== --- lib/Driver/CMakeLists.txt +++ lib/Driver/CMakeLists.txt @@ -34,6 +34,7 @@ LLVMObject LLVMOption LLVMSupport + ${CMAKE_THREAD_LIBS_INIT} ) add_dependencies(lldDriver DriverOptionsTableGen) Index: lib/ReaderWriter/CMakeLists.txt =================================================================== --- lib/ReaderWriter/CMakeLists.txt +++ lib/ReaderWriter/CMakeLists.txt @@ -15,4 +15,5 @@ lldYAML LLVMObject LLVMSupport + ${CMAKE_THREAD_LIBS_INIT} ) Index: lib/ReaderWriter/ELF/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/CMakeLists.txt +++ lib/ReaderWriter/ELF/CMakeLists.txt @@ -17,6 +17,7 @@ lldYAML LLVMObject LLVMSupport + ${CMAKE_THREAD_LIBS_INIT} ) include_directories(.) Index: lib/ReaderWriter/MachO/CMakeLists.txt =================================================================== --- lib/ReaderWriter/MachO/CMakeLists.txt +++ lib/ReaderWriter/MachO/CMakeLists.txt @@ -22,6 +22,7 @@ lldYAML LLVMObject LLVMSupport + ${CMAKE_THREAD_LIBS_INIT} ) include_directories(.) Index: unittests/CMakeLists.txt =================================================================== --- unittests/CMakeLists.txt +++ unittests/CMakeLists.txt @@ -7,7 +7,9 @@ # Produces a binary named 'basename(test_dirname)'. function(add_lld_unittest test_dirname) add_unittest(LLDUnitTests ${test_dirname} ${ARGN}) - target_link_libraries(${test_dirname} ${LLVM_COMMON_LIBS}) + target_link_libraries(${test_dirname} + ${LLVM_COMMON_LIBS} + ${CMAKE_THREAD_LIBS_INIT}) endfunction() add_subdirectory(CoreTests)