summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorOscar Fuentes <ofv@wanadoo.es>2009-05-27 15:49:33 +0000
committerOscar Fuentes <ofv@wanadoo.es>2009-05-27 15:49:33 +0000
commit1a53cbfb4a532511633ad752fcf7396a79857e98 (patch)
tree38f7a3cad6ac8c3eed2a48fcc576a1406ba88295 /cmake
parentb5da3f6f98b28afc0c62572c164ffccb4004827f (diff)
downloadllvm-1a53cbfb4a532511633ad752fcf7396a79857e98.tar.gz
llvm-1a53cbfb4a532511633ad752fcf7396a79857e98.tar.bz2
llvm-1a53cbfb4a532511633ad752fcf7396a79857e98.tar.xz
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
Diffstat (limited to 'cmake')
-rwxr-xr-xcmake/modules/AddLLVM.cmake14
-rwxr-xr-xcmake/modules/LLVMConfig.cmake19
2 files changed, 23 insertions, 10 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 1f0ff74c12..c531298a30 100755
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -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)
diff --git a/cmake/modules/LLVMConfig.cmake b/cmake/modules/LLVMConfig.cmake
index 63f9ded19f..9776fb05d2 100755
--- a/cmake/modules/LLVMConfig.cmake
+++ b/cmake/modules/LLVMConfig.cmake
@@ -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 )