Expose most of the Constant creation functions to llvm-c.
[oota-llvm.git] / cmake / modules / LLVMConfig.cmake
index 4196d1c47a83c80dc8e286bfedad530d1e866e2b..1d8d090986dcaadd9194abf1ddfe6239039e4b4c 100755 (executable)
@@ -1,6 +1,3 @@
-include(FindPerl)
-include(LLVMLibDeps)
-
 function(get_system_libs return_var)
   # Returns in `return_var' a list of system libraries used by LLVM.
   if( NOT MSVC )
@@ -81,23 +78,50 @@ function(explicit_map_components_to_libraries out_libs)
   # 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} )
-    list(GET expanded_components ${curr_idx} c)
+  set(result "")
+  while( 0 LESS ${lst_size} )
+    list(GET expanded_components 0 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(REMOVE_ITEM result ${canonical_lib})
     list(APPEND result ${canonical_lib})
-    list(APPEND result ${MSVC_LIB_DEPS_${canonical_lib}})
+    foreach(c ${MSVC_LIB_DEPS_${canonical_lib}})
+      list(REMOVE_ITEM expanded_components ${c})
+    endforeach()
     list(APPEND expanded_components ${MSVC_LIB_DEPS_${canonical_lib}})
-    list(REMOVE_DUPLICATES expanded_components)
+    list(REMOVE_AT expanded_components 0)
     list(LENGTH expanded_components lst_size)
-    math(EXPR curr_idx "${curr_idx} + 1")
-  endwhile( ${curr_idx} LESS ${lst_size} )
-  list(REMOVE_DUPLICATES result)
+  endwhile( 0 LESS ${lst_size} )
   set(${out_libs} ${result} PARENT_SCOPE)
 endfunction(explicit_map_components_to_libraries)
+
+
+# The library dependency data is contained in the file
+# LLVMLibDeps.cmake on this directory. It is automatically generated
+# by tools/llvm-config/CMakeLists.txt when the build comprises all the
+# targets and we are on a environment Posix enough to build the
+# llvm-config script. This, in practice, just excludes MSVC.
+
+# When you remove or rename a library from the build, be sure to
+# remove its file from lib/ as well, or the GenLibDeps.pl script will
+# include it on its analysis!
+
+# The format generated by GenLibDeps.pl
+
+# LLVMARMAsmPrinter.o: LLVMARMCodeGen.o libLLVMAsmPrinter.a libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMTarget.a
+
+# is translated to:
+
+# set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
+
+# It is necessary to remove the `lib' prefix and the `.a'.
+
+# This 'sed' script should do the trick:
+# sed -e s'#\.a##g' -e 's#libLLVM#LLVM#g' -e 's#: # #' -e 's#\(.*\)#set(MSVC_LIB_DEPS_\1)#' ~/llvm/tools/llvm-config/LibDeps.txt
+
+include(LLVMLibDeps)