llvm.org GIT mirror llvm / e7510c2
Rename LLVMConfig.cmake to LLVM-Config.cmake. The *Config.cmake naming 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 Oscar Fuentes 9 years ago
6 changed file(s) with 210 addition(s) and 210 deletion(s). Raw diff Collapse all Expand all
0 include(LLVMProcessSources)
1 include(LLVMConfig)
1 include(LLVM-Config)
22
33 macro(add_llvm_library name)
44 llvm_process_sources( ALL_FILES ${ARGN} )
88
99 install(FILES
1010 ${llvm_cmake_builddir}/LLVM.cmake
11 LLVMConfig.cmake
11 LLVM-Config.cmake
1212 LLVMLibDeps.cmake
1313 DESTINATION share/llvm/cmake)
1414
1717 FILES_MATCHING PATTERN *.cmake
1818 PATTERN .svn EXCLUDE
1919 PATTERN LLVM.cmake EXCLUDE
20 PATTERN LLVMConfig.cmake EXCLUDE
20 PATTERN LLVM-Config.cmake EXCLUDE
2121 PATTERN LLVMLibDeps.cmake EXCLUDE
2222 PATTERN FindBison.cmake EXCLUDE
2323 PATTERN GetTargetTriple.cmake EXCLUDE
2626
2727 install(FILES
2828 ${llvm_cmake_builddir}/LLVM.cmake
29 LLVMConfig.cmake
29 LLVM-Config.cmake
3030 LLVMLibDeps.cmake
3131 DESTINATION share/llvm/cmake)
0 function(get_system_libs return_var)
1 # Returns in `return_var' a list of system libraries used by LLVM.
2 if( NOT MSVC )
3 if( MINGW )
4 set(system_libs ${system_libs} imagehlp psapi)
5 elseif( CMAKE_HOST_UNIX )
6 if( HAVE_LIBDL )
7 set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
8 endif()
9 if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
10 set(system_libs ${system_libs} pthread)
11 endif()
12 endif( MINGW )
13 endif( NOT MSVC )
14 set(${return_var} ${system_libs} PARENT_SCOPE)
15 endfunction(get_system_libs)
16
17
18 function(link_system_libs target)
19 get_system_libs(llvm_system_libs)
20 target_link_libraries(${target} ${llvm_system_libs})
21 endfunction(link_system_libs)
22
23
24 function(is_llvm_target_library library return_var)
25 # Sets variable `return_var' to ON if `library' corresponds to a
26 # LLVM supported target. To OFF if it doesn't.
27 set(${return_var} OFF PARENT_SCOPE)
28 string(TOUPPER "${library}" capitalized_lib)
29 string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
30 foreach(t ${targets})
31 if( capitalized_lib STREQUAL t OR
32 capitalized_lib STREQUAL "LLVM${t}" OR
33 capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
34 capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
35 capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
36 capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
37 capitalized_lib STREQUAL "LLVM${t}INFO" )
38 set(${return_var} ON PARENT_SCOPE)
39 break()
40 endif()
41 endforeach()
42 endfunction(is_llvm_target_library)
43
44
45 macro(llvm_config executable)
46 explicit_llvm_config(${executable} ${ARGN})
47 endmacro(llvm_config)
48
49
50 function(explicit_llvm_config executable)
51 set( link_components ${ARGN} )
52
53 explicit_map_components_to_libraries(LIBRARIES ${link_components})
54 target_link_libraries(${executable} ${LIBRARIES})
55 endfunction(explicit_llvm_config)
56
57
58 # This is a variant intended for the final user:
59 function(llvm_map_components_to_libraries OUT_VAR)
60 explicit_map_components_to_libraries(result ${ARGN})
61 get_system_libs(sys_result)
62 set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
63 endfunction(llvm_map_components_to_libraries)
64
65
66 function(explicit_map_components_to_libraries out_libs)
67 set( link_components ${ARGN} )
68 get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
69 string(TOUPPER "${llvm_libs}" capitalized_libs)
70
71 # Expand some keywords:
72 list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
73 list(FIND link_components "engine" engine_required)
74 if( NOT engine_required EQUAL -1 )
75 list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit)
76 if( NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1 )
77 list(APPEND link_components "jit")
78 list(APPEND link_components "native")
79 else()
80 list(APPEND link_components "interpreter")
81 endif()
82 endif()
83 list(FIND link_components "native" native_required)
84 if( NOT native_required EQUAL -1 )
85 if( NOT have_native_backend EQUAL -1 )
86 list(APPEND link_components ${LLVM_NATIVE_ARCH})
87 endif()
88 endif()
89
90 # Translate symbolic component names to real libraries:
91 foreach(c ${link_components})
92 # add codegen, asmprinter, asmparser, disassembler
93 list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
94 if( NOT idx LESS 0 )
95 list(FIND llvm_libs "LLVM${c}CodeGen" idx)
96 if( NOT idx LESS 0 )
97 list(APPEND expanded_components "LLVM${c}CodeGen")
98 else()
99 list(FIND llvm_libs "LLVM${c}" idx)
100 if( NOT idx LESS 0 )
101 list(APPEND expanded_components "LLVM${c}")
102 else()
103 message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
104 endif()
105 endif()
106 list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
107 if( NOT asmidx LESS 0 )
108 list(APPEND expanded_components "LLVM${c}AsmPrinter")
109 endif()
110 list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
111 if( NOT asmidx LESS 0 )
112 list(APPEND expanded_components "LLVM${c}AsmParser")
113 endif()
114 list(FIND llvm_libs "LLVM${c}Info" asmidx)
115 if( NOT asmidx LESS 0 )
116 list(APPEND expanded_components "LLVM${c}Info")
117 endif()
118 list(FIND llvm_libs "LLVM${c}Disassembler" asmidx)
119 if( NOT asmidx LESS 0 )
120 list(APPEND expanded_components "LLVM${c}Disassembler")
121 endif()
122 elseif( c STREQUAL "native" )
123 # already processed
124 elseif( c STREQUAL "nativecodegen" )
125 list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}CodeGen")
126 elseif( c STREQUAL "backend" )
127 # same case as in `native'.
128 elseif( c STREQUAL "engine" )
129 # already processed
130 elseif( c STREQUAL "all" )
131 list(APPEND expanded_components ${llvm_libs})
132 else( NOT idx LESS 0 )
133 # Canonize the component name:
134 string(TOUPPER "${c}" capitalized)
135 list(FIND capitalized_libs LLVM${capitalized} lib_idx)
136 if( lib_idx LESS 0 )
137 # The component is unkown. Maybe is an ommitted target?
138 is_llvm_target_library(${c} iltl_result)
139 if( NOT iltl_result )
140 message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
141 endif()
142 else( lib_idx LESS 0 )
143 list(GET llvm_libs ${lib_idx} canonical_lib)
144 list(APPEND expanded_components ${canonical_lib})
145 endif( lib_idx LESS 0 )
146 endif( NOT idx LESS 0 )
147 endforeach(c)
148 # Expand dependencies while topologically sorting the list of libraries:
149 list(LENGTH expanded_components lst_size)
150 set(cursor 0)
151 set(processed)
152 while( cursor LESS lst_size )
153 list(GET expanded_components ${cursor} lib)
154 list(APPEND expanded_components ${MSVC_LIB_DEPS_${lib}})
155 # Remove duplicates at the front:
156 list(REVERSE expanded_components)
157 list(REMOVE_DUPLICATES expanded_components)
158 list(REVERSE expanded_components)
159 list(APPEND processed ${lib})
160 # Find the maximum index that doesn't have to be re-processed:
161 while(NOT "${expanded_components}" MATCHES "^${processed}.*" )
162 list(REMOVE_AT processed -1)
163 endwhile()
164 list(LENGTH processed cursor)
165 list(LENGTH expanded_components lst_size)
166 endwhile( cursor LESS lst_size )
167 # Return just the libraries included in this build:
168 set(result)
169 foreach(c ${expanded_components})
170 list(FIND llvm_libs ${c} lib_idx)
171 if( NOT lib_idx LESS 0 )
172 set(result ${result} ${c})
173 endif()
174 endforeach(c)
175 set(${out_libs} ${result} PARENT_SCOPE)
176 endfunction(explicit_map_components_to_libraries)
177
178
179 # The library dependency data is contained in the file
180 # LLVMLibDeps.cmake on this directory. It is automatically generated
181 # by tools/llvm-config/CMakeLists.txt when the build comprises all the
182 # targets and we are on a environment Posix enough to build the
183 # llvm-config script. This, in practice, just excludes MSVC.
184
185 # When you remove or rename a library from the build, be sure to
186 # remove its file from lib/ as well, or the GenLibDeps.pl script will
187 # include it on its analysis!
188
189 # The format generated by GenLibDeps.pl
190
191 # LLVMARMAsmPrinter.o: LLVMARMCodeGen.o libLLVMAsmPrinter.a libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMTarget.a
192
193 # is translated to:
194
195 # set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
196
197 # It is necessary to remove the `lib' prefix and the `.a'.
198
199 # This 'sed' script should do the trick:
200 # 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
201
202 include(LLVMLibDeps)
2727 # We try to include using the current setting of CMAKE_MODULE_PATH,
2828 # which suppossedly was filled by the user with the directory where
2929 # this file was installed:
30 include( LLVMConfig OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED )
30 include( LLVM-Config OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED )
3131
3232 # If failed, we assume that this is an un-installed build:
3333 if( NOT LLVMCONFIG_INCLUDED )
3434 set(CMAKE_MODULE_PATH
3535 ${CMAKE_MODULE_PATH}
3636 "@LLVM_SOURCE_DIR@/cmake/modules")
37 include( LLVMConfig )
37 include( LLVM-Config )
3838 endif()
3939
+0
-203
cmake/modules/LLVMConfig.cmake less more
None function(get_system_libs return_var)
1 # Returns in `return_var' a list of system libraries used by LLVM.
2 if( NOT MSVC )
3 if( MINGW )
4 set(system_libs ${system_libs} imagehlp psapi)
5 elseif( CMAKE_HOST_UNIX )
6 if( HAVE_LIBDL )
7 set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
8 endif()
9 if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
10 set(system_libs ${system_libs} pthread)
11 endif()
12 endif( MINGW )
13 endif( NOT MSVC )
14 set(${return_var} ${system_libs} PARENT_SCOPE)
15 endfunction(get_system_libs)
16
17
18 function(link_system_libs target)
19 get_system_libs(llvm_system_libs)
20 target_link_libraries(${target} ${llvm_system_libs})
21 endfunction(link_system_libs)
22
23
24 function(is_llvm_target_library library return_var)
25 # Sets variable `return_var' to ON if `library' corresponds to a
26 # LLVM supported target. To OFF if it doesn't.
27 set(${return_var} OFF PARENT_SCOPE)
28 string(TOUPPER "${library}" capitalized_lib)
29 string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
30 foreach(t ${targets})
31 if( capitalized_lib STREQUAL t OR
32 capitalized_lib STREQUAL "LLVM${t}" OR
33 capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
34 capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
35 capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
36 capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
37 capitalized_lib STREQUAL "LLVM${t}INFO" )
38 set(${return_var} ON PARENT_SCOPE)
39 break()
40 endif()
41 endforeach()
42 endfunction(is_llvm_target_library)
43
44
45 macro(llvm_config executable)
46 explicit_llvm_config(${executable} ${ARGN})
47 endmacro(llvm_config)
48
49
50 function(explicit_llvm_config executable)
51 set( link_components ${ARGN} )
52
53 explicit_map_components_to_libraries(LIBRARIES ${link_components})
54 target_link_libraries(${executable} ${LIBRARIES})
55 endfunction(explicit_llvm_config)
56
57
58 # This is a variant intended for the final user:
59 function(llvm_map_components_to_libraries OUT_VAR)
60 explicit_map_components_to_libraries(result ${ARGN})
61 get_system_libs(sys_result)
62 set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
63 endfunction(llvm_map_components_to_libraries)
64
65
66 function(explicit_map_components_to_libraries out_libs)
67 set( link_components ${ARGN} )
68 get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
69 string(TOUPPER "${llvm_libs}" capitalized_libs)
70
71 # Expand some keywords:
72 list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
73 list(FIND link_components "engine" engine_required)
74 if( NOT engine_required EQUAL -1 )
75 list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit)
76 if( NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1 )
77 list(APPEND link_components "jit")
78 list(APPEND link_components "native")
79 else()
80 list(APPEND link_components "interpreter")
81 endif()
82 endif()
83 list(FIND link_components "native" native_required)
84 if( NOT native_required EQUAL -1 )
85 if( NOT have_native_backend EQUAL -1 )
86 list(APPEND link_components ${LLVM_NATIVE_ARCH})
87 endif()
88 endif()
89
90 # Translate symbolic component names to real libraries:
91 foreach(c ${link_components})
92 # add codegen, asmprinter, asmparser, disassembler
93 list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
94 if( NOT idx LESS 0 )
95 list(FIND llvm_libs "LLVM${c}CodeGen" idx)
96 if( NOT idx LESS 0 )
97 list(APPEND expanded_components "LLVM${c}CodeGen")
98 else()
99 list(FIND llvm_libs "LLVM${c}" idx)
100 if( NOT idx LESS 0 )
101 list(APPEND expanded_components "LLVM${c}")
102 else()
103 message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
104 endif()
105 endif()
106 list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
107 if( NOT asmidx LESS 0 )
108 list(APPEND expanded_components "LLVM${c}AsmPrinter")
109 endif()
110 list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
111 if( NOT asmidx LESS 0 )
112 list(APPEND expanded_components "LLVM${c}AsmParser")
113 endif()
114 list(FIND llvm_libs "LLVM${c}Info" asmidx)
115 if( NOT asmidx LESS 0 )
116 list(APPEND expanded_components "LLVM${c}Info")
117 endif()
118 list(FIND llvm_libs "LLVM${c}Disassembler" asmidx)
119 if( NOT asmidx LESS 0 )
120 list(APPEND expanded_components "LLVM${c}Disassembler")
121 endif()
122 elseif( c STREQUAL "native" )
123 # already processed
124 elseif( c STREQUAL "nativecodegen" )
125 list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}CodeGen")
126 elseif( c STREQUAL "backend" )
127 # same case as in `native'.
128 elseif( c STREQUAL "engine" )
129 # already processed
130 elseif( c STREQUAL "all" )
131 list(APPEND expanded_components ${llvm_libs})
132 else( NOT idx LESS 0 )
133 # Canonize the component name:
134 string(TOUPPER "${c}" capitalized)
135 list(FIND capitalized_libs LLVM${capitalized} lib_idx)
136 if( lib_idx LESS 0 )
137 # The component is unkown. Maybe is an ommitted target?
138 is_llvm_target_library(${c} iltl_result)
139 if( NOT iltl_result )
140 message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
141 endif()
142 else( lib_idx LESS 0 )
143 list(GET llvm_libs ${lib_idx} canonical_lib)
144 list(APPEND expanded_components ${canonical_lib})
145 endif( lib_idx LESS 0 )
146 endif( NOT idx LESS 0 )
147 endforeach(c)
148 # Expand dependencies while topologically sorting the list of libraries:
149 list(LENGTH expanded_components lst_size)
150 set(cursor 0)
151 set(processed)
152 while( cursor LESS lst_size )
153 list(GET expanded_components ${cursor} lib)
154 list(APPEND expanded_components ${MSVC_LIB_DEPS_${lib}})
155 # Remove duplicates at the front:
156 list(REVERSE expanded_components)
157 list(REMOVE_DUPLICATES expanded_components)
158 list(REVERSE expanded_components)
159 list(APPEND processed ${lib})
160 # Find the maximum index that doesn't have to be re-processed:
161 while(NOT "${expanded_components}" MATCHES "^${processed}.*" )
162 list(REMOVE_AT processed -1)
163 endwhile()
164 list(LENGTH processed cursor)
165 list(LENGTH expanded_components lst_size)
166 endwhile( cursor LESS lst_size )
167 # Return just the libraries included in this build:
168 set(result)
169 foreach(c ${expanded_components})
170 list(FIND llvm_libs ${c} lib_idx)
171 if( NOT lib_idx LESS 0 )
172 set(result ${result} ${c})
173 endif()
174 endforeach(c)
175 set(${out_libs} ${result} PARENT_SCOPE)
176 endfunction(explicit_map_components_to_libraries)
177
178
179 # The library dependency data is contained in the file
180 # LLVMLibDeps.cmake on this directory. It is automatically generated
181 # by tools/llvm-config/CMakeLists.txt when the build comprises all the
182 # targets and we are on a environment Posix enough to build the
183 # llvm-config script. This, in practice, just excludes MSVC.
184
185 # When you remove or rename a library from the build, be sure to
186 # remove its file from lib/ as well, or the GenLibDeps.pl script will
187 # include it on its analysis!
188
189 # The format generated by GenLibDeps.pl
190
191 # LLVMARMAsmPrinter.o: LLVMARMCodeGen.o libLLVMAsmPrinter.a libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMTarget.a
192
193 # is translated to:
194
195 # set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
196
197 # It is necessary to remove the `lib' prefix and the `.a'.
198
199 # This 'sed' script should do the trick:
200 # 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
201
202 include(LLVMLibDeps)
141141
142142 # Regeneration of library dependencies.
143143
144 # See the comments at the end of cmake/modules/LLVMConfig.cmake for
144 # See the comments at the end of cmake/modules/LLVM-Config.cmake for
145145 # notes and guidelines.
146146
147147 set(LLVMLibDeps ${LLVM_MAIN_SRC_DIR}/cmake/modules/LLVMLibDeps.cmake)