Oscar Fuentes | 2761c7a | 2011-02-04 05:40:04 +0000 | [diff] [blame] | 1 | if( WIN32 AND NOT CYGWIN ) |
| 2 | # We consider Cygwin as another Unix |
| 3 | set(PURE_WINDOWS 1) |
| 4 | endif() |
| 5 | |
Douglas Gregor | f99626e | 2009-10-01 17:25:36 +0000 | [diff] [blame] | 6 | include(CheckIncludeFile) |
Benjamin Kramer | ff2be22 | 2013-05-03 14:48:29 +0000 | [diff] [blame] | 7 | include(CheckIncludeFileCXX) |
Douglas Gregor | f99626e | 2009-10-01 17:25:36 +0000 | [diff] [blame] | 8 | include(CheckLibraryExists) |
| 9 | include(CheckSymbolExists) |
| 10 | include(CheckFunctionExists) |
| 11 | include(CheckCXXSourceCompiles) |
Michael J. Spencer | b550b66 | 2010-10-21 20:28:21 +0000 | [diff] [blame] | 12 | include(TestBigEndian) |
Douglas Gregor | f99626e | 2009-10-01 17:25:36 +0000 | [diff] [blame] | 13 | |
Reid Kleckner | 9fac19f | 2016-03-02 16:42:56 +0000 | [diff] [blame] | 14 | include(CheckCompilerVersion) |
Jordan Rose | 31c5b7b | 2014-02-05 00:02:37 +0000 | [diff] [blame] | 15 | include(HandleLLVMStdlib) |
| 16 | |
Renato Golin | 9590c53 | 2016-02-26 17:01:45 +0000 | [diff] [blame] | 17 | if( UNIX AND NOT (BEOS OR HAIKU) ) |
Oscar Fuentes | d533e1d | 2009-11-12 05:36:09 +0000 | [diff] [blame] | 18 | # Used by check_symbol_exists: |
| 19 | set(CMAKE_REQUIRED_LIBRARIES m) |
| 20 | endif() |
Viktor Kutuzov | 6bd3229 | 2014-04-09 11:43:34 +0000 | [diff] [blame] | 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") |
| 25 | endif() |
Oscar Fuentes | d533e1d | 2009-11-12 05:36:09 +0000 | [diff] [blame] | 26 | |
Douglas Gregor | f99626e | 2009-10-01 17:25:36 +0000 | [diff] [blame] | 27 | # Helper macros and functions |
| 28 | macro(add_cxx_include result files) |
| 29 | set(${result} "") |
| 30 | foreach (file_name ${files}) |
| 31 | set(${result} "${${result}}#include<${file_name}>\n") |
| 32 | endforeach() |
| 33 | endmacro(add_cxx_include files result) |
| 34 | |
| 35 | function(check_type_exists type files variable) |
| 36 | add_cxx_include(includes "${files}") |
| 37 | CHECK_CXX_SOURCE_COMPILES(" |
| 38 | ${includes} ${type} typeVar; |
| 39 | int main() { |
| 40 | return 0; |
| 41 | } |
| 42 | " ${variable}) |
| 43 | endfunction() |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 44 | |
| 45 | # include checks |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 46 | check_include_file(dirent.h HAVE_DIRENT_H) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 47 | check_include_file(dlfcn.h HAVE_DLFCN_H) |
| 48 | check_include_file(errno.h HAVE_ERRNO_H) |
| 49 | check_include_file(execinfo.h HAVE_EXECINFO_H) |
| 50 | check_include_file(fcntl.h HAVE_FCNTL_H) |
| 51 | check_include_file(inttypes.h HAVE_INTTYPES_H) |
| 52 | check_include_file(limits.h HAVE_LIMITS_H) |
Alexey Samsonov | 8a584bb | 2014-10-10 22:06:59 +0000 | [diff] [blame] | 53 | check_include_file(link.h HAVE_LINK_H) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 54 | check_include_file(malloc.h HAVE_MALLOC_H) |
| 55 | check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 56 | check_include_file(ndir.h HAVE_NDIR_H) |
Oscar Fuentes | 2761c7a | 2011-02-04 05:40:04 +0000 | [diff] [blame] | 57 | if( NOT PURE_WINDOWS ) |
Oscar Fuentes | 1a0bfb6 | 2009-11-05 18:57:56 +0000 | [diff] [blame] | 58 | check_include_file(pthread.h HAVE_PTHREAD_H) |
| 59 | endif() |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 60 | check_include_file(signal.h HAVE_SIGNAL_H) |
| 61 | check_include_file(stdint.h HAVE_STDINT_H) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 62 | check_include_file(sys/dir.h HAVE_SYS_DIR_H) |
Douglas Gregor | 1543661 | 2009-05-11 18:05:52 +0000 | [diff] [blame] | 63 | check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 64 | check_include_file(sys/mman.h HAVE_SYS_MMAN_H) |
| 65 | check_include_file(sys/ndir.h HAVE_SYS_NDIR_H) |
| 66 | check_include_file(sys/param.h HAVE_SYS_PARAM_H) |
| 67 | check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H) |
| 68 | check_include_file(sys/stat.h HAVE_SYS_STAT_H) |
| 69 | check_include_file(sys/time.h HAVE_SYS_TIME_H) |
Jeroen Ketema | a689721 | 2016-04-07 08:36:13 +0000 | [diff] [blame^] | 70 | check_include_file(sys/types.h HAVE_SYS_TYPES_H) |
Oscar Fuentes | ed27ead | 2011-02-03 04:23:07 +0000 | [diff] [blame] | 71 | check_include_file(sys/uio.h HAVE_SYS_UIO_H) |
Douglas Gregor | b81294d | 2009-05-18 17:21:34 +0000 | [diff] [blame] | 72 | check_include_file(termios.h HAVE_TERMIOS_H) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 73 | check_include_file(unistd.h HAVE_UNISTD_H) |
| 74 | check_include_file(utime.h HAVE_UTIME_H) |
Jeffrey Yasskin | 3ddd88f | 2010-03-15 04:57:55 +0000 | [diff] [blame] | 75 | check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H) |
Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 76 | check_include_file(zlib.h HAVE_ZLIB_H) |
Oscar Fuentes | bcc8b2f | 2010-09-17 20:30:48 +0000 | [diff] [blame] | 77 | check_include_file(fenv.h HAVE_FENV_H) |
Joerg Sonnenberger | 8a1177f | 2013-03-25 13:13:33 +0000 | [diff] [blame] | 78 | check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT) |
| 79 | check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT) |
| 80 | |
Oscar Fuentes | e65ed1c | 2011-01-17 16:35:14 +0000 | [diff] [blame] | 81 | check_include_file(mach/mach.h HAVE_MACH_MACH_H) |
| 82 | check_include_file(mach-o/dyld.h HAVE_MACH_O_DYLD_H) |
Chris Bieneman | b2d7149 | 2015-01-30 00:10:43 +0000 | [diff] [blame] | 83 | check_include_file(histedit.h HAVE_HISTEDIT_H) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 84 | |
Rui Ueyama | 292fb6d | 2014-10-27 08:16:18 +0000 | [diff] [blame] | 85 | # size_t must be defined before including cxxabi.h on FreeBSD 10.0. |
| 86 | check_cxx_source_compiles(" |
| 87 | #include <stddef.h> |
| 88 | #include <cxxabi.h> |
| 89 | int main() { return 0; } |
| 90 | " HAVE_CXXABI_H) |
| 91 | |
Oscar Fuentes | a6e2006 | 2009-05-06 14:40:37 +0000 | [diff] [blame] | 92 | # library checks |
Oscar Fuentes | 2761c7a | 2011-02-04 05:40:04 +0000 | [diff] [blame] | 93 | if( NOT PURE_WINDOWS ) |
Oscar Fuentes | 1a0bfb6 | 2009-11-05 18:57:56 +0000 | [diff] [blame] | 94 | check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD) |
Evgeniy Stepanov | c439a42 | 2012-09-04 09:14:45 +0000 | [diff] [blame] | 95 | if (HAVE_LIBPTHREAD) |
| 96 | check_library_exists(pthread pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC) |
| 97 | check_library_exists(pthread pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT) |
| 98 | check_library_exists(pthread pthread_mutex_lock "" HAVE_PTHREAD_MUTEX_LOCK) |
| 99 | else() |
| 100 | # this could be Android |
| 101 | check_library_exists(c pthread_create "" PTHREAD_IN_LIBC) |
| 102 | if (PTHREAD_IN_LIBC) |
| 103 | check_library_exists(c pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC) |
| 104 | check_library_exists(c pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT) |
| 105 | check_library_exists(c pthread_mutex_lock "" HAVE_PTHREAD_MUTEX_LOCK) |
| 106 | endif() |
| 107 | endif() |
Oscar Fuentes | 1a0bfb6 | 2009-11-05 18:57:56 +0000 | [diff] [blame] | 108 | check_library_exists(dl dlopen "" HAVE_LIBDL) |
Chandler Carruth | ef7f968 | 2013-01-04 23:19:55 +0000 | [diff] [blame] | 109 | check_library_exists(rt clock_gettime "" HAVE_LIBRT) |
Reid Kleckner | 61bc356 | 2015-11-19 00:05:21 +0000 | [diff] [blame] | 110 | endif() |
| 111 | |
Rafael Espindola | 5cd721a | 2016-03-01 15:54:40 +0000 | [diff] [blame] | 112 | if(HAVE_LIBPTHREAD) |
| 113 | set(PTHREAD_LIB pthread) |
| 114 | endif() |
| 115 | |
Reid Kleckner | 61bc356 | 2015-11-19 00:05:21 +0000 | [diff] [blame] | 116 | # Don't look for these libraries on Windows. Also don't look for them if we're |
| 117 | # using MSan, since uninstrmented third party code may call MSan interceptors |
| 118 | # like strlen, leading to false positives. |
| 119 | if( NOT PURE_WINDOWS AND NOT LLVM_USE_SANITIZER MATCHES "Memory.*") |
Alexey Samsonov | 068fc8a | 2013-04-23 10:17:34 +0000 | [diff] [blame] | 120 | if (LLVM_ENABLE_ZLIB) |
| 121 | check_library_exists(z compress2 "" HAVE_LIBZ) |
| 122 | else() |
| 123 | set(HAVE_LIBZ 0) |
| 124 | endif() |
Chris Bieneman | b2d7149 | 2015-01-30 00:10:43 +0000 | [diff] [blame] | 125 | if (HAVE_HISTEDIT_H) |
| 126 | check_library_exists(edit el_init "" HAVE_LIBEDIT) |
| 127 | endif() |
Chandler Carruth | 9121985 | 2013-08-12 10:40:11 +0000 | [diff] [blame] | 128 | if(LLVM_ENABLE_TERMINFO) |
Chandler Carruth | f11f1e4 | 2013-08-12 09:49:17 +0000 | [diff] [blame] | 129 | set(HAVE_TERMINFO 0) |
Joerg Sonnenberger | 4e5a399 | 2013-08-17 11:06:00 +0000 | [diff] [blame] | 130 | foreach(library tinfo terminfo curses ncurses ncursesw) |
Chandler Carruth | f11f1e4 | 2013-08-12 09:49:17 +0000 | [diff] [blame] | 131 | string(TOUPPER ${library} library_suffix) |
| 132 | check_library_exists(${library} setupterm "" HAVE_TERMINFO_${library_suffix}) |
| 133 | if(HAVE_TERMINFO_${library_suffix}) |
| 134 | set(HAVE_TERMINFO 1) |
| 135 | set(TERMINFO_LIBS "${library}") |
| 136 | break() |
Chandler Carruth | cad7e5e | 2013-08-07 08:47:36 +0000 | [diff] [blame] | 137 | endif() |
Chandler Carruth | f11f1e4 | 2013-08-12 09:49:17 +0000 | [diff] [blame] | 138 | endforeach() |
Chandler Carruth | cad7e5e | 2013-08-07 08:47:36 +0000 | [diff] [blame] | 139 | else() |
Chandler Carruth | f11f1e4 | 2013-08-12 09:49:17 +0000 | [diff] [blame] | 140 | set(HAVE_TERMINFO 0) |
Chandler Carruth | cad7e5e | 2013-08-07 08:47:36 +0000 | [diff] [blame] | 141 | endif() |
Oscar Fuentes | 1a0bfb6 | 2009-11-05 18:57:56 +0000 | [diff] [blame] | 142 | endif() |
Oscar Fuentes | a6e2006 | 2009-05-06 14:40:37 +0000 | [diff] [blame] | 143 | |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 144 | # function checks |
Todd Fiala | 4ccfe39 | 2014-02-05 05:04:36 +0000 | [diff] [blame] | 145 | check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM) |
Benjamin Kramer | d02949b | 2012-09-01 20:50:18 +0000 | [diff] [blame] | 146 | check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 147 | check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE) |
| 148 | check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE) |
| 149 | check_symbol_exists(setrlimit sys/resource.h HAVE_SETRLIMIT) |
Ted Kremenek | 6ea1b76 | 2011-12-23 01:31:45 +0000 | [diff] [blame] | 150 | check_symbol_exists(isatty unistd.h HAVE_ISATTY) |
Eric Christopher | a24dc7f | 2013-07-04 01:10:38 +0000 | [diff] [blame] | 151 | check_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS) |
| 152 | check_symbol_exists(futimes sys/time.h HAVE_FUTIMES) |
Oscar Fuentes | e866c41 | 2011-01-31 18:25:25 +0000 | [diff] [blame] | 153 | if( HAVE_SETJMP_H ) |
| 154 | check_symbol_exists(longjmp setjmp.h HAVE_LONGJMP) |
| 155 | check_symbol_exists(setjmp setjmp.h HAVE_SETJMP) |
| 156 | check_symbol_exists(siglongjmp setjmp.h HAVE_SIGLONGJMP) |
| 157 | check_symbol_exists(sigsetjmp setjmp.h HAVE_SIGSETJMP) |
| 158 | endif() |
Oscar Fuentes | ed27ead | 2011-02-03 04:23:07 +0000 | [diff] [blame] | 159 | if( HAVE_SYS_UIO_H ) |
| 160 | check_symbol_exists(writev sys/uio.h HAVE_WRITEV) |
| 161 | endif() |
Davide Italiano | faafae3 | 2015-02-19 07:27:14 +0000 | [diff] [blame] | 162 | check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 163 | check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO) |
Douglas Gregor | 60dd76f | 2009-06-04 17:22:52 +0000 | [diff] [blame] | 164 | check_symbol_exists(malloc_zone_statistics malloc/malloc.h |
| 165 | HAVE_MALLOC_ZONE_STATISTICS) |
Benjamin Kramer | c1ba4c2 | 2009-10-28 18:37:31 +0000 | [diff] [blame] | 166 | check_symbol_exists(mkdtemp "stdlib.h;unistd.h" HAVE_MKDTEMP) |
| 167 | check_symbol_exists(mkstemp "stdlib.h;unistd.h" HAVE_MKSTEMP) |
| 168 | check_symbol_exists(mktemp "stdlib.h;unistd.h" HAVE_MKTEMP) |
Oscar Fuentes | 0a1b6b8 | 2011-01-13 19:17:28 +0000 | [diff] [blame] | 169 | check_symbol_exists(closedir "sys/types.h;dirent.h" HAVE_CLOSEDIR) |
| 170 | check_symbol_exists(opendir "sys/types.h;dirent.h" HAVE_OPENDIR) |
Oscar Fuentes | e866c41 | 2011-01-31 18:25:25 +0000 | [diff] [blame] | 171 | check_symbol_exists(readdir "sys/types.h;dirent.h" HAVE_READDIR) |
Oscar Fuentes | 0a1b6b8 | 2011-01-13 19:17:28 +0000 | [diff] [blame] | 172 | check_symbol_exists(getcwd unistd.h HAVE_GETCWD) |
| 173 | check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) |
| 174 | check_symbol_exists(getrlimit "sys/types.h;sys/time.h;sys/resource.h" HAVE_GETRLIMIT) |
Benjamin Kramer | e1effb0 | 2011-11-22 12:31:53 +0000 | [diff] [blame] | 175 | check_symbol_exists(posix_spawn spawn.h HAVE_POSIX_SPAWN) |
| 176 | check_symbol_exists(pread unistd.h HAVE_PREAD) |
Alexey Samsonov | 30c0ecc | 2013-08-26 18:11:25 +0000 | [diff] [blame] | 177 | check_symbol_exists(realpath stdlib.h HAVE_REALPATH) |
Edward O'Callaghan | 655314e | 2009-10-05 23:05:32 +0000 | [diff] [blame] | 178 | check_symbol_exists(sbrk unistd.h HAVE_SBRK) |
Oscar Fuentes | e866c41 | 2011-01-31 18:25:25 +0000 | [diff] [blame] | 179 | check_symbol_exists(srand48 stdlib.h HAVE_RAND48_SRAND48) |
| 180 | if( HAVE_RAND48_SRAND48 ) |
| 181 | check_symbol_exists(lrand48 stdlib.h HAVE_RAND48_LRAND48) |
| 182 | if( HAVE_RAND48_LRAND48 ) |
| 183 | check_symbol_exists(drand48 stdlib.h HAVE_RAND48_DRAND48) |
| 184 | if( HAVE_RAND48_DRAND48 ) |
| 185 | set(HAVE_RAND48 1 CACHE INTERNAL "are srand48/lrand48/drand48 available?") |
| 186 | endif() |
| 187 | endif() |
| 188 | endif() |
Oscar Fuentes | a9ac909 | 2008-10-25 03:29:36 +0000 | [diff] [blame] | 189 | check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL) |
Oscar Fuentes | e866c41 | 2011-01-31 18:25:25 +0000 | [diff] [blame] | 190 | check_symbol_exists(strtoq stdlib.h HAVE_STRTOQ) |
Jeffrey Yasskin | 1a93330 | 2009-07-01 18:11:20 +0000 | [diff] [blame] | 191 | check_symbol_exists(strerror string.h HAVE_STRERROR) |
| 192 | check_symbol_exists(strerror_r string.h HAVE_STRERROR_R) |
NAKAMURA Takumi | 18911180 | 2011-02-09 04:18:48 +0000 | [diff] [blame] | 193 | check_symbol_exists(strerror_s string.h HAVE_DECL_STRERROR_S) |
Jeffrey Yasskin | 14a5cc5 | 2009-09-25 21:07:20 +0000 | [diff] [blame] | 194 | check_symbol_exists(setenv stdlib.h HAVE_SETENV) |
Oscar Fuentes | 2761c7a | 2011-02-04 05:40:04 +0000 | [diff] [blame] | 195 | if( PURE_WINDOWS ) |
Michael J. Spencer | ca242f2 | 2010-12-03 18:48:56 +0000 | [diff] [blame] | 196 | check_symbol_exists(_chsize_s io.h HAVE__CHSIZE_S) |
NAKAMURA Takumi | 03a541f | 2011-02-05 15:11:53 +0000 | [diff] [blame] | 197 | |
| 198 | check_function_exists(_alloca HAVE__ALLOCA) |
| 199 | check_function_exists(__alloca HAVE___ALLOCA) |
| 200 | check_function_exists(__chkstk HAVE___CHKSTK) |
NAKAMURA Takumi | 7885507 | 2015-01-30 13:01:19 +0000 | [diff] [blame] | 201 | check_function_exists(__chkstk_ms HAVE___CHKSTK_MS) |
NAKAMURA Takumi | 03a541f | 2011-02-05 15:11:53 +0000 | [diff] [blame] | 202 | check_function_exists(___chkstk HAVE____CHKSTK) |
NAKAMURA Takumi | 7885507 | 2015-01-30 13:01:19 +0000 | [diff] [blame] | 203 | check_function_exists(___chkstk_ms HAVE____CHKSTK_MS) |
NAKAMURA Takumi | 03a541f | 2011-02-05 15:11:53 +0000 | [diff] [blame] | 204 | |
| 205 | check_function_exists(__ashldi3 HAVE___ASHLDI3) |
| 206 | check_function_exists(__ashrdi3 HAVE___ASHRDI3) |
| 207 | check_function_exists(__divdi3 HAVE___DIVDI3) |
| 208 | check_function_exists(__fixdfdi HAVE___FIXDFDI) |
| 209 | check_function_exists(__fixsfdi HAVE___FIXSFDI) |
| 210 | check_function_exists(__floatdidf HAVE___FLOATDIDF) |
| 211 | check_function_exists(__lshrdi3 HAVE___LSHRDI3) |
| 212 | check_function_exists(__moddi3 HAVE___MODDI3) |
| 213 | check_function_exists(__udivdi3 HAVE___UDIVDI3) |
| 214 | check_function_exists(__umoddi3 HAVE___UMODDI3) |
| 215 | |
| 216 | check_function_exists(__main HAVE___MAIN) |
| 217 | check_function_exists(__cmpdi2 HAVE___CMPDI2) |
Michael J. Spencer | ca242f2 | 2010-12-03 18:48:56 +0000 | [diff] [blame] | 218 | endif() |
Oscar Fuentes | e866c41 | 2011-01-31 18:25:25 +0000 | [diff] [blame] | 219 | if( HAVE_DLFCN_H ) |
| 220 | if( HAVE_LIBDL ) |
| 221 | list(APPEND CMAKE_REQUIRED_LIBRARIES dl) |
| 222 | endif() |
Oscar Fuentes | e65ed1c | 2011-01-17 16:35:14 +0000 | [diff] [blame] | 223 | check_symbol_exists(dlerror dlfcn.h HAVE_DLERROR) |
| 224 | check_symbol_exists(dlopen dlfcn.h HAVE_DLOPEN) |
Oscar Fuentes | e866c41 | 2011-01-31 18:25:25 +0000 | [diff] [blame] | 225 | if( HAVE_LIBDL ) |
| 226 | list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl) |
| 227 | endif() |
Oscar Fuentes | e65ed1c | 2011-01-17 16:35:14 +0000 | [diff] [blame] | 228 | endif() |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 229 | |
Oscar Fuentes | bda403b | 2009-04-04 22:41:07 +0000 | [diff] [blame] | 230 | check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC) |
| 231 | if( LLVM_USING_GLIBC ) |
| 232 | add_llvm_definitions( -D_GNU_SOURCE ) |
| 233 | endif() |
| 234 | |
Reid Kleckner | 37f69de | 2013-07-26 16:54:23 +0000 | [diff] [blame] | 235 | set(headers "sys/types.h") |
Douglas Gregor | f99626e | 2009-10-01 17:25:36 +0000 | [diff] [blame] | 236 | |
| 237 | if (HAVE_INTTYPES_H) |
| 238 | set(headers ${headers} "inttypes.h") |
| 239 | endif() |
| 240 | |
| 241 | if (HAVE_STDINT_H) |
| 242 | set(headers ${headers} "stdint.h") |
| 243 | endif() |
| 244 | |
Oscar Fuentes | c8cb58e | 2011-01-11 12:31:54 +0000 | [diff] [blame] | 245 | check_type_exists(int64_t "${headers}" HAVE_INT64_T) |
Douglas Gregor | f99626e | 2009-10-01 17:25:36 +0000 | [diff] [blame] | 246 | check_type_exists(uint64_t "${headers}" HAVE_UINT64_T) |
| 247 | check_type_exists(u_int64_t "${headers}" HAVE_U_INT64_T) |
| 248 | |
Oscar Fuentes | 17feb2a | 2009-11-05 19:03:26 +0000 | [diff] [blame] | 249 | # available programs checks |
Oscar Fuentes | de8f431 | 2009-11-09 15:26:40 +0000 | [diff] [blame] | 250 | function(llvm_find_program name) |
| 251 | string(TOUPPER ${name} NAME) |
Tobias Grosser | 1b4f940 | 2011-02-27 04:11:05 +0000 | [diff] [blame] | 252 | string(REGEX REPLACE "\\." "_" NAME ${NAME}) |
Matt Arsenault | 9096217 | 2013-07-08 20:24:49 +0000 | [diff] [blame] | 253 | |
| 254 | find_program(LLVM_PATH_${NAME} NAMES ${ARGV}) |
Oscar Fuentes | de8f431 | 2009-11-09 15:26:40 +0000 | [diff] [blame] | 255 | mark_as_advanced(LLVM_PATH_${NAME}) |
| 256 | if(LLVM_PATH_${NAME}) |
| 257 | set(HAVE_${NAME} 1 CACHE INTERNAL "Is ${name} available ?") |
| 258 | mark_as_advanced(HAVE_${NAME}) |
| 259 | else(LLVM_PATH_${NAME}) |
| 260 | set(HAVE_${NAME} "" CACHE INTERNAL "Is ${name} available ?") |
Oscar Fuentes | de8f431 | 2009-11-09 15:26:40 +0000 | [diff] [blame] | 261 | endif(LLVM_PATH_${NAME}) |
| 262 | endfunction() |
| 263 | |
Alp Toker | 125be84 | 2014-06-02 01:40:04 +0000 | [diff] [blame] | 264 | if (LLVM_ENABLE_DOXYGEN) |
| 265 | llvm_find_program(dot) |
| 266 | endif () |
Oscar Fuentes | 17feb2a | 2009-11-05 19:03:26 +0000 | [diff] [blame] | 267 | |
Oscar Fuentes | 6495595 | 2011-01-21 15:42:54 +0000 | [diff] [blame] | 268 | if( LLVM_ENABLE_FFI ) |
| 269 | find_path(FFI_INCLUDE_PATH ffi.h PATHS ${FFI_INCLUDE_DIR}) |
Josh Klontz | da295e9 | 2014-08-08 14:32:56 +0000 | [diff] [blame] | 270 | if( EXISTS "${FFI_INCLUDE_PATH}/ffi.h" ) |
Oscar Fuentes | 6495595 | 2011-01-21 15:42:54 +0000 | [diff] [blame] | 271 | set(FFI_HEADER ffi.h CACHE INTERNAL "") |
| 272 | set(HAVE_FFI_H 1 CACHE INTERNAL "") |
| 273 | else() |
| 274 | find_path(FFI_INCLUDE_PATH ffi/ffi.h PATHS ${FFI_INCLUDE_DIR}) |
Josh Klontz | da295e9 | 2014-08-08 14:32:56 +0000 | [diff] [blame] | 275 | if( EXISTS "${FFI_INCLUDE_PATH}/ffi/ffi.h" ) |
Oscar Fuentes | 6495595 | 2011-01-21 15:42:54 +0000 | [diff] [blame] | 276 | set(FFI_HEADER ffi/ffi.h CACHE INTERNAL "") |
| 277 | set(HAVE_FFI_FFI_H 1 CACHE INTERNAL "") |
| 278 | endif() |
| 279 | endif() |
| 280 | |
| 281 | if( NOT FFI_HEADER ) |
| 282 | message(FATAL_ERROR "libffi includes are not found.") |
| 283 | endif() |
| 284 | |
| 285 | find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) |
| 286 | if( NOT FFI_LIBRARY_PATH ) |
| 287 | message(FATAL_ERROR "libffi is not found.") |
| 288 | endif() |
| 289 | |
| 290 | list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH}) |
| 291 | list(APPEND CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH}) |
| 292 | check_symbol_exists(ffi_call ${FFI_HEADER} HAVE_FFI_CALL) |
| 293 | list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH}) |
| 294 | list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH}) |
Oscar Fuentes | f2ab928 | 2011-04-02 13:21:12 +0000 | [diff] [blame] | 295 | else() |
| 296 | unset(HAVE_FFI_FFI_H CACHE) |
| 297 | unset(HAVE_FFI_H CACHE) |
| 298 | unset(HAVE_FFI_CALL CACHE) |
Oscar Fuentes | 6495595 | 2011-01-21 15:42:54 +0000 | [diff] [blame] | 299 | endif( LLVM_ENABLE_FFI ) |
| 300 | |
Eric Christopher | 4418a60 | 2011-09-19 20:43:23 +0000 | [diff] [blame] | 301 | # Define LLVM_HAS_ATOMICS if gcc or MSVC atomic builtins are supported. |
Xerxes Ranby | 64c6d42 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 302 | include(CheckAtomic) |
| 303 | |
Oscar Fuentes | 25ac830 | 2011-01-15 13:35:37 +0000 | [diff] [blame] | 304 | if( LLVM_ENABLE_PIC ) |
| 305 | set(ENABLE_PIC 1) |
| 306 | else() |
| 307 | set(ENABLE_PIC 0) |
Chris Bieneman | 7494dc5 | 2015-11-24 08:04:59 +0000 | [diff] [blame] | 308 | check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG) |
| 309 | if(SUPPORTS_NO_PIE_FLAG) |
Pavel Labath | e3af026 | 2015-11-24 09:46:01 +0000 | [diff] [blame] | 310 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") |
Chris Bieneman | 7494dc5 | 2015-11-24 08:04:59 +0000 | [diff] [blame] | 311 | endif() |
Oscar Fuentes | 25ac830 | 2011-01-15 13:35:37 +0000 | [diff] [blame] | 312 | endif() |
Oscar Fuentes | edfc184 | 2011-01-09 14:34:39 +0000 | [diff] [blame] | 313 | |
Michael J. Spencer | 33a390e | 2010-10-07 18:12:54 +0000 | [diff] [blame] | 314 | check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG) |
| 315 | |
Edwin Vane | a9c5bb3 | 2013-02-04 02:32:44 +0000 | [diff] [blame] | 316 | set(USE_NO_MAYBE_UNINITIALIZED 0) |
| 317 | set(USE_NO_UNINITIALIZED 0) |
| 318 | |
| 319 | # Disable gcc's potentially uninitialized use analysis as it presents lots of |
| 320 | # false positives. |
| 321 | if (CMAKE_COMPILER_IS_GNUCXX) |
| 322 | check_cxx_compiler_flag("-Wmaybe-uninitialized" HAS_MAYBE_UNINITIALIZED) |
| 323 | if (HAS_MAYBE_UNINITIALIZED) |
| 324 | set(USE_NO_MAYBE_UNINITIALIZED 1) |
| 325 | else() |
| 326 | # Only recent versions of gcc make the distinction between -Wuninitialized |
| 327 | # and -Wmaybe-uninitialized. If -Wmaybe-uninitialized isn't supported, just |
| 328 | # turn off all uninitialized use warnings. |
| 329 | check_cxx_compiler_flag("-Wuninitialized" HAS_UNINITIALIZED) |
| 330 | set(USE_NO_UNINITIALIZED ${HAS_UNINITIALIZED}) |
| 331 | endif() |
| 332 | endif() |
| 333 | |
Sebastian Pop | 82622dc | 2012-08-08 18:04:45 +0000 | [diff] [blame] | 334 | # By default, we target the host, but this can be overridden at CMake |
| 335 | # invocation time. |
Tim Northover | fee13d1 | 2013-05-04 07:36:23 +0000 | [diff] [blame] | 336 | include(GetHostTriple) |
| 337 | get_host_triple(LLVM_INFERRED_HOST_TRIPLE) |
| 338 | |
| 339 | set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING |
| 340 | "Host on which LLVM binaries will run") |
Daniel Dunbar | c0fd8a4 | 2009-11-07 23:52:20 +0000 | [diff] [blame] | 341 | |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 342 | # Determine the native architecture. |
Oscar Fuentes | b9a7813 | 2009-09-13 22:18:38 +0000 | [diff] [blame] | 343 | string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH) |
| 344 | if( LLVM_NATIVE_ARCH STREQUAL "host" ) |
Chandler Carruth | beb3e7e | 2012-01-24 18:00:44 +0000 | [diff] [blame] | 345 | string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOST_TRIPLE}) |
Oscar Fuentes | b9a7813 | 2009-09-13 22:18:38 +0000 | [diff] [blame] | 346 | endif () |
| 347 | |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 348 | if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86") |
| 349 | set(LLVM_NATIVE_ARCH X86) |
Oscar Fuentes | b9a7813 | 2009-09-13 22:18:38 +0000 | [diff] [blame] | 350 | elseif (LLVM_NATIVE_ARCH STREQUAL "x86") |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 351 | set(LLVM_NATIVE_ARCH X86) |
Oscar Fuentes | b9a7813 | 2009-09-13 22:18:38 +0000 | [diff] [blame] | 352 | elseif (LLVM_NATIVE_ARCH STREQUAL "amd64") |
| 353 | set(LLVM_NATIVE_ARCH X86) |
| 354 | elseif (LLVM_NATIVE_ARCH STREQUAL "x86_64") |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 355 | set(LLVM_NATIVE_ARCH X86) |
| 356 | elseif (LLVM_NATIVE_ARCH MATCHES "sparc") |
| 357 | set(LLVM_NATIVE_ARCH Sparc) |
| 358 | elseif (LLVM_NATIVE_ARCH MATCHES "powerpc") |
| 359 | set(LLVM_NATIVE_ARCH PowerPC) |
Tim Northover | a958a57 | 2013-05-04 20:13:52 +0000 | [diff] [blame] | 360 | elseif (LLVM_NATIVE_ARCH MATCHES "aarch64") |
| 361 | set(LLVM_NATIVE_ARCH AArch64) |
Tim Northover | 00ed996 | 2014-03-29 10:18:08 +0000 | [diff] [blame] | 362 | elseif (LLVM_NATIVE_ARCH MATCHES "arm64") |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 363 | set(LLVM_NATIVE_ARCH AArch64) |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 364 | elseif (LLVM_NATIVE_ARCH MATCHES "arm") |
| 365 | set(LLVM_NATIVE_ARCH ARM) |
| 366 | elseif (LLVM_NATIVE_ARCH MATCHES "mips") |
| 367 | set(LLVM_NATIVE_ARCH Mips) |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 368 | elseif (LLVM_NATIVE_ARCH MATCHES "xcore") |
| 369 | set(LLVM_NATIVE_ARCH XCore) |
| 370 | elseif (LLVM_NATIVE_ARCH MATCHES "msp430") |
| 371 | set(LLVM_NATIVE_ARCH MSP430) |
Sebastian Pop | 8f4aec4 | 2012-08-20 19:56:49 +0000 | [diff] [blame] | 372 | elseif (LLVM_NATIVE_ARCH MATCHES "hexagon") |
| 373 | set(LLVM_NATIVE_ARCH Hexagon) |
Ulrich Weigand | 1ceebf6 | 2013-05-06 16:22:34 +0000 | [diff] [blame] | 374 | elseif (LLVM_NATIVE_ARCH MATCHES "s390x") |
| 375 | set(LLVM_NATIVE_ARCH SystemZ) |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 376 | elseif (LLVM_NATIVE_ARCH MATCHES "wasm32") |
| 377 | set(LLVM_NATIVE_ARCH WebAssembly) |
| 378 | elseif (LLVM_NATIVE_ARCH MATCHES "wasm64") |
| 379 | set(LLVM_NATIVE_ARCH WebAssembly) |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 380 | else () |
Oscar Fuentes | 465f936 | 2011-03-23 17:42:13 +0000 | [diff] [blame] | 381 | message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}") |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 382 | endif () |
Michael J. Spencer | 1444f47 | 2010-09-24 09:00:56 +0000 | [diff] [blame] | 383 | |
Andy Gibbs | f5dede1 | 2013-06-26 07:57:53 +0000 | [diff] [blame] | 384 | # If build targets includes "host", then replace with native architecture. |
| 385 | list(FIND LLVM_TARGETS_TO_BUILD "host" idx) |
| 386 | if( NOT idx LESS 0 ) |
| 387 | list(REMOVE_AT LLVM_TARGETS_TO_BUILD ${idx}) |
| 388 | list(APPEND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH}) |
| 389 | list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD) |
| 390 | endif() |
| 391 | |
Oscar Fuentes | 465f936 | 2011-03-23 17:42:13 +0000 | [diff] [blame] | 392 | list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX) |
| 393 | if (NATIVE_ARCH_IDX EQUAL -1) |
| 394 | message(STATUS |
| 395 | "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code") |
| 396 | else () |
| 397 | message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}") |
| 398 | set(LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target) |
| 399 | set(LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo) |
Evan Cheng | 8c886a4 | 2011-07-22 21:58:54 +0000 | [diff] [blame] | 400 | set(LLVM_NATIVE_TARGETMC LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC) |
Oscar Fuentes | 465f936 | 2011-03-23 17:42:13 +0000 | [diff] [blame] | 401 | set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter) |
Chandler Carruth | 98e642d | 2011-12-09 03:31:58 +0000 | [diff] [blame] | 402 | |
| 403 | # We don't have an ASM parser for all architectures yet. |
| 404 | if (EXISTS ${CMAKE_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/CMakeLists.txt) |
| 405 | set(LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser) |
| 406 | endif () |
Eric Christopher | 56079c1 | 2012-03-26 21:56:56 +0000 | [diff] [blame] | 407 | |
| 408 | # We don't have an disassembler for all architectures yet. |
| 409 | if (EXISTS ${CMAKE_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/CMakeLists.txt) |
| 410 | set(LLVM_NATIVE_DISASSEMBLER LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler) |
| 411 | endif () |
Oscar Fuentes | 465f936 | 2011-03-23 17:42:13 +0000 | [diff] [blame] | 412 | endif () |
Douglas Gregor | 3def847 | 2009-06-17 17:01:56 +0000 | [diff] [blame] | 413 | |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 414 | if( MINGW ) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 415 | set(HAVE_LIBPSAPI 1) |
David Majnemer | 61eae2e | 2013-10-07 01:00:07 +0000 | [diff] [blame] | 416 | set(HAVE_LIBSHELL32 1) |
Oscar Fuentes | 2500aae | 2008-10-29 02:33:15 +0000 | [diff] [blame] | 417 | # TODO: Check existence of libraries. |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 418 | # include(CheckLibraryExists) |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 419 | endif( MINGW ) |
| 420 | |
Reid Kleckner | a3ae94e | 2013-08-07 00:29:15 +0000 | [diff] [blame] | 421 | if (NOT HAVE_STRTOLL) |
| 422 | # Use _strtoi64 if strtoll is not available. |
| 423 | check_symbol_exists(_strtoi64 stdlib.h have_strtoi64) |
| 424 | if (have_strtoi64) |
| 425 | set(HAVE_STRTOLL 1) |
| 426 | set(strtoll "_strtoi64") |
| 427 | set(strtoull "_strtoui64") |
| 428 | endif () |
| 429 | endif () |
| 430 | |
Oscar Fuentes | a9ac909 | 2008-10-25 03:29:36 +0000 | [diff] [blame] | 431 | if( MSVC ) |
Oscar Fuentes | a9ac909 | 2008-10-25 03:29:36 +0000 | [diff] [blame] | 432 | set(SHLIBEXT ".lib") |
Oscar Fuentes | a9ac909 | 2008-10-25 03:29:36 +0000 | [diff] [blame] | 433 | set(stricmp "_stricmp") |
| 434 | set(strdup "_strdup") |
Zachary Turner | 733b849 | 2015-02-10 05:04:25 +0000 | [diff] [blame] | 435 | |
| 436 | # See if the DIA SDK is available and usable. |
| 437 | set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK") |
| 438 | |
| 439 | # Due to a bug in MSVC 2013's installation software, it is possible |
| 440 | # for MSVC 2013 to write the DIA SDK into the Visual Studio 2012 |
| 441 | # install directory. If this happens, the installation is corrupt |
| 442 | # and there's nothing we can do. It happens with enough frequency |
| 443 | # though that we should handle it. We do so by simply checking that |
| 444 | # the DIA SDK folder exists. Should this happen you will need to |
| 445 | # uninstall VS 2012 and then re-install VS 2013. |
| 446 | if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR}) |
| 447 | set(HAVE_DIA_SDK 1) |
| 448 | else() |
| 449 | set(HAVE_DIA_SDK 0) |
| 450 | endif() |
Zachary Turner | 3ddf94e | 2015-02-22 07:13:52 +0000 | [diff] [blame] | 451 | else() |
| 452 | set(HAVE_DIA_SDK 0) |
Oscar Fuentes | a9ac909 | 2008-10-25 03:29:36 +0000 | [diff] [blame] | 453 | endif( MSVC ) |
| 454 | |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 455 | # FIXME: Signal handler return type, currently hardcoded to 'void' |
| 456 | set(RETSIGTYPE void) |
| 457 | |
Oscar Fuentes | 366fbb7 | 2008-11-18 23:45:21 +0000 | [diff] [blame] | 458 | if( LLVM_ENABLE_THREADS ) |
Dylan Noblesmith | efddf20 | 2011-11-28 00:48:58 +0000 | [diff] [blame] | 459 | # Check if threading primitives aren't supported on this platform |
| 460 | if( NOT HAVE_PTHREAD_H AND NOT WIN32 ) |
| 461 | set(LLVM_ENABLE_THREADS 0) |
Oscar Fuentes | 366fbb7 | 2008-11-18 23:45:21 +0000 | [diff] [blame] | 462 | endif() |
| 463 | endif() |
| 464 | |
Dylan Noblesmith | efddf20 | 2011-11-28 00:48:58 +0000 | [diff] [blame] | 465 | if( LLVM_ENABLE_THREADS ) |
Oscar Fuentes | 366fbb7 | 2008-11-18 23:45:21 +0000 | [diff] [blame] | 466 | message(STATUS "Threads enabled.") |
Dylan Noblesmith | efddf20 | 2011-11-28 00:48:58 +0000 | [diff] [blame] | 467 | else( LLVM_ENABLE_THREADS ) |
Oscar Fuentes | 366fbb7 | 2008-11-18 23:45:21 +0000 | [diff] [blame] | 468 | message(STATUS "Threads disabled.") |
| 469 | endif() |
Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 470 | |
Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 471 | if (LLVM_ENABLE_ZLIB ) |
| 472 | # Check if zlib is available in the system. |
| 473 | if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ ) |
| 474 | set(LLVM_ENABLE_ZLIB 0) |
| 475 | endif() |
| 476 | endif() |
| 477 | |
Oscar Fuentes | 2b1077f | 2010-08-08 04:32:21 +0000 | [diff] [blame] | 478 | set(LLVM_PREFIX ${CMAKE_INSTALL_PREFIX}) |
Michael Gottesman | 4d35b90 | 2013-08-24 07:25:21 +0000 | [diff] [blame] | 479 | |
| 480 | if (LLVM_ENABLE_DOXYGEN) |
| 481 | message(STATUS "Doxygen enabled.") |
Dan Liew | f854295 | 2014-04-28 09:10:05 +0000 | [diff] [blame] | 482 | find_package(Doxygen REQUIRED) |
Michael Gottesman | 9cc5a45 | 2013-08-28 20:28:32 +0000 | [diff] [blame] | 483 | |
| 484 | if (DOXYGEN_FOUND) |
| 485 | # If we find doxygen and we want to enable doxygen by default create a |
| 486 | # global aggregate doxygen target for generating llvm and any/all |
| 487 | # subprojects doxygen documentation. |
| 488 | if (LLVM_BUILD_DOCS) |
| 489 | add_custom_target(doxygen ALL) |
| 490 | endif() |
Michael Gottesman | 406525d | 2013-08-28 21:55:26 +0000 | [diff] [blame] | 491 | |
| 492 | option(LLVM_DOXYGEN_EXTERNAL_SEARCH "Enable doxygen external search." OFF) |
| 493 | if (LLVM_DOXYGEN_EXTERNAL_SEARCH) |
Saleem Abdulrasool | f95da49 | 2015-07-24 01:14:25 +0000 | [diff] [blame] | 494 | set(LLVM_DOXYGEN_SEARCHENGINE_URL "" CACHE STRING "URL to use for external search.") |
Michael Gottesman | 406525d | 2013-08-28 21:55:26 +0000 | [diff] [blame] | 495 | set(LLVM_DOXYGEN_SEARCH_MAPPINGS "" CACHE STRING "Doxygen Search Mappings") |
| 496 | endif() |
Michael Gottesman | 9cc5a45 | 2013-08-28 20:28:32 +0000 | [diff] [blame] | 497 | endif() |
Michael Gottesman | 4d35b90 | 2013-08-24 07:25:21 +0000 | [diff] [blame] | 498 | else() |
| 499 | message(STATUS "Doxygen disabled.") |
| 500 | endif() |
Reid Kleckner | 9f5eb63 | 2014-04-18 21:45:25 +0000 | [diff] [blame] | 501 | |
| 502 | if (LLVM_ENABLE_SPHINX) |
| 503 | message(STATUS "Sphinx enabled.") |
| 504 | find_package(Sphinx REQUIRED) |
| 505 | if (LLVM_BUILD_DOCS) |
| 506 | add_custom_target(sphinx ALL) |
| 507 | endif() |
| 508 | else() |
| 509 | message(STATUS "Sphinx disabled.") |
| 510 | endif() |
Peter Collingbourne | 82e3e37 | 2014-10-16 22:48:02 +0000 | [diff] [blame] | 511 | |
| 512 | set(LLVM_BINDINGS "") |
Peter Collingbourne | 244ecf5 | 2014-10-23 02:33:23 +0000 | [diff] [blame] | 513 | if(WIN32) |
Peter Collingbourne | 82e3e37 | 2014-10-16 22:48:02 +0000 | [diff] [blame] | 514 | message(STATUS "Go bindings disabled.") |
| 515 | else() |
Peter Collingbourne | 244ecf5 | 2014-10-23 02:33:23 +0000 | [diff] [blame] | 516 | find_program(GO_EXECUTABLE NAMES go DOC "go executable") |
| 517 | if(GO_EXECUTABLE STREQUAL "GO_EXECUTABLE-NOTFOUND") |
| 518 | message(STATUS "Go bindings disabled.") |
Peter Collingbourne | 82e3e37 | 2014-10-16 22:48:02 +0000 | [diff] [blame] | 519 | else() |
Peter Collingbourne | 244ecf5 | 2014-10-23 02:33:23 +0000 | [diff] [blame] | 520 | execute_process(COMMAND ${GO_EXECUTABLE} run ${CMAKE_SOURCE_DIR}/bindings/go/conftest.go |
| 521 | RESULT_VARIABLE GO_CONFTEST) |
| 522 | if(GO_CONFTEST STREQUAL "0") |
| 523 | set(LLVM_BINDINGS "${LLVM_BINDINGS} go") |
| 524 | message(STATUS "Go bindings enabled.") |
| 525 | else() |
| 526 | message(STATUS "Go bindings disabled, need at least Go 1.2.") |
| 527 | endif() |
Peter Collingbourne | 82e3e37 | 2014-10-16 22:48:02 +0000 | [diff] [blame] | 528 | endif() |
| 529 | endif() |
Peter Zotov | b20073c | 2014-12-01 19:50:23 +0000 | [diff] [blame] | 530 | |
Niels Ole Salscheider | b0e3c34 | 2015-05-01 11:58:30 +0000 | [diff] [blame] | 531 | find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold ld.gold ${LLVM_DEFAULT_TARGET_TRIPLE}-ld ld DOC "The gold linker") |
Rafael Espindola | 6b27999 | 2015-04-27 21:08:47 +0000 | [diff] [blame] | 532 | set(LLVM_BINUTILS_INCDIR "" CACHE PATH |
| 533 | "PATH to binutils/include containing plugin-api.h for gold plugin.") |
Chandler Carruth | edd9294 | 2015-02-14 09:43:57 +0000 | [diff] [blame] | 534 | |
Peter Collingbourne | bbdc26b | 2015-03-19 23:55:38 +0000 | [diff] [blame] | 535 | if(APPLE) |
| 536 | find_program(LD64_EXECUTABLE NAMES ld DOC "The ld64 linker") |
| 537 | endif() |
| 538 | |
Peter Zotov | b20073c | 2014-12-01 19:50:23 +0000 | [diff] [blame] | 539 | include(FindOCaml) |
| 540 | include(AddOCaml) |
| 541 | if(WIN32) |
| 542 | message(STATUS "OCaml bindings disabled.") |
| 543 | else() |
| 544 | find_package(OCaml) |
| 545 | if( NOT OCAML_FOUND ) |
| 546 | message(STATUS "OCaml bindings disabled.") |
| 547 | else() |
| 548 | if( OCAML_VERSION VERSION_LESS "4.00.0" ) |
| 549 | message(STATUS "OCaml bindings disabled, need OCaml >=4.00.0.") |
| 550 | else() |
Peter Zotov | 8c7e29d | 2015-06-27 14:32:30 +0000 | [diff] [blame] | 551 | find_ocamlfind_package(ctypes VERSION 0.4 OPTIONAL) |
Peter Zotov | fcefcf9 | 2014-12-03 03:39:01 +0000 | [diff] [blame] | 552 | if( HAVE_OCAML_CTYPES ) |
| 553 | message(STATUS "OCaml bindings enabled.") |
| 554 | find_ocamlfind_package(oUnit VERSION 2 OPTIONAL) |
| 555 | set(LLVM_BINDINGS "${LLVM_BINDINGS} ocaml") |
| 556 | else() |
Peter Zotov | 8c7e29d | 2015-06-27 14:32:30 +0000 | [diff] [blame] | 557 | message(STATUS "OCaml bindings disabled, need ctypes >=0.4.") |
Peter Zotov | fcefcf9 | 2014-12-03 03:39:01 +0000 | [diff] [blame] | 558 | endif() |
Peter Zotov | b20073c | 2014-12-01 19:50:23 +0000 | [diff] [blame] | 559 | endif() |
| 560 | endif() |
| 561 | endif() |
| 562 | |
| 563 | string(REPLACE " " ";" LLVM_BINDINGS_LIST "${LLVM_BINDINGS}") |