source: clamav/vendor/current/libclamav/c++/llvm/cmake/config-ix.cmake@ 189

Last change on this file since 189 was 189, checked in by Yuri Dario, 14 years ago

clamav: initial clamav 0.96.4 import.

File size: 8.5 KB
Line 
1include(CheckIncludeFile)
2include(CheckLibraryExists)
3include(CheckSymbolExists)
4include(CheckFunctionExists)
5include(CheckCXXSourceCompiles)
6
7if( UNIX )
8 # Used by check_symbol_exists:
9 set(CMAKE_REQUIRED_LIBRARIES m)
10endif()
11
12# Helper macros and functions
13macro(add_cxx_include result files)
14 set(${result} "")
15 foreach (file_name ${files})
16 set(${result} "${${result}}#include<${file_name}>\n")
17 endforeach()
18endmacro(add_cxx_include files result)
19
20function(check_type_exists type files variable)
21 add_cxx_include(includes "${files}")
22 CHECK_CXX_SOURCE_COMPILES("
23 ${includes} ${type} typeVar;
24 int main() {
25 return 0;
26 }
27 " ${variable})
28endfunction()
29
30# include checks
31check_include_file(argz.h HAVE_ARGZ_H)
32check_include_file(assert.h HAVE_ASSERT_H)
33check_include_file(dirent.h HAVE_DIRENT_H)
34check_include_file(dl.h HAVE_DL_H)
35check_include_file(dld.h HAVE_DLD_H)
36check_include_file(dlfcn.h HAVE_DLFCN_H)
37check_include_file(errno.h HAVE_ERRNO_H)
38check_include_file(execinfo.h HAVE_EXECINFO_H)
39check_include_file(fcntl.h HAVE_FCNTL_H)
40check_include_file(inttypes.h HAVE_INTTYPES_H)
41check_include_file(limits.h HAVE_LIMITS_H)
42check_include_file(link.h HAVE_LINK_H)
43check_include_file(malloc.h HAVE_MALLOC_H)
44check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
45check_include_file(memory.h HAVE_MEMORY_H)
46check_include_file(ndir.h HAVE_NDIR_H)
47if( NOT LLVM_ON_WIN32 )
48 check_include_file(pthread.h HAVE_PTHREAD_H)
49endif()
50check_include_file(setjmp.h HAVE_SETJMP_H)
51check_include_file(signal.h HAVE_SIGNAL_H)
52check_include_file(stdint.h HAVE_STDINT_H)
53check_include_file(stdio.h HAVE_STDIO_H)
54check_include_file(stdlib.h HAVE_STDLIB_H)
55check_include_file(string.h HAVE_STRING_H)
56check_include_file(sys/dir.h HAVE_SYS_DIR_H)
57check_include_file(sys/dl.h HAVE_SYS_DL_H)
58check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
59check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
60check_include_file(sys/ndir.h HAVE_SYS_NDIR_H)
61check_include_file(sys/param.h HAVE_SYS_PARAM_H)
62check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
63check_include_file(sys/stat.h HAVE_SYS_STAT_H)
64check_include_file(sys/time.h HAVE_SYS_TIME_H)
65check_include_file(sys/types.h HAVE_SYS_TYPES_H)
66check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
67check_include_file(termios.h HAVE_TERMIOS_H)
68check_include_file(unistd.h HAVE_UNISTD_H)
69check_include_file(utime.h HAVE_UTIME_H)
70check_include_file(windows.h HAVE_WINDOWS_H)
71
72# library checks
73if( NOT LLVM_ON_WIN32 )
74 check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
75 check_library_exists(pthread pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC)
76 check_library_exists(pthread pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT)
77 check_library_exists(dl dlopen "" HAVE_LIBDL)
78endif()
79
80# function checks
81check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
82check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
83check_symbol_exists(setrlimit sys/resource.h HAVE_SETRLIMIT)
84check_function_exists(isatty HAVE_ISATTY)
85check_symbol_exists(isinf cmath HAVE_ISINF_IN_CMATH)
86check_symbol_exists(isinf math.h HAVE_ISINF_IN_MATH_H)
87check_symbol_exists(finite ieeefp.h HAVE_FINITE_IN_IEEEFP_H)
88check_symbol_exists(isnan cmath HAVE_ISNAN_IN_CMATH)
89check_symbol_exists(isnan math.h HAVE_ISNAN_IN_MATH_H)
90check_symbol_exists(ceilf math.h HAVE_CEILF)
91check_symbol_exists(floorf math.h HAVE_FLOORF)
92check_symbol_exists(nearbyintf math.h HAVE_NEARBYINTF)
93check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
94check_symbol_exists(malloc_zone_statistics malloc/malloc.h
95 HAVE_MALLOC_ZONE_STATISTICS)
96check_symbol_exists(mkdtemp "stdlib.h;unistd.h" HAVE_MKDTEMP)
97check_symbol_exists(mkstemp "stdlib.h;unistd.h" HAVE_MKSTEMP)
98check_symbol_exists(mktemp "stdlib.h;unistd.h" HAVE_MKTEMP)
99if( NOT LLVM_ON_WIN32 )
100 check_symbol_exists(pthread_mutex_lock pthread.h HAVE_PTHREAD_MUTEX_LOCK)
101endif()
102check_symbol_exists(sbrk unistd.h HAVE_SBRK)
103check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL)
104check_symbol_exists(strerror string.h HAVE_STRERROR)
105check_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
106check_symbol_exists(strerror_s string.h HAVE_STRERROR_S)
107check_symbol_exists(setenv stdlib.h HAVE_SETENV)
108
109check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
110if( LLVM_USING_GLIBC )
111 add_llvm_definitions( -D_GNU_SOURCE )
112endif()
113
114# Type checks
115check_type_exists(std::bidirectional_iterator<int,int> "iterator;iostream" HAVE_BI_ITERATOR)
116check_type_exists(std::iterator<int,int,int> iterator HAVE_STD_ITERATOR)
117check_type_exists(std::forward_iterator<int,int> iterator HAVE_FWD_ITERATOR)
118
119set(headers "")
120if (HAVE_SYS_TYPES_H)
121 set(headers ${headers} "sys/types.h")
122endif()
123
124if (HAVE_INTTYPES_H)
125 set(headers ${headers} "inttypes.h")
126endif()
127
128if (HAVE_STDINT_H)
129 set(headers ${headers} "stdint.h")
130endif()
131
132check_type_exists(uint64_t "${headers}" HAVE_UINT64_T)
133check_type_exists(u_int64_t "${headers}" HAVE_U_INT64_T)
134
135# available programs checks
136function(llvm_find_program name)
137 string(TOUPPER ${name} NAME)
138 find_program(LLVM_PATH_${NAME} ${name})
139 mark_as_advanced(LLVM_PATH_${NAME})
140 if(LLVM_PATH_${NAME})
141 set(HAVE_${NAME} 1 CACHE INTERNAL "Is ${name} available ?")
142 mark_as_advanced(HAVE_${NAME})
143 else(LLVM_PATH_${NAME})
144 set(HAVE_${NAME} "" CACHE INTERNAL "Is ${name} available ?")
145 endif(LLVM_PATH_${NAME})
146endfunction()
147
148llvm_find_program(gv)
149llvm_find_program(circo)
150llvm_find_program(twopi)
151llvm_find_program(neato)
152llvm_find_program(fdp)
153llvm_find_program(dot)
154llvm_find_program(dotty)
155
156# Define LLVM_MULTITHREADED if gcc atomic builtins exists.
157include(CheckAtomic)
158
159include(CheckCXXCompilerFlag)
160# On windows all code is position-independent and mingw warns if -fPIC
161# is in the command-line.
162if( NOT WIN32 )
163 check_cxx_compiler_flag("-fPIC" SUPPORTS_FPIC_FLAG)
164endif()
165
166include(GetTargetTriple)
167get_target_triple(LLVM_HOSTTRIPLE)
168
169# FIXME: We don't distinguish the target and the host. :(
170set(TARGET_TRIPLE "${LLVM_HOSTTRIPLE}")
171
172# Determine the native architecture.
173string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)
174if( LLVM_NATIVE_ARCH STREQUAL "host" )
175 string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOSTTRIPLE})
176endif ()
177
178if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86")
179 set(LLVM_NATIVE_ARCH X86)
180elseif (LLVM_NATIVE_ARCH STREQUAL "x86")
181 set(LLVM_NATIVE_ARCH X86)
182elseif (LLVM_NATIVE_ARCH STREQUAL "amd64")
183 set(LLVM_NATIVE_ARCH X86)
184elseif (LLVM_NATIVE_ARCH STREQUAL "x86_64")
185 set(LLVM_NATIVE_ARCH X86)
186elseif (LLVM_NATIVE_ARCH MATCHES "sparc")
187 set(LLVM_NATIVE_ARCH Sparc)
188elseif (LLVM_NATIVE_ARCH MATCHES "powerpc")
189 set(LLVM_NATIVE_ARCH PowerPC)
190elseif (LLVM_NATIVE_ARCH MATCHES "alpha")
191 set(LLVM_NATIVE_ARCH Alpha)
192elseif (LLVM_NATIVE_ARCH MATCHES "arm")
193 set(LLVM_NATIVE_ARCH ARM)
194elseif (LLVM_NATIVE_ARCH MATCHES "mips")
195 set(LLVM_NATIVE_ARCH Mips)
196elseif (LLVM_NATIVE_ARCH MATCHES "pic16")
197 set(LLVM_NATIVE_ARCH "PIC16")
198elseif (LLVM_NATIVE_ARCH MATCHES "xcore")
199 set(LLVM_NATIVE_ARCH XCore)
200elseif (LLVM_NATIVE_ARCH MATCHES "msp430")
201 set(LLVM_NATIVE_ARCH MSP430)
202else ()
203 message(STATUS
204 "Unknown architecture ${LLVM_NATIVE_ARCH}; lli will not JIT code")
205 set(LLVM_NATIVE_ARCH)
206endif ()
207
208if (LLVM_NATIVE_ARCH)
209 list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX)
210 if (NATIVE_ARCH_IDX EQUAL -1)
211 message(STATUS
212 "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code")
213 set(LLVM_NATIVE_ARCH)
214 else ()
215 message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}")
216 endif ()
217endif()
218
219if( MINGW )
220 set(HAVE_LIBIMAGEHLP 1)
221 set(HAVE_LIBPSAPI 1)
222 # TODO: Check existence of libraries.
223 # include(CheckLibraryExists)
224 # CHECK_LIBRARY_EXISTS(imagehlp ??? . HAVE_LIBIMAGEHLP)
225endif( MINGW )
226
227if( MSVC )
228 set(error_t int)
229 set(mode_t "unsigned short")
230 set(LTDL_SHLIBPATH_VAR "PATH")
231 set(LTDL_SYSSEARCHPATH "")
232 set(LTDL_DLOPEN_DEPLIBS 1)
233 set(SHLIBEXT ".lib")
234 set(LTDL_OBJDIR "_libs")
235 set(HAVE_STRTOLL 1)
236 set(strtoll "_strtoi64")
237 set(strtoull "_strtoui64")
238 set(stricmp "_stricmp")
239 set(strdup "_strdup")
240else( MSVC )
241 set(LTDL_SHLIBPATH_VAR "LD_LIBRARY_PATH")
242 set(LTDL_SYSSEARCHPATH "") # TODO
243 set(LTDL_DLOPEN_DEPLIBS 0) # TODO
244endif( MSVC )
245
246# FIXME: Signal handler return type, currently hardcoded to 'void'
247set(RETSIGTYPE void)
248
249if( LLVM_ENABLE_THREADS )
250 if( HAVE_PTHREAD_H OR WIN32 )
251 set(ENABLE_THREADS 1)
252 endif()
253endif()
254
255if( ENABLE_THREADS )
256 message(STATUS "Threads enabled.")
257else( ENABLE_THREADS )
258 message(STATUS "Threads disabled.")
259endif()
260
261configure_file(
262 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake
263 ${LLVM_BINARY_DIR}/include/llvm/Config/config.h
264 )
265
266configure_file(
267 ${LLVM_MAIN_INCLUDE_DIR}/llvm/System/DataTypes.h.cmake
268 ${LLVM_BINARY_DIR}/include/llvm/System/DataTypes.h
269 )
270
Note: See TracBrowser for help on using the repository browser.