2009-01-22 01:20:31 +00:00
|
|
|
include(FindPerl)
|
|
|
|
|
2009-05-27 15:49:33 +00: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 04:13:19 +00:00
|
|
|
macro(llvm_config executable)
|
2009-06-23 18:30:17 +00:00
|
|
|
explicit_llvm_config(${executable} ${ARGN})
|
2008-11-16 04:13:19 +00:00
|
|
|
endmacro(llvm_config)
|
2008-09-22 01:08:49 +00:00
|
|
|
|
|
|
|
|
2009-06-04 19:53:37 +00:00
|
|
|
function(explicit_llvm_config executable)
|
2008-11-16 04:13:19 +00:00
|
|
|
set( link_components ${ARGN} )
|
2009-06-04 19:53:37 +00:00
|
|
|
|
|
|
|
set(lfgs)
|
|
|
|
if (MSVC)
|
|
|
|
if( CMAKE_CL_64 )
|
|
|
|
set(include_lflag "/INCLUDE:")
|
|
|
|
else( CMAKE_CL_64 )
|
|
|
|
set(include_lflag "/INCLUDE:_")
|
|
|
|
endif()
|
|
|
|
foreach(c ${link_components})
|
|
|
|
if( c STREQUAL "jit" )
|
|
|
|
set(lfgs "${lfgs} ${include_lflag}X86TargetMachineModule")
|
|
|
|
endif( c STREQUAL "jit" )
|
|
|
|
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
|
2008-11-15 22:51:03 +00:00
|
|
|
if( NOT idx LESS 0 )
|
2009-06-04 19:53:37 +00:00
|
|
|
set(lfgs "${lfgs} ${include_lflag}${c}TargetMachineModule")
|
|
|
|
list(FIND LLVM_ASMPRINTERS_FORCE_LINK ${c} idx)
|
|
|
|
if( NOT idx LESS 0 )
|
|
|
|
set(lfgs "${lfgs} ${include_lflag}${c}AsmPrinterForceLink")
|
|
|
|
endif()
|
2008-11-15 22:51:03 +00:00
|
|
|
endif()
|
2009-06-04 19:53:37 +00:00
|
|
|
endforeach(c)
|
|
|
|
endif ()
|
2008-11-15 22:51:03 +00:00
|
|
|
|
2009-06-04 19:53:37 +00:00
|
|
|
explicit_map_components_to_libraries(LIBRARIES ${link_components})
|
2008-10-31 01:24:51 +00:00
|
|
|
target_link_libraries(${executable} ${LIBRARIES})
|
2008-11-15 22:51:03 +00:00
|
|
|
|
|
|
|
if( lfgs )
|
|
|
|
set_target_properties(${executable}
|
|
|
|
PROPERTIES
|
|
|
|
LINK_FLAGS ${lfgs})
|
|
|
|
endif()
|
2009-06-04 19:53:37 +00:00
|
|
|
endfunction(explicit_llvm_config)
|
2008-10-31 01:24:51 +00:00
|
|
|
|
|
|
|
|
2009-06-04 19:53:37 +00:00
|
|
|
function(explicit_map_components_to_libraries out_libs)
|
2008-11-16 04:13:19 +00:00
|
|
|
set( link_components ${ARGN} )
|
2008-10-31 01:24:51 +00:00
|
|
|
foreach(c ${link_components})
|
2008-11-15 22:51:03 +00:00
|
|
|
# add codegen/asmprinter
|
|
|
|
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
|
|
|
|
if( NOT idx LESS 0 )
|
2008-11-16 04:13:19 +00: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 22:51:03 +00:00
|
|
|
list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
|
|
|
|
if( NOT asmidx LESS 0 )
|
|
|
|
list(APPEND expanded_components "LLVM${c}AsmPrinter")
|
|
|
|
endif()
|
|
|
|
elseif( c STREQUAL "native" )
|
2008-10-31 01:24:51 +00: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 22:51:03 +00:00
|
|
|
else( NOT idx LESS 0 )
|
2008-10-31 01:24:51 +00:00
|
|
|
list(APPEND expanded_components LLVM${c})
|
2008-11-15 22:51:03 +00:00
|
|
|
endif( NOT idx LESS 0 )
|
2008-10-31 01:24:51 +00:00
|
|
|
endforeach(c)
|
|
|
|
# We must match capitalization.
|
|
|
|
string(TOUPPER "${llvm_libs}" capitalized_libs)
|
2008-11-16 04:13:19 +00:00
|
|
|
list(REMOVE_DUPLICATES expanded_components)
|
2008-10-31 01:24:51 +00: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 04:13:19 +00:00
|
|
|
list(REMOVE_DUPLICATES expanded_components)
|
2008-10-31 01:24:51 +00: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 19:53:37 +00:00
|
|
|
endfunction(explicit_map_components_to_libraries)
|
2008-09-22 01:08:49 +00:00
|
|
|
|
2009-06-23 18:30:17 +00:00
|
|
|
# This data is used to establish executable/library
|
2008-10-31 01:24:51 +00:00
|
|
|
# dependencies. Comes from the llvm-config script, which is built and
|
|
|
|
# installed on the bin directory for MinGW or Linux. At the end of the
|
|
|
|
# script, you'll see lines like this:
|
2008-10-31 01:37:26 +00:00
|
|
|
|
|
|
|
# LLVMARMAsmPrinter.o: LLVMARMCodeGen.o libLLVMAsmPrinter.a libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMTarget.a
|
|
|
|
|
2008-10-31 01:24:51 +00:00
|
|
|
# This is translated to:
|
2008-10-31 01:37:26 +00:00
|
|
|
|
|
|
|
# set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
|
|
|
|
|
2008-10-31 01:24:51 +00:00
|
|
|
# It is necessary to remove the `lib' prefix, the `.a' and `.o'
|
|
|
|
# suffixes. Watch out for this line:
|
2008-10-31 01:37:26 +00:00
|
|
|
|
|
|
|
# LLVMExecutionEngine.o LLVMJIT.o: libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a
|
|
|
|
|
2008-10-31 01:24:51 +00:00
|
|
|
# See how there are two elements before the colon. This must be
|
|
|
|
# translated as if it were:
|
2008-10-31 01:37:26 +00:00
|
|
|
|
|
|
|
# LLVMExecutionEngine.o: libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a
|
|
|
|
# LLVMJIT.o: libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a
|
|
|
|
|
2008-10-31 01:24:51 +00:00
|
|
|
# TODO: do this transformations on cmake.
|
2008-10-31 01:37:26 +00:00
|
|
|
|
2008-10-31 01:24:51 +00:00
|
|
|
# It is very important that the LLVM built for extracting this data
|
|
|
|
# must contain all targets, not just X86.
|
|
|
|
|
|
|
|
|
|
|
|
set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMARMCodeGen LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
|
2008-11-11 20:04:40 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMAlphaAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMAlphaCodeGen LLVMAlphaAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
|
2008-10-31 01:24:51 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMCBackend LLVMAnalysis LLVMCodeGen LLVMCore LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils LLVMipa)
|
2008-11-11 20:04:40 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMCellSPUAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMCellSPUCodeGen LLVMCellSPUAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
|
2008-10-31 01:24:51 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMCppBackend LLVMCore LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMExecutionEngine LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMJIT LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMIA64 LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMInterpreter LLVMExecutionEngine LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMMSIL LLVMAnalysis LLVMCodeGen LLVMCore LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils LLVMipa)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMMips LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMPIC16 LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMPowerPCCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMPowerPCCodeGen LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget)
|
2008-11-11 20:04:40 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMSparcAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMSparcCodeGen LLVMSparcAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
|
2008-10-31 01:24:51 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMX86AsmPrinter LLVMX86CodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMX86CodeGen LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
|
2008-11-11 20:04:40 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMXCore LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSelectionDAG LLVMSupport LLVMTarget)
|
2008-10-31 01:24:51 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMArchive LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMAsmParser LLVMCore LLVMSupport)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMBitReader LLVMCore LLVMSupport)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMBitWriter LLVMCore LLVMSupport LLVMSystem)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMCodeGen LLVMAnalysis LLVMCore LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMCore LLVMSupport LLVMSystem)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMDebugger LLVMAnalysis LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
|
2008-11-11 20:04:40 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMHello LLVMCore LLVMSupport)
|
2008-10-31 01:24:51 +00:00
|
|
|
set(MSVC_LIB_DEPS_LLVMInstrumentation LLVMCore LLVMScalarOpts LLVMSupport LLVMTransformUtils)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMLinker LLVMArchive LLVMBitReader LLVMCore LLVMSupport LLVMSystem)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMScalarOpts LLVMAnalysis LLVMCore LLVMSupport LLVMTarget LLVMTransformUtils)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMSelectionDAG LLVMAnalysis LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMSupport LLVMSystem)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMSystem )
|
|
|
|
set(MSVC_LIB_DEPS_LLVMTarget LLVMCore LLVMSupport)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMTransformUtils LLVMAnalysis LLVMCore LLVMSupport LLVMTarget LLVMipa)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMipa LLVMAnalysis LLVMCore LLVMSupport)
|
|
|
|
set(MSVC_LIB_DEPS_LLVMipo LLVMAnalysis LLVMCore LLVMSupport LLVMTarget LLVMTransformUtils LLVMipa)
|