[polly] r279743 - Query llvm-config to get system libs required for linking.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 07:58:30 PDT 2016


Author: meinersbur
Date: Thu Aug 25 09:58:29 2016
New Revision: 279743

URL: http://llvm.org/viewvc/llvm-project?rev=279743&view=rev
Log:
Query llvm-config to get system libs required for linking.

Remove the unused function get_system_libs. Instead, run
'llvm-config --system-libs' to determine which libraries are required in
addition LLVM's for linking an executable. At the moment these are the unittests
that link to gtest and transitively depend on these system libs.

Modified:
    polly/trunk/CMakeLists.txt

Modified: polly/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/CMakeLists.txt?rev=279743&r1=279742&r2=279743&view=diff
==============================================================================
--- polly/trunk/CMakeLists.txt (original)
+++ polly/trunk/CMakeLists.txt Thu Aug 25 09:58:29 2016
@@ -21,22 +21,10 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   include_directories(${LLVM_INSTALL_ROOT}/include/)
 
   # Get the system librarys that will link into LLVM.
-  function(get_system_libs return_var)
-    # Returns in `return_var' a list of system libraries used by LLVM.
-    if( NOT MSVC )
-      if( MINGW )
-        set(system_libs ${system_libs} imagehlp psapi)
-      elseif( CMAKE_HOST_UNIX )
-        if( HAVE_LIBDL )
-          set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
-        endif()
-        if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
-          set(system_libs ${system_libs} pthread)
-        endif()
-      endif( MINGW )
-    endif( NOT MSVC )
-    set(${return_var} ${system_libs} PARENT_SCOPE)
-  endfunction(get_system_libs)
+  execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --system-libs
+                  OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+  message(STATUS "System libs required by LLVM: ${LLVM_SYSTEM_LIBS}")
 
   # Determine where LLVM stores its libraries.
   execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --libdir
@@ -100,9 +88,7 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
     add_library(gtest ${UNITTEST_DIR}/googletest/src/gtest-all.cc)
     target_include_directories(gtest PUBLIC "${UNITTEST_DIR}/googletest/include" PRIVATE "${UNITTEST_DIR}/googletest")
-    if( NOT MSVC )
-      target_link_libraries(gtest pthread tinfo dl)
-    endif ()
+    target_link_libraries(gtest ${LLVM_SYSTEM_LIBS})
 
     add_library(gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp)
     target_link_libraries(gtest_main gtest)




More information about the llvm-commits mailing list