aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/modules/LLVM-Config.cmake
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /cmake/modules/LLVM-Config.cmake
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'cmake/modules/LLVM-Config.cmake')
-rw-r--r--cmake/modules/LLVM-Config.cmake119
1 files changed, 55 insertions, 64 deletions
diff --git a/cmake/modules/LLVM-Config.cmake b/cmake/modules/LLVM-Config.cmake
index e26fabd..2783af8 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)
@@ -41,12 +17,12 @@ function(is_llvm_target_library library return_var)
string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
foreach(t ${targets})
if( capitalized_lib STREQUAL t OR
- capitalized_lib STREQUAL "LLVM${t}" OR
- capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
- capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
- capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
- capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
- capitalized_lib STREQUAL "LLVM${t}INFO" )
+ capitalized_lib STREQUAL "LLVM${t}" OR
+ capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
+ capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
+ capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
+ capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
+ capitalized_lib STREQUAL "LLVM${t}INFO" )
set(${return_var} ON PARENT_SCOPE)
break()
endif()
@@ -62,23 +38,33 @@ endmacro(llvm_config)
function(explicit_llvm_config executable)
set( link_components ${ARGN} )
- explicit_map_components_to_libraries(LIBRARIES ${link_components})
- target_link_libraries(${executable} ${LIBRARIES})
+ llvm_map_components_to_libnames(LIBRARIES ${link_components})
+ get_target_property(t ${executable} TYPE)
+ if("${t}" STREQUAL "STATIC_LIBRARY")
+ target_link_libraries(${executable} ${cmake_2_8_12_INTERFACE} ${LIBRARIES})
+ elseif("${t}" STREQUAL "SHARED_LIBRARY" OR "${t}" STREQUAL "MODULE_LIBRARY")
+ target_link_libraries(${executable} ${cmake_2_8_12_PRIVATE} ${LIBRARIES})
+ else()
+ # Use plain form for legacy user.
+ target_link_libraries(${executable} ${LIBRARIES})
+ endif()
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)
-
-function(explicit_map_components_to_libraries out_libs)
+# Map LINK_COMPONENTS to actual libnames.
+function(llvm_map_components_to_libnames out_libs)
set( link_components ${ARGN} )
- get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
- string(TOUPPER "${llvm_libs}" capitalized_libs)
+ if(NOT LLVM_AVAILABLE_LIBS)
+ # Inside LLVM itself available libs are in a global property.
+ get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
+ endif()
+ string(TOUPPER "${LLVM_AVAILABLE_LIBS}" capitalized_libs)
# Expand some keywords:
list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
@@ -104,31 +90,25 @@ function(explicit_map_components_to_libraries out_libs)
# add codegen, asmprinter, asmparser, disassembler
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
if( NOT idx LESS 0 )
- list(FIND llvm_libs "LLVM${c}CodeGen" idx)
- if( NOT idx LESS 0 )
- list(APPEND expanded_components "LLVM${c}CodeGen")
+ if( TARGET LLVM${c}CodeGen )
+ list(APPEND expanded_components "LLVM${c}CodeGen")
else()
- list(FIND llvm_libs "LLVM${c}" idx)
- if( NOT idx LESS 0 )
- list(APPEND expanded_components "LLVM${c}")
- else()
- message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
- endif()
+ if( TARGET LLVM${c} )
+ list(APPEND expanded_components "LLVM${c}")
+ else()
+ message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
+ endif()
endif()
- list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
- if( NOT asmidx LESS 0 )
+ if( TARGET LLVM${c}AsmPrinter )
list(APPEND expanded_components "LLVM${c}AsmPrinter")
endif()
- list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
- if( NOT asmidx LESS 0 )
+ if( TARGET LLVM${c}AsmParser )
list(APPEND expanded_components "LLVM${c}AsmParser")
endif()
- list(FIND llvm_libs "LLVM${c}Info" asmidx)
- if( NOT asmidx LESS 0 )
+ if( TARGET LLVM${c}Info )
list(APPEND expanded_components "LLVM${c}Info")
endif()
- list(FIND llvm_libs "LLVM${c}Disassembler" asmidx)
- if( NOT asmidx LESS 0 )
+ if( TARGET LLVM${c}Disassembler )
list(APPEND expanded_components "LLVM${c}Disassembler")
endif()
elseif( c STREQUAL "native" )
@@ -140,7 +120,7 @@ function(explicit_map_components_to_libraries out_libs)
elseif( c STREQUAL "engine" )
# already processed
elseif( c STREQUAL "all" )
- list(APPEND expanded_components ${llvm_libs})
+ list(APPEND expanded_components ${LLVM_AVAILABLE_LIBS})
else( NOT idx LESS 0 )
# Canonize the component name:
string(TOUPPER "${c}" capitalized)
@@ -152,12 +132,18 @@ function(explicit_map_components_to_libraries out_libs)
message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
endif()
else( lib_idx LESS 0 )
- list(GET llvm_libs ${lib_idx} canonical_lib)
+ list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
list(APPEND expanded_components ${canonical_lib})
endif( lib_idx LESS 0 )
endif( NOT idx LESS 0 )
endforeach(c)
- # Expand dependencies while topologically sorting the list of libraries:
+
+ set(${out_libs} ${expanded_components} PARENT_SCOPE)
+endfunction()
+
+# Expand dependencies while topologically sorting the list of libraries:
+function(llvm_expand_dependencies out_libs)
+ set(expanded_components ${ARGN})
list(LENGTH expanded_components lst_size)
set(cursor 0)
set(processed)
@@ -177,11 +163,16 @@ function(explicit_map_components_to_libraries out_libs)
list(LENGTH processed cursor)
list(LENGTH expanded_components lst_size)
endwhile( cursor LESS lst_size )
+ set(${out_libs} ${expanded_components} PARENT_SCOPE)
+endfunction()
+
+function(explicit_map_components_to_libraries out_libs)
+ llvm_map_components_to_libnames(link_libs ${ARGN})
+ llvm_expand_dependencies(expanded_components ${link_libs})
# Return just the libraries included in this build:
set(result)
foreach(c ${expanded_components})
- list(FIND llvm_libs ${c} lib_idx)
- if( NOT lib_idx LESS 0 )
+ if( TARGET ${c} )
set(result ${result} ${c})
endif()
endforeach(c)