Rename LLVMConfig.cmake to LLVM-Config.cmake. The *Config.cmake naming
authorOscar Fuentes <ofv@wanadoo.es>
Tue, 5 Apr 2011 17:02:48 +0000 (17:02 +0000)
committerOscar Fuentes <ofv@wanadoo.es>
Tue, 5 Apr 2011 17:02:48 +0000 (17:02 +0000)
scheme is used by the functionality related to find_package.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128889 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/AddLLVM.cmake
cmake/modules/CMakeLists.txt
cmake/modules/LLVM-Config.cmake [new file with mode: 0755]
cmake/modules/LLVM.cmake
cmake/modules/LLVMConfig.cmake [deleted file]
tools/llvm-config/CMakeLists.txt

index df739b411995bb45bb5e3ff322ab940088790419..6087094e8351bedca22087ca407141894d3acea6 100755 (executable)
@@ -1,5 +1,5 @@
 include(LLVMProcessSources)
-include(LLVMConfig)
+include(LLVM-Config)
 
 macro(add_llvm_library name)
   llvm_process_sources( ALL_FILES ${ARGN} )
index 1ab94749f1569feae7188c0b622ac4f509215998..036ee05cfb3620bda847b01d1e4b745b695bc4e0 100644 (file)
@@ -9,7 +9,7 @@ configure_file(
 
 install(FILES
   ${llvm_cmake_builddir}/LLVM.cmake
-  LLVMConfig.cmake
+  LLVM-Config.cmake
   LLVMLibDeps.cmake
   DESTINATION share/llvm/cmake)
 
@@ -18,7 +18,7 @@ install(DIRECTORY .
   FILES_MATCHING PATTERN *.cmake
   PATTERN .svn EXCLUDE
   PATTERN LLVM.cmake EXCLUDE
-  PATTERN LLVMConfig.cmake EXCLUDE
+  PATTERN LLVM-Config.cmake EXCLUDE
   PATTERN LLVMLibDeps.cmake EXCLUDE
   PATTERN FindBison.cmake EXCLUDE
   PATTERN GetTargetTriple.cmake EXCLUDE
@@ -27,6 +27,6 @@ install(DIRECTORY .
 
 install(FILES
   ${llvm_cmake_builddir}/LLVM.cmake
-  LLVMConfig.cmake
+  LLVM-Config.cmake
   LLVMLibDeps.cmake
   DESTINATION share/llvm/cmake)
diff --git a/cmake/modules/LLVM-Config.cmake b/cmake/modules/LLVM-Config.cmake
new file mode 100755 (executable)
index 0000000..bd6a7a2
--- /dev/null
@@ -0,0 +1,203 @@
+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)
+
+
+function(link_system_libs target)
+  get_system_libs(llvm_system_libs)
+  target_link_libraries(${target} ${llvm_system_libs})
+endfunction(link_system_libs)
+
+
+function(is_llvm_target_library library return_var)
+  # Sets variable `return_var' to ON if `library' corresponds to a
+  # LLVM supported target. To OFF if it doesn't.
+  set(${return_var} OFF PARENT_SCOPE)
+  string(TOUPPER "${library}" capitalized_lib)
+  string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
+  foreach(t ${targets})
+    if( capitalized_lib STREQUAL t OR
+       capitalized_lib STREQUAL "LLVM${t}" OR
+       capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
+       capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
+       capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
+       capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
+       capitalized_lib STREQUAL "LLVM${t}INFO" )
+      set(${return_var} ON PARENT_SCOPE)
+      break()
+    endif()
+  endforeach()
+endfunction(is_llvm_target_library)
+
+
+macro(llvm_config executable)
+  explicit_llvm_config(${executable} ${ARGN})
+endmacro(llvm_config)
+
+
+function(explicit_llvm_config executable)
+  set( link_components ${ARGN} )
+
+  explicit_map_components_to_libraries(LIBRARIES ${link_components})
+  target_link_libraries(${executable} ${LIBRARIES})
+endfunction(explicit_llvm_config)
+
+
+# This is a variant intended for the final user:
+function(llvm_map_components_to_libraries OUT_VAR)
+  explicit_map_components_to_libraries(result ${ARGN})
+  get_system_libs(sys_result)
+  set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
+endfunction(llvm_map_components_to_libraries)
+
+
+function(explicit_map_components_to_libraries out_libs)
+  set( link_components ${ARGN} )
+  get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
+  string(TOUPPER "${llvm_libs}" capitalized_libs)
+
+  # Expand some keywords:
+  list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
+  list(FIND link_components "engine" engine_required)
+  if( NOT engine_required EQUAL -1 )
+    list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit)
+    if( NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1 )
+      list(APPEND link_components "jit")
+      list(APPEND link_components "native")
+    else()
+      list(APPEND link_components "interpreter")
+    endif()
+  endif()
+  list(FIND link_components "native" native_required)
+  if( NOT native_required EQUAL -1 )
+    if( NOT have_native_backend EQUAL -1 )
+      list(APPEND link_components ${LLVM_NATIVE_ARCH})
+    endif()
+  endif()
+
+  # Translate symbolic component names to real libraries:
+  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" )
+      # already processed
+    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" )
+      # already processed
+    elseif( c STREQUAL "all" )
+      list(APPEND expanded_components ${llvm_libs})
+    else( NOT idx LESS 0 )
+      # Canonize the component name:
+      string(TOUPPER "${c}" capitalized)
+      list(FIND capitalized_libs LLVM${capitalized} lib_idx)
+      if( lib_idx LESS 0 )
+       # The component is unkown. Maybe is an ommitted target?
+       is_llvm_target_library(${c} iltl_result)
+       if( NOT iltl_result )
+         message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
+       endif()
+      else( lib_idx LESS 0 )
+       list(GET llvm_libs ${lib_idx} canonical_lib)
+       list(APPEND expanded_components ${canonical_lib})
+      endif( lib_idx LESS 0 )
+    endif( NOT idx LESS 0 )
+  endforeach(c)
+  # Expand dependencies while topologically sorting the list of libraries:
+  list(LENGTH expanded_components lst_size)
+  set(cursor 0)
+  set(processed)
+  while( cursor LESS lst_size )
+    list(GET expanded_components ${cursor} lib)
+    list(APPEND expanded_components ${MSVC_LIB_DEPS_${lib}})
+    # Remove duplicates at the front:
+    list(REVERSE expanded_components)
+    list(REMOVE_DUPLICATES expanded_components)
+    list(REVERSE expanded_components)
+    list(APPEND processed ${lib})
+    # Find the maximum index that doesn't have to be re-processed:
+    while(NOT "${expanded_components}" MATCHES "^${processed}.*" )
+      list(REMOVE_AT processed -1)
+    endwhile()
+    list(LENGTH processed cursor)
+    list(LENGTH expanded_components lst_size)
+  endwhile( cursor LESS lst_size )
+  # Return just the libraries included in this build:
+  set(result)
+  foreach(c ${expanded_components})
+    list(FIND llvm_libs ${c} lib_idx)
+    if( NOT lib_idx LESS 0 )
+      set(result ${result} ${c})
+    endif()
+  endforeach(c)
+  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)
index 8afc63d7a38922e53ec080fb61af60d1b1dc4bee..04abb9d2c2b2ccd71138d85a755b960224b82175 100644 (file)
@@ -28,13 +28,13 @@ set(LLVM_ON_WIN32 @LLVM_ON_WIN32@)
 # We try to include using the current setting of CMAKE_MODULE_PATH,
 # which suppossedly was filled by the user with the directory where
 # this file was installed:
-include( LLVMConfig OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED )
+include( LLVM-Config OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED )
 
 # If failed, we assume that this is an un-installed build:
 if( NOT LLVMCONFIG_INCLUDED )
   set(CMAKE_MODULE_PATH
     ${CMAKE_MODULE_PATH}
     "@LLVM_SOURCE_DIR@/cmake/modules")
-  include( LLVMConfig )
+  include( LLVM-Config )
 endif()
 
diff --git a/cmake/modules/LLVMConfig.cmake b/cmake/modules/LLVMConfig.cmake
deleted file mode 100755 (executable)
index bd6a7a2..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-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)
-
-
-function(link_system_libs target)
-  get_system_libs(llvm_system_libs)
-  target_link_libraries(${target} ${llvm_system_libs})
-endfunction(link_system_libs)
-
-
-function(is_llvm_target_library library return_var)
-  # Sets variable `return_var' to ON if `library' corresponds to a
-  # LLVM supported target. To OFF if it doesn't.
-  set(${return_var} OFF PARENT_SCOPE)
-  string(TOUPPER "${library}" capitalized_lib)
-  string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
-  foreach(t ${targets})
-    if( capitalized_lib STREQUAL t OR
-       capitalized_lib STREQUAL "LLVM${t}" OR
-       capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
-       capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
-       capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
-       capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
-       capitalized_lib STREQUAL "LLVM${t}INFO" )
-      set(${return_var} ON PARENT_SCOPE)
-      break()
-    endif()
-  endforeach()
-endfunction(is_llvm_target_library)
-
-
-macro(llvm_config executable)
-  explicit_llvm_config(${executable} ${ARGN})
-endmacro(llvm_config)
-
-
-function(explicit_llvm_config executable)
-  set( link_components ${ARGN} )
-
-  explicit_map_components_to_libraries(LIBRARIES ${link_components})
-  target_link_libraries(${executable} ${LIBRARIES})
-endfunction(explicit_llvm_config)
-
-
-# This is a variant intended for the final user:
-function(llvm_map_components_to_libraries OUT_VAR)
-  explicit_map_components_to_libraries(result ${ARGN})
-  get_system_libs(sys_result)
-  set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
-endfunction(llvm_map_components_to_libraries)
-
-
-function(explicit_map_components_to_libraries out_libs)
-  set( link_components ${ARGN} )
-  get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
-  string(TOUPPER "${llvm_libs}" capitalized_libs)
-
-  # Expand some keywords:
-  list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
-  list(FIND link_components "engine" engine_required)
-  if( NOT engine_required EQUAL -1 )
-    list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit)
-    if( NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1 )
-      list(APPEND link_components "jit")
-      list(APPEND link_components "native")
-    else()
-      list(APPEND link_components "interpreter")
-    endif()
-  endif()
-  list(FIND link_components "native" native_required)
-  if( NOT native_required EQUAL -1 )
-    if( NOT have_native_backend EQUAL -1 )
-      list(APPEND link_components ${LLVM_NATIVE_ARCH})
-    endif()
-  endif()
-
-  # Translate symbolic component names to real libraries:
-  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" )
-      # already processed
-    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" )
-      # already processed
-    elseif( c STREQUAL "all" )
-      list(APPEND expanded_components ${llvm_libs})
-    else( NOT idx LESS 0 )
-      # Canonize the component name:
-      string(TOUPPER "${c}" capitalized)
-      list(FIND capitalized_libs LLVM${capitalized} lib_idx)
-      if( lib_idx LESS 0 )
-       # The component is unkown. Maybe is an ommitted target?
-       is_llvm_target_library(${c} iltl_result)
-       if( NOT iltl_result )
-         message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
-       endif()
-      else( lib_idx LESS 0 )
-       list(GET llvm_libs ${lib_idx} canonical_lib)
-       list(APPEND expanded_components ${canonical_lib})
-      endif( lib_idx LESS 0 )
-    endif( NOT idx LESS 0 )
-  endforeach(c)
-  # Expand dependencies while topologically sorting the list of libraries:
-  list(LENGTH expanded_components lst_size)
-  set(cursor 0)
-  set(processed)
-  while( cursor LESS lst_size )
-    list(GET expanded_components ${cursor} lib)
-    list(APPEND expanded_components ${MSVC_LIB_DEPS_${lib}})
-    # Remove duplicates at the front:
-    list(REVERSE expanded_components)
-    list(REMOVE_DUPLICATES expanded_components)
-    list(REVERSE expanded_components)
-    list(APPEND processed ${lib})
-    # Find the maximum index that doesn't have to be re-processed:
-    while(NOT "${expanded_components}" MATCHES "^${processed}.*" )
-      list(REMOVE_AT processed -1)
-    endwhile()
-    list(LENGTH processed cursor)
-    list(LENGTH expanded_components lst_size)
-  endwhile( cursor LESS lst_size )
-  # Return just the libraries included in this build:
-  set(result)
-  foreach(c ${expanded_components})
-    list(FIND llvm_libs ${c} lib_idx)
-    if( NOT lib_idx LESS 0 )
-      set(result ${result} ${c})
-    endif()
-  endforeach(c)
-  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)
index 1f5aaf4d36697e11538f389d6ae3d4b54be81239..bc23a64d0efc707413e27b281491f2ce5a3d0e9b 100644 (file)
@@ -142,7 +142,7 @@ install(FILES ${LLVM_CONFIG}
 
 # Regeneration of library dependencies.
 
-# See the comments at the end of cmake/modules/LLVMConfig.cmake for
+# See the comments at the end of cmake/modules/LLVM-Config.cmake for
 # notes and guidelines.
 
 set(LLVMLibDeps ${LLVM_MAIN_SRC_DIR}/cmake/modules/LLVMLibDeps.cmake)