diff options
Diffstat (limited to 'cmake/modules/AddLLVM.cmake')
-rwxr-xr-x | cmake/modules/AddLLVM.cmake | 87 |
1 files changed, 4 insertions, 83 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index 52864d2..22a456e 100755 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -1,21 +1,5 @@ include(LLVMProcessSources) - -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} ${CMAKE_DL_LIBS}) - 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) +include(LLVMConfig) macro(add_llvm_library name) llvm_process_sources( ALL_FILES ${ARGN} ) @@ -25,11 +9,7 @@ macro(add_llvm_library name) if( LLVM_COMMON_DEPENDS ) add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) endif( LLVM_COMMON_DEPENDS ) - if (LLVM_COMMON_LIBS) - target_link_libraries(${name} ${LLVM_COMMON_LIBS}) - endif() install(TARGETS ${name} - EXPORT LLVM LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) # The LLVM Target library shall be built before its sublibraries @@ -58,7 +38,6 @@ ${name} ignored.") endif() install(TARGETS ${name} - EXPORT LLVM LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) endif() @@ -78,12 +57,12 @@ macro(add_llvm_executable name) target_link_libraries( ${name} ${lib} ) endforeach(lib) endif( LLVM_USED_LIBS ) + if( LLVM_LINK_COMPONENTS ) + llvm_config(${name} ${LLVM_LINK_COMPONENTS}) + endif( LLVM_LINK_COMPONENTS ) if( LLVM_COMMON_DEPENDS ) add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) endif( LLVM_COMMON_DEPENDS ) - if (LLVM_COMMON_LIBS) - target_link_libraries(${name} ${LLVM_COMMON_LIBS}) - endif() if( NOT MINGW ) get_system_libs(llvm_system_libs) if( llvm_system_libs ) @@ -130,61 +109,3 @@ macro(add_llvm_target target_name) endif (TABLEGEN_OUTPUT) set(CURRENT_LLVM_TARGET LLVM${target_name} PARENT_SCOPE) endmacro(add_llvm_target) - -macro(llvm_get_target_libraries return_var) - set( link_components ${ARGN} ) - foreach(c ${link_components}) - # 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") - 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() - list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx) - if( NOT asmidx LESS 0 ) - list(APPEND expanded_components "LLVM${c}AsmPrinter") - endif() - list(FIND llvm_libs "LLVM${c}AsmParser" asmidx) - if( NOT asmidx LESS 0 ) - list(APPEND expanded_components "LLVM${c}AsmParser") - endif() - list(FIND llvm_libs "LLVM${c}Info" asmidx) - if( NOT asmidx LESS 0 ) - list(APPEND expanded_components "LLVM${c}Info") - endif() - list(FIND llvm_libs "LLVM${c}Disassembler" asmidx) - if( NOT asmidx LESS 0 ) - list(APPEND expanded_components "LLVM${c}Disassembler") - endif() - elseif( c STREQUAL "native" ) - list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}CodeGen") - elseif( c STREQUAL "nativecodegen" ) - list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}CodeGen") - elseif( c STREQUAL "backend" ) - # same case as in `native'. - elseif( c STREQUAL "engine" OR c STREQUAL "jit") - # TODO: as we assume we are on X86, this is `jit'. - list(APPEND expanded_components "LLVMJIT") - elseif( c STREQUAL "interpreter" ) - list(APPEND expanded_components "LLVMInterpreter") - elseif( c STREQUAL "all" ) - list(APPEND expanded_components ${llvm_libs}) - else( NOT idx LESS 0 ) - list(APPEND expanded_components LLVM${c}) - endif( NOT idx LESS 0 ) - endforeach(c) - set(${return_var} ${expanded_components}) -endmacro(llvm_get_target_libraries) - -macro(add_llvm_link_components target_name) - llvm_get_target_libraries(target_libs ${ARGN}) - target_link_libraries(${target_name} ${target_libs}) -endmacro() |