1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

CMake: Set LIBS on llvm-config so we can query the system libraries

used by CMake with --ldflags.

llvm-svn: 72470
This commit is contained in:
Oscar Fuentes 2009-05-27 15:49:33 +00:00
parent 15bf5ba18b
commit 72dd52b258
3 changed files with 29 additions and 11 deletions

View File

@ -30,17 +30,11 @@ macro(add_llvm_executable name)
target_link_libraries(${name} ${llvm_libs})
else( MSVC )
add_dependencies(${name} llvm-config.target)
if( MINGW )
target_link_libraries(${name} imagehlp psapi)
elseif( CMAKE_HOST_UNIX )
if( HAVE_LIBDL )
target_link_libraries(${name} dl)
endif()
if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
target_link_libraries(${name} pthread)
endif()
endif( MINGW )
endif( MSVC )
get_system_libs(llvm_system_libs)
if( llvm_system_libs )
target_link_libraries(${name} ${llvm_system_libs})
endif()
endmacro(add_llvm_executable name)

View File

@ -1,5 +1,24 @@
include(FindPerl)
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} dl)
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)
macro(llvm_config executable)
# extra args is the list of link components.
if( MSVC )

View File

@ -28,6 +28,11 @@ set(SHLIBEXT ${LTDL_SHLIB_EXT})
set(OS "${CMAKE_SYSTEM}")
set(ARCH "X86") # TODO: This gives "i686" in Linux: "${CMAKE_SYSTEM_PROCESSOR}")
get_system_libs(LLVM_SYSTEM_LIBS_LIST)
foreach(l ${LLVM_SYSTEM_LIBS_LIST})
set(LLVM_SYSTEM_LIBS ${LLVM_SYSTEM_LIBS} "-l${l}")
endforeach()
include(GetTargetTriple)
get_target_triple(target)
@ -93,7 +98,7 @@ add_custom_command(OUTPUT ${LLVM_CONFIG}
COMMAND echo 's!@LLVM_CXXFLAGS@!${CXX_FLGS}!' >> temp.sed
# TODO: Use general flags for linking! not just for shared libs:
COMMAND echo 's!@LLVM_LDFLAGS@!${CMAKE_SHARED_LINKER_FLAGS}!' >> temp.sed
COMMAND echo 's!@LIBS@!!' >> temp.sed # TODO: System libs
COMMAND echo 's!@LIBS@!${LLVM_SYSTEM_LIBS}!' >> temp.sed
COMMAND echo 's!@LLVM_BUILDMODE@!${CMAKE_BUILD_TYPE}!' >> temp.sed
COMMAND sed -f temp.sed < ${LLVM_CONFIG_IN} > ${LLVM_CONFIG}
COMMAND ${CMAKE_COMMAND} -E remove -f temp.sed