llvm.org GIT mirror llvm / 5969379
Handles libffi on the CMake build. Patch by arrowdodger! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123976 91177308-0d34-0410-b5e6-96231b3b80d8 Oscar Fuentes 8 years ago
5 changed file(s) with 58 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
112112 if(LLVM_ENABLE_TIMESTAMPS)
113113 set(ENABLE_TIMESTAMPS 1)
114114 endif()
115
116 option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF)
117 set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so")
118 set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h")
115119
116120 set(C_INCLUDE_DIRS "" CACHE STRING
117121 "Colon separated list of directories clang will search for headers.")
189189 llvm_find_program(dot)
190190 llvm_find_program(dotty)
191191
192 if( LLVM_ENABLE_FFI )
193 find_path(FFI_INCLUDE_PATH ffi.h PATHS ${FFI_INCLUDE_DIR})
194 if( FFI_INCLUDE_PATH )
195 set(FFI_HEADER ffi.h CACHE INTERNAL "")
196 set(HAVE_FFI_H 1 CACHE INTERNAL "")
197 else()
198 find_path(FFI_INCLUDE_PATH ffi/ffi.h PATHS ${FFI_INCLUDE_DIR})
199 if( FFI_INCLUDE_PATH )
200 set(FFI_HEADER ffi/ffi.h CACHE INTERNAL "")
201 set(HAVE_FFI_FFI_H 1 CACHE INTERNAL "")
202 endif()
203 endif()
204
205 if( NOT FFI_HEADER )
206 message(FATAL_ERROR "libffi includes are not found.")
207 endif()
208
209 find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR})
210 if( NOT FFI_LIBRARY_PATH )
211 message(FATAL_ERROR "libffi is not found.")
212 endif()
213
214 list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
215 list(APPEND CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH})
216 check_symbol_exists(ffi_call ${FFI_HEADER} HAVE_FFI_CALL)
217 list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH})
218 list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
219 endif( LLVM_ENABLE_FFI )
220
192221 # Define LLVM_MULTITHREADED if gcc atomic builtins exists.
193222 include(CheckAtomic)
194223
337337 By default, "-sv --no-progress-bar"
338338 on Visual C++ and Xcode,
339339 "-sv" on others.
340
341
LLVM_ENABLE_FFI:BOOL
342
Indicates whether LLVM Interpreter will be linked with Foreign
343 Function Interface library. If the library or its headers are
344 installed on a custom location, you can set the variables
345 FFI_INCLUDE_DIR and FFI_LIBRARY_DIR. Defaults to OFF.
340346
341347
342348
129129 #cmakedefine HAVE_FENV_H ${HAVE_FENV_H}
130130
131131 /* Define if libffi is available on this platform. */
132 #undef HAVE_FFI_CALL
132 #cmakedefine HAVE_FFI_CALL ${HAVE_FFI_CALL}
133133
134134 /* Define to 1 if you have the header file. */
135 #undef HAVE_FFI_FFI_H
135 #cmakedefine HAVE_FFI_FFI_H ${HAVE_FFI_FFI_H}
136136
137137 /* Define to 1 if you have the header file. */
138 #undef HAVE_FFI_H
138 #cmakedefine HAVE_FFI_H ${HAVE_FFI_H}
139139
140140 /* Set to 1 if the finite function is found in */
141141 #cmakedefine HAVE_FINITE_IN_IEEEFP_H ${HAVE_FINITE_IN_IEEEFP_H}
0 # If the user required a custom path for ffi headers, use it on its
1 # abolute form (see config-ix.cmake):
2 if( FFI_INCLUDE_DIR )
3 include_directories( ${FFI_INCLUDE_PATH} )
4 endif()
5
6 # If the user required a custom path for libffi, use it on its abolute
7 # form (see config-ix.cmake):
8 if( FFI_LIBRARY_DIR )
9 link_directories( ${FFI_LIBRARY_PATH} )
10 endif()
11
12 add_llvm_library(LLVMInterpreter
113 Execution.cpp
214 ExternalFunctions.cpp
315 Interpreter.cpp
416 )
17
18 if( LLVM_ENABLE_FFI )
19 target_link_libraries( LLVMInterpreter ffi )
20 endif()