2009-01-22 02:20:31 +01:00
|
|
|
include(FindPerl)
|
2009-08-12 05:32:44 +02:00
|
|
|
include(LLVMLibDeps)
|
2009-05-27 17:49:33 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
2008-11-16 05:13:19 +01:00
|
|
|
macro(llvm_config executable)
|
2009-06-23 20:30:17 +02:00
|
|
|
explicit_llvm_config(${executable} ${ARGN})
|
2008-11-16 05:13:19 +01:00
|
|
|
endmacro(llvm_config)
|
2008-09-22 03:08:49 +02:00
|
|
|
|
|
|
|
|
2009-06-04 21:53:37 +02:00
|
|
|
function(explicit_llvm_config executable)
|
2008-11-16 05:13:19 +01:00
|
|
|
set( link_components ${ARGN} )
|
2009-06-04 21:53:37 +02:00
|
|
|
|
|
|
|
explicit_map_components_to_libraries(LIBRARIES ${link_components})
|
2008-10-31 02:24:51 +01:00
|
|
|
target_link_libraries(${executable} ${LIBRARIES})
|
2009-06-04 21:53:37 +02:00
|
|
|
endfunction(explicit_llvm_config)
|
2008-10-31 02:24:51 +01:00
|
|
|
|
|
|
|
|
2009-06-04 21:53:37 +02:00
|
|
|
function(explicit_map_components_to_libraries out_libs)
|
2008-11-16 05:13:19 +01:00
|
|
|
set( link_components ${ARGN} )
|
2008-10-31 02:24:51 +01:00
|
|
|
foreach(c ${link_components})
|
2009-07-17 22:42:00 +02:00
|
|
|
# add codegen, asmprinter, asmparser
|
2008-11-15 23:51:03 +01:00
|
|
|
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
|
|
|
|
if( NOT idx LESS 0 )
|
2008-11-16 05:13:19 +01:00
|
|
|
list(FIND llvm_libs "LLVM${c}CodeGen" idx)
|
|
|
|
if( NOT idx LESS 0 )
|
|
|
|
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()
|
|
|
|
endif()
|
2008-11-15 23:51:03 +01:00
|
|
|
list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
|
|
|
|
if( NOT asmidx LESS 0 )
|
|
|
|
list(APPEND expanded_components "LLVM${c}AsmPrinter")
|
|
|
|
endif()
|
2009-07-17 22:42:00 +02:00
|
|
|
list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
|
|
|
|
if( NOT asmidx LESS 0 )
|
|
|
|
list(APPEND expanded_components "LLVM${c}AsmParser")
|
|
|
|
endif()
|
2009-07-15 09:52:36 +02:00
|
|
|
list(FIND llvm_libs "LLVM${c}Info" asmidx)
|
|
|
|
if( NOT asmidx LESS 0 )
|
|
|
|
list(APPEND expanded_components "LLVM${c}Info")
|
|
|
|
endif()
|
2008-11-15 23:51:03 +01:00
|
|
|
elseif( c STREQUAL "native" )
|
2008-10-31 02:24:51 +01:00
|
|
|
# TODO: we assume ARCH is X86. In this case, we must use nativecodegen
|
|
|
|
# component instead. Do nothing, as in llvm-config script.
|
|
|
|
elseif( c STREQUAL "nativecodegen" )
|
|
|
|
# TODO: we assume ARCH is X86.
|
|
|
|
list(APPEND expanded_components "LLVMX86CodeGen")
|
|
|
|
elseif( c STREQUAL "backend" )
|
|
|
|
# same case as in `native'.
|
|
|
|
elseif( c STREQUAL "engine" )
|
|
|
|
# TODO: as we assume we are on X86, this is `jit'.
|
|
|
|
list(APPEND expanded_components "LLVMJIT")
|
|
|
|
elseif( c STREQUAL "all" )
|
|
|
|
list(APPEND expanded_components ${llvm_libs})
|
2008-11-15 23:51:03 +01:00
|
|
|
else( NOT idx LESS 0 )
|
2008-10-31 02:24:51 +01:00
|
|
|
list(APPEND expanded_components LLVM${c})
|
2008-11-15 23:51:03 +01:00
|
|
|
endif( NOT idx LESS 0 )
|
2008-10-31 02:24:51 +01:00
|
|
|
endforeach(c)
|
|
|
|
# We must match capitalization.
|
|
|
|
string(TOUPPER "${llvm_libs}" capitalized_libs)
|
2008-11-16 05:13:19 +01:00
|
|
|
list(REMOVE_DUPLICATES expanded_components)
|
2008-10-31 02:24:51 +01:00
|
|
|
set(curr_idx 0)
|
|
|
|
list(LENGTH expanded_components lst_size)
|
|
|
|
while( ${curr_idx} LESS ${lst_size} )
|
|
|
|
list(GET expanded_components ${curr_idx} c)
|
|
|
|
string(TOUPPER "${c}" capitalized)
|
|
|
|
list(FIND capitalized_libs ${capitalized} idx)
|
|
|
|
if( idx LESS 0 )
|
|
|
|
message(FATAL_ERROR "Library ${c} not found in list of llvm libraries.")
|
|
|
|
endif( idx LESS 0 )
|
|
|
|
list(GET llvm_libs ${idx} canonical_lib)
|
|
|
|
list(APPEND result ${canonical_lib})
|
|
|
|
list(APPEND result ${MSVC_LIB_DEPS_${canonical_lib}})
|
|
|
|
list(APPEND expanded_components ${MSVC_LIB_DEPS_${canonical_lib}})
|
2008-11-16 05:13:19 +01:00
|
|
|
list(REMOVE_DUPLICATES expanded_components)
|
2008-10-31 02:24:51 +01:00
|
|
|
list(LENGTH expanded_components lst_size)
|
|
|
|
math(EXPR curr_idx "${curr_idx} + 1")
|
|
|
|
endwhile( ${curr_idx} LESS ${lst_size} )
|
|
|
|
list(REMOVE_DUPLICATES result)
|
|
|
|
set(${out_libs} ${result} PARENT_SCOPE)
|
2009-06-04 21:53:37 +02:00
|
|
|
endfunction(explicit_map_components_to_libraries)
|