Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -115,7 +115,7 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_HAVE_PTHREAD_ARG Off) find_package(Threads REQUIRED) - set(PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT}) + set(LLVM_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT}) endif() # Don't look for these libraries on Windows. Also don't look for them if we're Index: cmake/modules/AddLLVM.cmake =================================================================== --- cmake/modules/AddLLVM.cmake +++ cmake/modules/AddLLVM.cmake @@ -718,11 +718,11 @@ if(NOT ARG_IGNORE_EXTERNALIZE_DEBUGINFO) llvm_externalize_debuginfo(${name}) endif() - if (PTHREAD_LIB) + if (LLVM_PTHREAD_LIB) # libpthreads overrides some standard library symbols, so main # executable must be linked with it in order to provide consistent # API for all shared libaries loaded by this executable. - target_link_libraries(${name} ${PTHREAD_LIB}) + target_link_libraries(${name} ${LLVM_PTHREAD_LIB}) endif() endmacro(add_llvm_executable name) @@ -1027,7 +1027,7 @@ # libpthreads overrides some standard library symbols, so main # executable must be linked with it in order to provide consistent # API for all shared libaries loaded by this executable. - target_link_libraries(${test_name} gtest_main gtest ${PTHREAD_LIB}) + target_link_libraries(${test_name} gtest_main gtest ${LLVM_PTHREAD_LIB}) add_dependencies(${test_suite} ${test_name}) get_target_property(test_suite_folder ${test_suite} FOLDER) Index: cmake/modules/LLVMConfig.cmake.in =================================================================== --- cmake/modules/LLVMConfig.cmake.in +++ cmake/modules/LLVMConfig.cmake.in @@ -45,6 +45,10 @@ set(LLVM_BUILD_32_BITS @LLVM_BUILD_32_BITS@) +if (NOT "@LLVM_PTHREAD_LIB@" STREQUAL "") + set(LLVM_PTHREAD_LIB "@LLVM_PTHREAD_LIB@") +endif() + set(LLVM_ENABLE_PLUGINS @LLVM_ENABLE_PLUGINS@) set(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS @LLVM_EXPORT_SYMBOLS_FOR_PLUGINS@) set(LLVM_PLUGIN_EXT @LLVM_PLUGIN_EXT@) Index: examples/ParallelJIT/CMakeLists.txt =================================================================== --- examples/ParallelJIT/CMakeLists.txt +++ examples/ParallelJIT/CMakeLists.txt @@ -11,4 +11,4 @@ ParallelJIT.cpp ) -target_link_libraries(ParallelJIT ${PTHREAD_LIB}) +target_link_libraries(ParallelJIT ${LLVM_PTHREAD_LIB}) Index: lib/CodeGen/CMakeLists.txt =================================================================== --- lib/CodeGen/CMakeLists.txt +++ lib/CodeGen/CMakeLists.txt @@ -150,7 +150,7 @@ ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen/PBQP - LINK_LIBS ${PTHREAD_LIB} + LINK_LIBS ${LLVM_PTHREAD_LIB} DEPENDS intrinsics_gen Index: lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt =================================================================== --- lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt +++ lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt @@ -4,7 +4,7 @@ set(LLVM_INTEL_JIT_LIBS ${CMAKE_DL_LIBS}) endif() -set(LLVM_INTEL_JIT_LIBS ${PTHREAD_LIB} ${LLVM_INTEL_JIT_LIBS}) +set(LLVM_INTEL_JIT_LIBS ${LLVM_PTHREAD_LIB} ${LLVM_INTEL_JIT_LIBS}) add_llvm_library(LLVMIntelJITEvents Index: lib/Fuzzer/CMakeLists.txt =================================================================== --- lib/Fuzzer/CMakeLists.txt +++ lib/Fuzzer/CMakeLists.txt @@ -33,12 +33,12 @@ add_library(LLVMFuzzerNoMain STATIC $ ) - target_link_libraries(LLVMFuzzerNoMain ${PTHREAD_LIB}) + target_link_libraries(LLVMFuzzerNoMain ${LLVM_PTHREAD_LIB}) add_library(LLVMFuzzer STATIC FuzzerMain.cpp $ ) - target_link_libraries(LLVMFuzzer ${PTHREAD_LIB}) + target_link_libraries(LLVMFuzzer ${LLVM_PTHREAD_LIB}) if( LLVM_INCLUDE_TESTS ) add_subdirectory(test) Index: lib/Support/CMakeLists.txt =================================================================== --- lib/Support/CMakeLists.txt +++ lib/Support/CMakeLists.txt @@ -17,7 +17,7 @@ if( LLVM_ENABLE_THREADS AND HAVE_LIBATOMIC ) set(system_libs ${system_libs} atomic) endif() - set(system_libs ${system_libs} ${PTHREAD_LIB}) + set(system_libs ${system_libs} ${LLVM_PTHREAD_LIB}) if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ ) set(system_libs ${system_libs} z) endif() Index: unittests/ExecutionEngine/Orc/CMakeLists.txt =================================================================== --- unittests/ExecutionEngine/Orc/CMakeLists.txt +++ unittests/ExecutionEngine/Orc/CMakeLists.txt @@ -21,4 +21,4 @@ RPCUtilsTest.cpp ) -target_link_libraries(OrcJITTests ${PTHREAD_LIB}) +target_link_libraries(OrcJITTests ${LLVM_PTHREAD_LIB}) Index: unittests/Support/CMakeLists.txt =================================================================== --- unittests/Support/CMakeLists.txt +++ unittests/Support/CMakeLists.txt @@ -64,4 +64,4 @@ ) # ManagedStatic.cpp uses . -target_link_libraries(SupportTests ${PTHREAD_LIB}) +target_link_libraries(SupportTests ${LLVM_PTHREAD_LIB}) Index: utils/unittest/CMakeLists.txt =================================================================== --- utils/unittest/CMakeLists.txt +++ utils/unittest/CMakeLists.txt @@ -40,8 +40,8 @@ add_definitions( -DGTEST_HAS_PTHREAD=0 ) endif() -find_library(PTHREAD_LIBRARY_PATH pthread) -if (PTHREAD_LIBRARY_PATH) +find_library(LLVM_PTHREAD_LIBRARY_PATH pthread) +if (LLVM_PTHREAD_LIBRARY_PATH) list(APPEND LIBS pthread) endif()