summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2014-02-23 06:27:04 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2014-02-23 06:27:04 +0000
commit043cc54d6c9dedaa6e5316fe5be02f97f16d5d2b (patch)
tree911d252e31fb6d80081baecd236f30f8177e2c7a /cmake
parentbe66089390c5692f7a9d80e8832996f2d8fdc8c0 (diff)
downloadllvm-043cc54d6c9dedaa6e5316fe5be02f97f16d5d2b.tar.gz
llvm-043cc54d6c9dedaa6e5316fe5be02f97f16d5d2b.tar.bz2
llvm-043cc54d6c9dedaa6e5316fe5be02f97f16d5d2b.tar.xz
Simplify linking to system libraries
The LLVMSupport library implementation consolidates all dependencies on system libraries. Move the logic gathering system libraries out of 'cmake/modules/LLVM-Config.cmake' and into 'lib/Support/CMakeLists.txt'. Use the target_link_libraries() command there to tell CMake about the link dependencies of the LLVMSupport implementation. CMake will automatically propagate this to all targets that link LLVMSupport directly or indirectly. We still need to build knowledge of system library dependencies into 'llvm-config'. Store the list of libraries needed in a property on LLVMSupport and teach 'tools/llvm-config/CMakeLists.txt' to retrieve it from there. Drop all calls to 'link_system_libs' and 'get_system_libs' from our CMake code. Replace their implementations with a warning that explains the calls are no longer necessary. Also drop from 'LLVMConfig.cmake' the HAVE_* and related variables that were published there only to allow 'get_system_libs' to run outside our build process. Contributed by Brad King. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/LLVM-Config.cmake35
-rw-r--r--cmake/modules/LLVMConfig.cmake.in5
-rw-r--r--cmake/modules/Makefile14
3 files changed, 7 insertions, 47 deletions
diff --git a/cmake/modules/LLVM-Config.cmake b/cmake/modules/LLVM-Config.cmake
index af720fcb21..451fc56c6b 100644
--- a/cmake/modules/LLVM-Config.cmake
+++ b/cmake/modules/LLVM-Config.cmake
@@ -1,36 +1,12 @@
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 shell32)
- elseif( CMAKE_HOST_UNIX )
- if( HAVE_LIBRT )
- set(system_libs ${system_libs} rt)
- endif()
- if( HAVE_LIBDL )
- set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
- endif()
- if(LLVM_ENABLE_TERMINFO)
- if(HAVE_TERMINFO)
- set(system_libs ${system_libs} ${TERMINFO_LIBS})
- endif()
- endif()
- if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
- set(system_libs ${system_libs} pthread)
- endif()
- if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
- set(system_libs ${system_libs} z)
- endif()
- endif( MINGW )
- endif( NOT MSVC )
- set(${return_var} ${system_libs} PARENT_SCOPE)
-endfunction(get_system_libs)
+ message(AUTHOR_WARNING "get_system_libs no longer needed")
+ set(${return_var} "" PARENT_SCOPE)
+endfunction()
function(link_system_libs target)
- get_system_libs(llvm_system_libs)
- target_link_libraries(${target} ${llvm_system_libs})
-endfunction(link_system_libs)
+ message(AUTHOR_WARNING "link_system_libs no longer needed")
+endfunction()
function(is_llvm_target_library library return_var)
@@ -70,7 +46,6 @@ endfunction(explicit_llvm_config)
# This is a variant intended for the final user:
function(llvm_map_components_to_libraries OUT_VAR)
explicit_map_components_to_libraries(result ${ARGN})
- get_system_libs(sys_result)
set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
endfunction(llvm_map_components_to_libraries)
diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in
index 11857a5384..2f8d037af1 100644
--- a/cmake/modules/LLVMConfig.cmake.in
+++ b/cmake/modules/LLVMConfig.cmake.in
@@ -30,11 +30,6 @@ set(LLVM_NATIVE_ARCH @LLVM_NATIVE_ARCH@)
set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)
-set(HAVE_TERMINFO @HAVE_TERMINFO@)
-set(TERMINFO_LIBS @TERMINFO_LIBS@)
-set(HAVE_LIBDL @HAVE_LIBDL@)
-set(HAVE_LIBPTHREAD @HAVE_LIBPTHREAD@)
-set(HAVE_LIBZ @HAVE_LIBZ@)
set(LLVM_ON_UNIX @LLVM_ON_UNIX@)
set(LLVM_ON_WIN32 @LLVM_ON_WIN32@)
diff --git a/cmake/modules/Makefile b/cmake/modules/Makefile
index 894067d6f5..8f20ddf4dc 100644
--- a/cmake/modules/Makefile
+++ b/cmake/modules/Makefile
@@ -17,10 +17,6 @@ PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
-# TODO: Teach LLVM-Config.cmake to work without explicit terminfo libs.
-TERMINFO_LIBS := tinfo terminfo curses ncurses ncursesw
-TERMINFO_LIBS := $(filter $(TERMINFO_LIBS),$(subst -l,,$(LIBS)))
-
$(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
$(Echo) 'Generating LLVM CMake package config file'
$(Verb) ( \
@@ -40,11 +36,6 @@ $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
-e 's/@LLVM_ENABLE_ZLIB@/'"$(ENABLE_ZLIB)"'/' \
-e 's/@LLVM_NATIVE_ARCH@/'"$(LLVM_NATIVE_ARCH)"'/' \
-e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \
- -e 's/@HAVE_TERMINFO@/'"$(HAVE_TERMINFO)"'/' \
- -e 's/@TERMINFO_LIBS@/'"$(TERMINFO_LIBS)"'/' \
- -e 's/@HAVE_LIBDL@/'"$(HAVE_DLOPEN)"'/' \
- -e 's/@HAVE_LIBPTHREAD@/'"$(HAVE_PTHREAD)"'/' \
- -e 's/@HAVE_LIBZ@/'"$(HAVE_LIBZ)"'/' \
-e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \
-e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \
-e 's/@LLVM_CONFIG_INCLUDE_DIRS@/'"$(subst /,\/,$(PROJ_includedir))"'/' \
@@ -70,9 +61,8 @@ $(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag)
echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \
done && \
- cat "$(LLVMBuildCMakeExportsFrag)" \
- && echo '# System libs depend on LLVMSupport.' \
- && echo 'set_property(TARGET LLVMSupport PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES $(patsubst -l%,%,$(LIBS)))' \
+ cat "$(LLVMBuildCMakeExportsFrag)" && \
+ echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \
) | grep -v gtest > $@
all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))