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
This commit is contained in:
Michael Kruse 2016-08-25 14:58:29 +00:00
parent 606b06a156
commit b41b990e05
1 changed files with 5 additions and 19 deletions

View File

@ -21,22 +21,10 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
include_directories(${LLVM_INSTALL_ROOT}/include/) include_directories(${LLVM_INSTALL_ROOT}/include/)
# Get the system librarys that will link into LLVM. # Get the system librarys that will link into LLVM.
function(get_system_libs return_var) execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --system-libs
# Returns in `return_var' a list of system libraries used by LLVM. OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
if( NOT MSVC ) OUTPUT_STRIP_TRAILING_WHITESPACE)
if( MINGW ) message(STATUS "System libs required by LLVM: ${LLVM_SYSTEM_LIBS}")
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)
# Determine where LLVM stores its libraries. # Determine where LLVM stores its libraries.
execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --libdir 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) if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
add_library(gtest ${UNITTEST_DIR}/googletest/src/gtest-all.cc) add_library(gtest ${UNITTEST_DIR}/googletest/src/gtest-all.cc)
target_include_directories(gtest PUBLIC "${UNITTEST_DIR}/googletest/include" PRIVATE "${UNITTEST_DIR}/googletest") target_include_directories(gtest PUBLIC "${UNITTEST_DIR}/googletest/include" PRIVATE "${UNITTEST_DIR}/googletest")
if( NOT MSVC ) target_link_libraries(gtest ${LLVM_SYSTEM_LIBS})
target_link_libraries(gtest pthread tinfo dl)
endif ()
add_library(gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp) add_library(gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp)
target_link_libraries(gtest_main gtest) target_link_libraries(gtest_main gtest)