mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
CMake: Set LIBS on llvm-config so we can query the system libraries
used by CMake with --ldflags. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72470 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b5da3f6f98
commit
1a53cbfb4a
@ -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)
|
||||
|
||||
|
||||
|
@ -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 )
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user