Refactor duplicated code for linking with pthread.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 1 Mar 2016 15:54:40 +0000 (15:54 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 1 Mar 2016 15:54:40 +0000 (15:54 +0000)
llvm-svn: 262344

llvm/cmake/config-ix.cmake
llvm/examples/ParallelJIT/CMakeLists.txt
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
llvm/lib/Fuzzer/CMakeLists.txt
llvm/lib/Support/CMakeLists.txt
llvm/unittests/Support/CMakeLists.txt

index c5be442..86a106d 100755 (executable)
@@ -107,6 +107,10 @@ if( NOT PURE_WINDOWS )
   check_library_exists(rt clock_gettime "" HAVE_LIBRT)
 endif()
 
+if(HAVE_LIBPTHREAD)
+  set(PTHREAD_LIB pthread)
+endif()
+
 # Don't look for these libraries on Windows. Also don't look for them if we're
 # using MSan, since uninstrmented third party code may call MSan interceptors
 # like strlen, leading to false positives.
index 07c0a08..e85b470 100644 (file)
@@ -11,6 +11,4 @@ add_llvm_example(ParallelJIT
   ParallelJIT.cpp
   )
 
-if(HAVE_LIBPTHREAD)
-  target_link_libraries(ParallelJIT pthread)
-endif(HAVE_LIBPTHREAD)
+target_link_libraries(ParallelJIT ${PTHREAD_LIB})
index de6d21d..6ebde1a 100644 (file)
@@ -1,8 +1,3 @@
-set(system_libs)
-if(CMAKE_HOST_UNIX AND LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD)
-  set(system_libs ${system_libs} pthread)
-endif()
-
 add_llvm_library(LLVMCodeGen
   AggressiveAntiDepBreaker.cpp
   AllocationOrder.cpp
@@ -135,7 +130,7 @@ add_llvm_library(LLVMCodeGen
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen/PBQP
 
-  LINK_LIBS ${system_libs}
+  LINK_LIBS ${PTHREAD_LIB}
   )
 
 add_dependencies(LLVMCodeGen intrinsics_gen)
index 65f2a2f..3b8c4b9 100644 (file)
@@ -3,9 +3,9 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
 if( HAVE_LIBDL )
     set(LLVM_INTEL_JIT_LIBS ${CMAKE_DL_LIBS})
 endif()
-if( HAVE_LIBPTHREAD )
-    set(LLVM_INTEL_JIT_LIBS pthread ${LLVM_INTEL_JIT_LIBS})
-endif()
+
+set(LLVM_INTEL_JIT_LIBS ${PTHREAD_LIB} ${LLVM_INTEL_JIT_LIBS})
+
 
 add_llvm_library(LLVMIntelJITEvents
   IntelJITEventListener.cpp
index eeae511..3fae903 100644 (file)
@@ -18,16 +18,12 @@ if( LLVM_USE_SANITIZE_COVERAGE )
   add_library(LLVMFuzzerNoMain STATIC
     $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
     )
-  if( HAVE_LIBPTHREAD )
-    target_link_libraries(LLVMFuzzerNoMain pthread)
-  endif()
+  target_link_libraries(LLVMFuzzerNoMain ${PTHREAD_LIB})
   add_library(LLVMFuzzer STATIC
     FuzzerMain.cpp
     $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
     )
-  if( HAVE_LIBPTHREAD )
-    target_link_libraries(LLVMFuzzer pthread)
-  endif()
+  target_link_libraries(LLVMFuzzer ${PTHREAD_LIB})
 
   if( LLVM_INCLUDE_TESTS )
     add_subdirectory(test)
index bccbdfc..d14d7d3 100644 (file)
@@ -17,9 +17,7 @@ elseif( CMAKE_HOST_UNIX )
   if( LLVM_ENABLE_THREADS AND HAVE_LIBATOMIC )
     set(system_libs ${system_libs} atomic)
   endif()
-  if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
-    set(system_libs ${system_libs} pthread)
-  endif()
+  set(system_libs ${system_libs} ${PTHREAD_LIB})
   if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
     set(system_libs ${system_libs} z)
   endif()
index 607b92e..690a2e3 100644 (file)
@@ -53,6 +53,4 @@ add_llvm_unittest(SupportTests
   )
 
 # ManagedStatic.cpp uses <pthread>.
-if(LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD)
-  target_link_libraries(SupportTests pthread)
-endif()
+target_link_libraries(SupportTests ${PTHREAD_LIB})