diff options
Diffstat (limited to 'llvm')
| -rwxr-xr-x | llvm/cmake/modules/LLVMConfig.cmake | 39 | 
1 files changed, 27 insertions, 12 deletions
diff --git a/llvm/cmake/modules/LLVMConfig.cmake b/llvm/cmake/modules/LLVMConfig.cmake index 3d5e3bc55a4..6ed89bae447 100755 --- a/llvm/cmake/modules/LLVMConfig.cmake +++ b/llvm/cmake/modules/LLVMConfig.cmake @@ -1,13 +1,15 @@ -macro(llvm_config executable link_components) +macro(llvm_config executable) +  # extra args is the list of link components.    if( MSVC ) -    msvc_llvm_config(${executable} ${link_components}) +    msvc_llvm_config(${executable} ${ARGN})    else( MSVC ) -    nix_llvm_config(${executable} ${link_components}) +    nix_llvm_config(${executable} ${ARGN})    endif( MSVC ) -endmacro(llvm_config executable link_components) +endmacro(llvm_config) -function(msvc_llvm_config executable link_components) +function(msvc_llvm_config executable) +  set( link_components ${ARGN} )    foreach(c ${link_components})      if( c STREQUAL "jit" )        set(lfgs "${lfgs} /INCLUDE:_X86TargetMachineModule") @@ -22,7 +24,7 @@ function(msvc_llvm_config executable link_components)      endif()    endforeach(c) -  msvc_map_components_to_libraries(${link_components} LIBRARIES) +  msvc_map_components_to_libraries(LIBRARIES ${link_components})    target_link_libraries(${executable} ${LIBRARIES})    if( lfgs ) @@ -30,15 +32,26 @@ function(msvc_llvm_config executable link_components)        PROPERTIES        LINK_FLAGS ${lfgs})    endif() -endfunction(msvc_llvm_config executable link_components) +endfunction(msvc_llvm_config) -function(msvc_map_components_to_libraries link_components out_libs) +function(msvc_map_components_to_libraries out_libs) +  set( link_components ${ARGN} )    foreach(c ${link_components})      # add codegen/asmprinter      list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)      if( NOT idx LESS 0 ) -      list(APPEND expanded_components "LLVM${c}CodeGen") +      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") @@ -62,6 +75,7 @@ function(msvc_map_components_to_libraries link_components out_libs)    endforeach(c)    # We must match capitalization.    string(TOUPPER "${llvm_libs}" capitalized_libs) +  list(REMOVE_DUPLICATES expanded_components)    set(curr_idx 0)    list(LENGTH expanded_components lst_size)    while( ${curr_idx} LESS ${lst_size} ) @@ -75,6 +89,7 @@ function(msvc_map_components_to_libraries link_components out_libs)      list(APPEND result ${canonical_lib})      list(APPEND result ${MSVC_LIB_DEPS_${canonical_lib}})      list(APPEND expanded_components ${MSVC_LIB_DEPS_${canonical_lib}}) +    list(REMOVE_DUPLICATES expanded_components)      list(LENGTH expanded_components lst_size)      math(EXPR curr_idx "${curr_idx} + 1")    endwhile( ${curr_idx} LESS ${lst_size} ) @@ -83,9 +98,9 @@ function(msvc_map_components_to_libraries link_components out_libs)  endfunction(msvc_map_components_to_libraries) -macro(nix_llvm_config executable link_components) +macro(nix_llvm_config executable)    set(lc "") -  foreach(c ${LLVM_LINK_COMPONENTS}) +  foreach(c ${ARGN})      set(lc "${lc} ${c}")    endforeach(c)    if( NOT HAVE_LLVM_CONFIG ) @@ -116,7 +131,7 @@ macro(nix_llvm_config executable link_components)        endif(c MATCHES ".*\\.o")      endforeach(c)    endif( NOT HAVE_LLVM_CONFIG ) -endmacro(nix_llvm_config executable link_components) +endmacro(nix_llvm_config)  # This data is used on MSVC for stablishing executable/library  | 

