Skip to content

Commit b41b990

Browse files
committed
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. llvm-svn: 279743
1 parent 606b06a commit b41b990

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

polly/CMakeLists.txt

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,10 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
2121
include_directories(${LLVM_INSTALL_ROOT}/include/)
2222

2323
# Get the system librarys that will link into LLVM.
24-
function(get_system_libs return_var)
25-
# Returns in `return_var' a list of system libraries used by LLVM.
26-
if( NOT MSVC )
27-
if( MINGW )
28-
set(system_libs ${system_libs} imagehlp psapi)
29-
elseif( CMAKE_HOST_UNIX )
30-
if( HAVE_LIBDL )
31-
set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
32-
endif()
33-
if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
34-
set(system_libs ${system_libs} pthread)
35-
endif()
36-
endif( MINGW )
37-
endif( NOT MSVC )
38-
set(${return_var} ${system_libs} PARENT_SCOPE)
39-
endfunction(get_system_libs)
24+
execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --system-libs
25+
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
26+
OUTPUT_STRIP_TRAILING_WHITESPACE)
27+
message(STATUS "System libs required by LLVM: ${LLVM_SYSTEM_LIBS}")
4028

4129
# Determine where LLVM stores its libraries.
4230
execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --libdir
@@ -100,9 +88,7 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
10088
if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
10189
add_library(gtest ${UNITTEST_DIR}/googletest/src/gtest-all.cc)
10290
target_include_directories(gtest PUBLIC "${UNITTEST_DIR}/googletest/include" PRIVATE "${UNITTEST_DIR}/googletest")
103-
if( NOT MSVC )
104-
target_link_libraries(gtest pthread tinfo dl)
105-
endif ()
91+
target_link_libraries(gtest ${LLVM_SYSTEM_LIBS})
10692

10793
add_library(gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp)
10894
target_link_libraries(gtest_main gtest)

0 commit comments

Comments
 (0)