1 if( WIN32 AND NOT CYGWIN )
2 # We consider Cygwin as another Unix
6 include(CheckIncludeFile)
7 include(CheckIncludeFileCXX)
8 include(CheckLibraryExists)
9 include(CheckSymbolExists)
10 include(CheckFunctionExists)
11 include(CheckCXXSourceCompiles)
12 include(TestBigEndian)
14 include(CheckCompilerVersion)
15 include(HandleLLVMStdlib)
17 if( UNIX AND NOT (BEOS OR HAIKU) )
18 # Used by check_symbol_exists:
19 set(CMAKE_REQUIRED_LIBRARIES m)
21 # x86_64 FreeBSD 9.2 requires libcxxrt to be specified explicitly.
22 if( CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE" AND
23 CMAKE_SIZEOF_VOID_P EQUAL 8 )
24 list(APPEND CMAKE_REQUIRED_LIBRARIES "cxxrt")
27 # Helper macros and functions
28 macro(add_cxx_include result files)
30 foreach (file_name ${files})
31 set(${result} "${${result}}#include<${file_name}>\n")
33 endmacro(add_cxx_include files result)
35 function(check_type_exists type files variable)
36 add_cxx_include(includes "${files}")
37 CHECK_CXX_SOURCE_COMPILES("
38 ${includes} ${type} typeVar;
46 check_include_file(dirent.h HAVE_DIRENT_H)
47 check_include_file(dlfcn.h HAVE_DLFCN_H)
48 check_include_file(errno.h HAVE_ERRNO_H)
49 check_include_file(fcntl.h HAVE_FCNTL_H)
50 check_include_file(inttypes.h HAVE_INTTYPES_H)
51 check_include_file(link.h HAVE_LINK_H)
52 check_include_file(malloc.h HAVE_MALLOC_H)
53 check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
54 check_include_file(ndir.h HAVE_NDIR_H)
55 if( NOT PURE_WINDOWS )
56 check_include_file(pthread.h HAVE_PTHREAD_H)
58 check_include_file(signal.h HAVE_SIGNAL_H)
59 check_include_file(stdint.h HAVE_STDINT_H)
60 check_include_file(sys/dir.h HAVE_SYS_DIR_H)
61 check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
62 check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
63 check_include_file(sys/ndir.h HAVE_SYS_NDIR_H)
64 check_include_file(sys/param.h HAVE_SYS_PARAM_H)
65 check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
66 check_include_file(sys/stat.h HAVE_SYS_STAT_H)
67 check_include_file(sys/time.h HAVE_SYS_TIME_H)
68 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
69 check_include_file(sys/uio.h HAVE_SYS_UIO_H)
70 check_include_file(termios.h HAVE_TERMIOS_H)
71 check_include_file(unistd.h HAVE_UNISTD_H)
72 check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
73 check_include_file(zlib.h HAVE_ZLIB_H)
74 check_include_file(fenv.h HAVE_FENV_H)
75 check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT)
76 check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)
78 check_include_file(mach/mach.h HAVE_MACH_MACH_H)
79 check_include_file(histedit.h HAVE_HISTEDIT_H)
80 check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H)
82 include(CheckCSourceCompiles)
83 CHECK_C_SOURCE_COMPILES("
84 static const char *__crashreporter_info__ = 0;
85 asm(\".desc ___crashreporter_info__, 0x10\");
86 int main() { return 0; }"
87 HAVE_CRASHREPORTER_INFO)
90 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
91 check_include_file(linux/magic.h HAVE_LINUX_MAGIC_H)
92 if(NOT HAVE_LINUX_MAGIC_H)
93 # older kernels use split files
94 check_include_file(linux/nfs_fs.h HAVE_LINUX_NFS_FS_H)
95 check_include_file(linux/smb.h HAVE_LINUX_SMB_H)
100 if( NOT PURE_WINDOWS )
101 check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
103 check_library_exists(pthread pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC)
104 check_library_exists(pthread pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT)
105 check_library_exists(pthread pthread_mutex_lock "" HAVE_PTHREAD_MUTEX_LOCK)
107 # this could be Android
108 check_library_exists(c pthread_create "" PTHREAD_IN_LIBC)
110 check_library_exists(c pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC)
111 check_library_exists(c pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT)
112 check_library_exists(c pthread_mutex_lock "" HAVE_PTHREAD_MUTEX_LOCK)
115 check_library_exists(dl dlopen "" HAVE_LIBDL)
116 check_library_exists(rt clock_gettime "" HAVE_LIBRT)
120 # We want to find pthreads library and at the moment we do want to
121 # have it reported as '-l<lib>' instead of '-pthread'.
122 # TODO: switch to -pthread once the rest of the build system can deal with it.
123 set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
124 set(THREADS_HAVE_PTHREAD_ARG Off)
125 find_package(Threads REQUIRED)
126 set(LLVM_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
129 # Don't look for these libraries on Windows. Also don't look for them if we're
130 # using MSan, since uninstrumented third party code may call MSan interceptors
131 # like strlen, leading to false positives.
132 if( NOT PURE_WINDOWS AND NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
133 if (LLVM_ENABLE_ZLIB)
134 check_library_exists(z compress2 "" HAVE_LIBZ)
138 # Skip libedit if using ASan as it contains memory leaks.
139 if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
140 check_library_exists(edit el_init "" HAVE_LIBEDIT)
144 if(LLVM_ENABLE_TERMINFO)
146 foreach(library tinfo terminfo curses ncurses ncursesw)
147 string(TOUPPER ${library} library_suffix)
148 check_library_exists(${library} setupterm "" HAVE_TERMINFO_${library_suffix})
149 if(HAVE_TERMINFO_${library_suffix})
151 set(TERMINFO_LIBS "${library}")
159 find_library(ICONV_LIBRARY_PATH NAMES iconv libiconv libiconv-2 c)
160 set(LLVM_LIBXML2_ENABLED 0)
162 if((LLVM_ENABLE_LIBXML2) AND (CMAKE_SYSTEM_NAME MATCHES "Linux") AND (ICONV_LIBRARY_PATH) AND (NOT LLVM_NATIVE_ARCH MATCHES "i686"))
163 find_package(LibXml2)
165 set(LLVM_LIBXML2_ENABLED 1)
166 include_directories(${LIBXML2_INCLUDE_DIR})
167 set(LIBXML2_LIBS "xml2")
172 check_library_exists(xar xar_open "" HAVE_LIBXAR)
178 check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
179 find_package(Backtrace)
180 set(HAVE_BACKTRACE ${Backtrace_FOUND})
181 set(BACKTRACE_HEADER ${Backtrace_HEADER})
182 check_symbol_exists(_Unwind_Backtrace "unwind.h" HAVE__UNWIND_BACKTRACE)
183 check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
184 check_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
185 check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
186 check_symbol_exists(setrlimit sys/resource.h HAVE_SETRLIMIT)
187 check_symbol_exists(isatty unistd.h HAVE_ISATTY)
188 check_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
189 check_symbol_exists(futimes sys/time.h HAVE_FUTIMES)
190 check_symbol_exists(posix_fallocate fcntl.h HAVE_POSIX_FALLOCATE)
191 # AddressSanitizer conflicts with lib/Support/Unix/Signals.inc
192 # Avoid sigaltstack on Apple platforms, where backtrace() cannot handle it
193 # (rdar://7089625) and _Unwind_Backtrace is unusable because it cannot unwind
194 # past the signal handler after an assertion failure (rdar://29866587).
195 if( HAVE_SIGNAL_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*" AND NOT APPLE )
196 check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK)
199 check_symbol_exists(writev sys/uio.h HAVE_WRITEV)
201 set(CMAKE_REQUIRED_DEFINITIONS "-D_LARGEFILE64_SOURCE")
202 check_symbol_exists(lseek64 "sys/types.h;unistd.h" HAVE_LSEEK64)
203 set(CMAKE_REQUIRED_DEFINITIONS "")
204 check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
205 check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
206 check_symbol_exists(malloc_zone_statistics malloc/malloc.h
207 HAVE_MALLOC_ZONE_STATISTICS)
208 check_symbol_exists(mkdtemp "stdlib.h;unistd.h" HAVE_MKDTEMP)
209 check_symbol_exists(mkstemp "stdlib.h;unistd.h" HAVE_MKSTEMP)
210 check_symbol_exists(mktemp "stdlib.h;unistd.h" HAVE_MKTEMP)
211 check_symbol_exists(getcwd unistd.h HAVE_GETCWD)
212 check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
213 check_symbol_exists(getrlimit "sys/types.h;sys/time.h;sys/resource.h" HAVE_GETRLIMIT)
214 check_symbol_exists(posix_spawn spawn.h HAVE_POSIX_SPAWN)
215 check_symbol_exists(pread unistd.h HAVE_PREAD)
216 check_symbol_exists(realpath stdlib.h HAVE_REALPATH)
217 check_symbol_exists(sbrk unistd.h HAVE_SBRK)
218 check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL)
219 check_symbol_exists(strerror string.h HAVE_STRERROR)
220 check_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
221 check_symbol_exists(strerror_s string.h HAVE_DECL_STRERROR_S)
222 check_symbol_exists(setenv stdlib.h HAVE_SETENV)
224 check_symbol_exists(_chsize_s io.h HAVE__CHSIZE_S)
226 check_function_exists(_alloca HAVE__ALLOCA)
227 check_function_exists(__alloca HAVE___ALLOCA)
228 check_function_exists(__chkstk HAVE___CHKSTK)
229 check_function_exists(__chkstk_ms HAVE___CHKSTK_MS)
230 check_function_exists(___chkstk HAVE____CHKSTK)
231 check_function_exists(___chkstk_ms HAVE____CHKSTK_MS)
233 check_function_exists(__ashldi3 HAVE___ASHLDI3)
234 check_function_exists(__ashrdi3 HAVE___ASHRDI3)
235 check_function_exists(__divdi3 HAVE___DIVDI3)
236 check_function_exists(__fixdfdi HAVE___FIXDFDI)
237 check_function_exists(__fixsfdi HAVE___FIXSFDI)
238 check_function_exists(__floatdidf HAVE___FLOATDIDF)
239 check_function_exists(__lshrdi3 HAVE___LSHRDI3)
240 check_function_exists(__moddi3 HAVE___MODDI3)
241 check_function_exists(__udivdi3 HAVE___UDIVDI3)
242 check_function_exists(__umoddi3 HAVE___UMODDI3)
244 check_function_exists(__main HAVE___MAIN)
245 check_function_exists(__cmpdi2 HAVE___CMPDI2)
249 list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
251 check_symbol_exists(dlopen dlfcn.h HAVE_DLOPEN)
252 check_symbol_exists(dladdr dlfcn.h HAVE_DLADDR)
254 list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl)
258 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
259 if( LLVM_USING_GLIBC )
260 add_definitions( -D_GNU_SOURCE )
262 # This check requires _GNU_SOURCE
264 check_library_exists(pthread pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP)
265 check_library_exists(pthread pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP)
266 elseif(PTHREAD_IN_LIBC)
267 check_library_exists(c pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP)
268 check_library_exists(c pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP)
271 set(headers "sys/types.h")
274 set(headers ${headers} "inttypes.h")
278 set(headers ${headers} "stdint.h")
281 check_type_exists(int64_t "${headers}" HAVE_INT64_T)
282 check_type_exists(uint64_t "${headers}" HAVE_UINT64_T)
283 check_type_exists(u_int64_t "${headers}" HAVE_U_INT64_T)
285 # available programs checks
286 function(llvm_find_program name)
287 string(TOUPPER ${name} NAME)
288 string(REGEX REPLACE "\\." "_" NAME ${NAME})
290 find_program(LLVM_PATH_${NAME} NAMES ${ARGV})
291 mark_as_advanced(LLVM_PATH_${NAME})
292 if(LLVM_PATH_${NAME})
293 set(HAVE_${NAME} 1 CACHE INTERNAL "Is ${name} available ?")
294 mark_as_advanced(HAVE_${NAME})
295 else(LLVM_PATH_${NAME})
296 set(HAVE_${NAME} "" CACHE INTERNAL "Is ${name} available ?")
297 endif(LLVM_PATH_${NAME})
300 if (LLVM_ENABLE_DOXYGEN)
301 llvm_find_program(dot)
304 if( LLVM_ENABLE_FFI )
305 find_path(FFI_INCLUDE_PATH ffi.h PATHS ${FFI_INCLUDE_DIR})
306 if( EXISTS "${FFI_INCLUDE_PATH}/ffi.h" )
307 set(FFI_HEADER ffi.h CACHE INTERNAL "")
308 set(HAVE_FFI_H 1 CACHE INTERNAL "")
310 find_path(FFI_INCLUDE_PATH ffi/ffi.h PATHS ${FFI_INCLUDE_DIR})
311 if( EXISTS "${FFI_INCLUDE_PATH}/ffi/ffi.h" )
312 set(FFI_HEADER ffi/ffi.h CACHE INTERNAL "")
313 set(HAVE_FFI_FFI_H 1 CACHE INTERNAL "")
318 message(FATAL_ERROR "libffi includes are not found.")
321 find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR})
322 if( NOT FFI_LIBRARY_PATH )
323 message(FATAL_ERROR "libffi is not found.")
326 list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
327 list(APPEND CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH})
328 check_symbol_exists(ffi_call ${FFI_HEADER} HAVE_FFI_CALL)
329 list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH})
330 list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
332 unset(HAVE_FFI_FFI_H CACHE)
333 unset(HAVE_FFI_H CACHE)
334 unset(HAVE_FFI_CALL CACHE)
335 endif( LLVM_ENABLE_FFI )
337 # Define LLVM_HAS_ATOMICS if gcc or MSVC atomic builtins are supported.
340 if( LLVM_ENABLE_PIC )
344 check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG)
345 if(SUPPORTS_NO_PIE_FLAG)
346 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
350 check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG)
351 check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments"
352 SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG)
354 set(USE_NO_MAYBE_UNINITIALIZED 0)
355 set(USE_NO_UNINITIALIZED 0)
357 # Disable gcc's potentially uninitialized use analysis as it presents lots of
359 if (CMAKE_COMPILER_IS_GNUCXX)
360 check_cxx_compiler_flag("-Wmaybe-uninitialized" HAS_MAYBE_UNINITIALIZED)
361 if (HAS_MAYBE_UNINITIALIZED)
362 set(USE_NO_MAYBE_UNINITIALIZED 1)
364 # Only recent versions of gcc make the distinction between -Wuninitialized
365 # and -Wmaybe-uninitialized. If -Wmaybe-uninitialized isn't supported, just
366 # turn off all uninitialized use warnings.
367 check_cxx_compiler_flag("-Wuninitialized" HAS_UNINITIALIZED)
368 set(USE_NO_UNINITIALIZED ${HAS_UNINITIALIZED})
372 # By default, we target the host, but this can be overridden at CMake
374 include(GetHostTriple)
375 get_host_triple(LLVM_INFERRED_HOST_TRIPLE)
377 set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING
378 "Host on which LLVM binaries will run")
380 # Determine the native architecture.
381 string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)
382 if( LLVM_NATIVE_ARCH STREQUAL "host" )
383 string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOST_TRIPLE})
386 if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86")
387 set(LLVM_NATIVE_ARCH X86)
388 elseif (LLVM_NATIVE_ARCH STREQUAL "x86")
389 set(LLVM_NATIVE_ARCH X86)
390 elseif (LLVM_NATIVE_ARCH STREQUAL "amd64")
391 set(LLVM_NATIVE_ARCH X86)
392 elseif (LLVM_NATIVE_ARCH STREQUAL "x86_64")
393 set(LLVM_NATIVE_ARCH X86)
394 elseif (LLVM_NATIVE_ARCH MATCHES "sparc")
395 set(LLVM_NATIVE_ARCH Sparc)
396 elseif (LLVM_NATIVE_ARCH MATCHES "powerpc")
397 set(LLVM_NATIVE_ARCH PowerPC)
398 elseif (LLVM_NATIVE_ARCH MATCHES "aarch64")
399 set(LLVM_NATIVE_ARCH AArch64)
400 elseif (LLVM_NATIVE_ARCH MATCHES "arm64")
401 set(LLVM_NATIVE_ARCH AArch64)
402 elseif (LLVM_NATIVE_ARCH MATCHES "arm")
403 set(LLVM_NATIVE_ARCH ARM)
404 elseif (LLVM_NATIVE_ARCH MATCHES "mips")
405 set(LLVM_NATIVE_ARCH Mips)
406 elseif (LLVM_NATIVE_ARCH MATCHES "xcore")
407 set(LLVM_NATIVE_ARCH XCore)
408 elseif (LLVM_NATIVE_ARCH MATCHES "msp430")
409 set(LLVM_NATIVE_ARCH MSP430)
410 elseif (LLVM_NATIVE_ARCH MATCHES "hexagon")
411 set(LLVM_NATIVE_ARCH Hexagon)
412 elseif (LLVM_NATIVE_ARCH MATCHES "s390x")
413 set(LLVM_NATIVE_ARCH SystemZ)
414 elseif (LLVM_NATIVE_ARCH MATCHES "wasm32")
415 set(LLVM_NATIVE_ARCH WebAssembly)
416 elseif (LLVM_NATIVE_ARCH MATCHES "wasm64")
417 set(LLVM_NATIVE_ARCH WebAssembly)
419 message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}")
422 # If build targets includes "host", then replace with native architecture.
423 list(FIND LLVM_TARGETS_TO_BUILD "host" idx)
425 list(REMOVE_AT LLVM_TARGETS_TO_BUILD ${idx})
426 list(APPEND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH})
427 list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
430 list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX)
431 if (NATIVE_ARCH_IDX EQUAL -1)
433 "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code")
435 message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}")
436 set(LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target)
437 set(LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo)
438 set(LLVM_NATIVE_TARGETMC LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC)
439 set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter)
441 # We don't have an ASM parser for all architectures yet.
442 if (EXISTS ${PROJECT_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/CMakeLists.txt)
443 set(LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser)
446 # We don't have an disassembler for all architectures yet.
447 if (EXISTS ${PROJECT_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/CMakeLists.txt)
448 set(LLVM_NATIVE_DISASSEMBLER LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler)
454 set(HAVE_LIBSHELL32 1)
455 # TODO: Check existence of libraries.
456 # include(CheckLibraryExists)
459 if (NOT HAVE_STRTOLL)
460 # Use _strtoi64 if strtoll is not available.
461 check_symbol_exists(_strtoi64 stdlib.h have_strtoi64)
464 set(strtoll "_strtoi64")
465 set(strtoull "_strtoui64")
471 set(stricmp "_stricmp")
472 set(strdup "_strdup")
474 # See if the DIA SDK is available and usable.
475 set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")
477 # Due to a bug in MSVC 2013's installation software, it is possible
478 # for MSVC 2013 to write the DIA SDK into the Visual Studio 2012
479 # install directory. If this happens, the installation is corrupt
480 # and there's nothing we can do. It happens with enough frequency
481 # though that we should handle it. We do so by simply checking that
482 # the DIA SDK folder exists. Should this happen you will need to
483 # uninstall VS 2012 and then re-install VS 2013.
484 if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR})
490 option(LLVM_ENABLE_DIA_SDK "Use MSVC DIA SDK for debugging if available."
493 if(LLVM_ENABLE_DIA_SDK AND NOT HAVE_DIA_SDK)
494 message(FATAL_ERROR "DIA SDK not found. If you have both VS 2012 and 2013 installed, you may need to uninstall the former and re-install the latter afterwards.")
497 set(LLVM_ENABLE_DIA_SDK 0)
500 # FIXME: Signal handler return type, currently hardcoded to 'void'
503 if( LLVM_ENABLE_THREADS )
504 # Check if threading primitives aren't supported on this platform
505 if( NOT HAVE_PTHREAD_H AND NOT WIN32 )
506 set(LLVM_ENABLE_THREADS 0)
510 if( LLVM_ENABLE_THREADS )
511 message(STATUS "Threads enabled.")
512 else( LLVM_ENABLE_THREADS )
513 message(STATUS "Threads disabled.")
516 if (LLVM_ENABLE_ZLIB )
517 # Check if zlib is available in the system.
518 if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ )
519 set(LLVM_ENABLE_ZLIB 0)
523 if (LLVM_ENABLE_DOXYGEN)
524 message(STATUS "Doxygen enabled.")
525 find_package(Doxygen REQUIRED)
528 # If we find doxygen and we want to enable doxygen by default create a
529 # global aggregate doxygen target for generating llvm and any/all
530 # subprojects doxygen documentation.
532 add_custom_target(doxygen ALL)
535 option(LLVM_DOXYGEN_EXTERNAL_SEARCH "Enable doxygen external search." OFF)
536 if (LLVM_DOXYGEN_EXTERNAL_SEARCH)
537 set(LLVM_DOXYGEN_SEARCHENGINE_URL "" CACHE STRING "URL to use for external search.")
538 set(LLVM_DOXYGEN_SEARCH_MAPPINGS "" CACHE STRING "Doxygen Search Mappings")
542 message(STATUS "Doxygen disabled.")
545 set(LLVM_BINDINGS "")
547 message(STATUS "Go bindings disabled.")
549 find_program(GO_EXECUTABLE NAMES go DOC "go executable")
550 if(GO_EXECUTABLE STREQUAL "GO_EXECUTABLE-NOTFOUND")
551 message(STATUS "Go bindings disabled.")
553 execute_process(COMMAND ${GO_EXECUTABLE} run ${PROJECT_SOURCE_DIR}/bindings/go/conftest.go
554 RESULT_VARIABLE GO_CONFTEST)
555 if(GO_CONFTEST STREQUAL "0")
556 set(LLVM_BINDINGS "${LLVM_BINDINGS} go")
557 message(STATUS "Go bindings enabled.")
559 message(STATUS "Go bindings disabled, need at least Go 1.2.")
564 find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold ld.gold ${LLVM_DEFAULT_TARGET_TRIPLE}-ld ld DOC "The gold linker")
565 set(LLVM_BINUTILS_INCDIR "" CACHE PATH
566 "PATH to binutils/include containing plugin-api.h for gold plugin.")
568 if(CMAKE_HOST_APPLE AND APPLE)
570 find_program(CMAKE_XCRUN NAMES xcrun)
573 execute_process(COMMAND ${CMAKE_XCRUN} -find ld
574 OUTPUT_VARIABLE LD64_EXECUTABLE
575 OUTPUT_STRIP_TRAILING_WHITESPACE)
577 find_program(LD64_EXECUTABLE NAMES ld DOC "The ld64 linker")
581 set(LD64_EXECUTABLE ${LD64_EXECUTABLE} CACHE PATH "ld64 executable")
582 message(STATUS "Found ld64 - ${LD64_EXECUTABLE}")
586 # Keep the version requirements in sync with bindings/ocaml/README.txt.
590 message(STATUS "OCaml bindings disabled.")
593 if( NOT OCAML_FOUND )
594 message(STATUS "OCaml bindings disabled.")
596 if( OCAML_VERSION VERSION_LESS "4.00.0" )
597 message(STATUS "OCaml bindings disabled, need OCaml >=4.00.0.")
599 find_ocamlfind_package(ctypes VERSION 0.4 OPTIONAL)
600 if( HAVE_OCAML_CTYPES )
601 message(STATUS "OCaml bindings enabled.")
602 find_ocamlfind_package(oUnit VERSION 2 OPTIONAL)
603 set(LLVM_BINDINGS "${LLVM_BINDINGS} ocaml")
605 set(LLVM_OCAML_INSTALL_PATH "${OCAML_STDLIB_PATH}" CACHE STRING
606 "Install directory for LLVM OCaml packages")
608 message(STATUS "OCaml bindings disabled, need ctypes >=0.4.")
614 string(REPLACE " " ";" LLVM_BINDINGS_LIST "${LLVM_BINDINGS}")