[llvm-commits] [llvm] r72470 - in /llvm/trunk: cmake/modules/AddLLVM.cmake cmake/modules/LLVMConfig.cmake tools/llvm-config/CMakeLists.txt
Oscar Fuentes
ofv at wanadoo.es
Wed May 27 08:49:39 PDT 2009
Author: ofv
Date: Wed May 27 10:49:33 2009
New Revision: 72470
URL: http://llvm.org/viewvc/llvm-project?rev=72470&view=rev
Log:
CMake: Set LIBS on llvm-config so we can query the system libraries
used by CMake with --ldflags.
Modified:
llvm/trunk/cmake/modules/AddLLVM.cmake
llvm/trunk/cmake/modules/LLVMConfig.cmake
llvm/trunk/tools/llvm-config/CMakeLists.txt
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=72470&r1=72469&r2=72470&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Wed May 27 10:49:33 2009
@@ -30,17 +30,11 @@
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)
Modified: llvm/trunk/cmake/modules/LLVMConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfig.cmake?rev=72470&r1=72469&r2=72470&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/LLVMConfig.cmake (original)
+++ llvm/trunk/cmake/modules/LLVMConfig.cmake Wed May 27 10:49:33 2009
@@ -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 )
Modified: llvm/trunk/tools/llvm-config/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/CMakeLists.txt?rev=72470&r1=72469&r2=72470&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-config/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-config/CMakeLists.txt Wed May 27 10:49:33 2009
@@ -28,6 +28,11 @@
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 @@
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
More information about the llvm-commits
mailing list