-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
360 lines (296 loc) · 13.2 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
PROJECT(clucene-shared)
#define command line options
INCLUDE (DefineOptions)
DEFINE_OPTIONS(EXTRA_OPTIONS EXTRA_LIBS)
ADD_DEFINITIONS(${EXTRA_OPTIONS} -DMAKE_CLUCENE_SHARED_LIB)
# include specific modules
set(CMAKE_MODULE_PATH "${clucene-shared_SOURCE_DIR}/cmake")
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckIncludeFileCXX)
INCLUDE (CheckCXXSourceCompiles)
INCLUDE (CheckCXXSourceRuns)
INCLUDE (CheckFunctionExists)
#local macros
INCLUDE (MacroMustDefine)
INCLUDE (MacroChooseType)
INCLUDE (MacroChooseMisc)
INCLUDE (MacroChooseFunction)
INCLUDE (MacroChooseSymbol)
INCLUDE (MacroCheckGccVisibility)
INCLUDE (DefineFloat)
INCLUDE (DefineDword)
INCLUDE (DefineLongLongSyntax)
INCLUDE (DefineStaticSyntax)
INCLUDE (DefineMAXPATHValue)
INCLUDE (CheckFloatByte)
INCLUDE (CheckErrorHandling)
INCLUDE (CheckHashmaps)
INCLUDE (CheckNamespace)
INCLUDE (CheckSnprintf)
INCLUDE (CheckStdCallFunctionExists)
find_package(Threads REQUIRED)
INCLUDE (CheckPthread)
INCLUDE (CheckAtomicFunctions)
find_package(ZLIB)
IF ( ZLIB_FOUND )
SET ( EXTRA_LIBS ${EXTRA_LIBS} ${ZLIB_LIBRARY} )
ELSE ( ZLIB_FOUND )
MESSAGE( "ZLIB not found, using local: ${clucene-ext_SOURCE_DIR}/zlib" )
SET(ZLIB_INCLUDE_DIR ${clucene-ext_SOURCE_DIR}/zlib )
SET(ZLIB_LIBRARY ${clucene-ext_BINARY_DIR})
ENDIF ( ZLIB_FOUND )
INCLUDE_DIRECTORIES( ${ZLIB_INCLUDE_DIR} )
########################################################################
# test for headers
########################################################################
CHECK_INCLUDE_FILES ("sys/time.h;time.h" _CL_TIME_WITH_SYS_TIME)
CHECK_REQUIRED_HEADERS ( stdlib.h stdarg.h stdio.h stddef.h ctype.h algorithm
functional map vector list set math.h fcntl.h limits.h)
CHECK_OPTIONAL_HEADERS ( string.h sys/time.h memory.h sys/types.h
stdint.h unistd.h io.h direct.h sys/dir.h sys/ndir.h dirent.h wctype.h fcntl.h
stat.h sys/stat.h stdexcept errno.h fcntl.h windef.h windows.h wchar.h
hash_map hash_set ext/hash_map ext/hash_map tr1/unordered_set tr1/unordered_map
sys/timeb.h tchar.h strings.h stdexcept sys/mman.h winerror.h )
########################################################################
# test for types
########################################################################
#find int_t types
CHOOSE_TYPE(int8_t 1 signed "int8_t;char")
CHOOSE_TYPE(uint8_t 1 unsigned "uint8_t;char")
CHOOSE_TYPE(int16_t 2 signed "int16_t;short")
CHOOSE_TYPE(uint16_t 2 unsigned "uint16_t;short")
CHOOSE_TYPE(int32_t 4 signed "int32_t;int;long")
CHOOSE_TYPE(uint32_t 4 unsigned "uint32_t;int;long")
CHOOSE_TYPE(int64_t 8 signed "int64_t;long long;__int64")
CHOOSE_TYPE(uint64_t 8 unsigned "uint64_t;long long;__int64")
CHOOSE_TYPE(size_t -1 unsigned "size_t;int" )
CHOOSE_MISC(TYPE__TIMEB
HAVE_TYPE__TIMEB
"struct _timeb x\;" "/* #undef _timeb */" "_timeb"
"struct timeb x\;" "#define _timeb timeb" "timeb"
)
#run macro for checking float. (and _FLT_EVAL_METHOD)
DEFINE_FLOAT()
DEFINE_DWORD()
########################################################################
# Test for functions
########################################################################
CHECK_REQUIRED_FUNCTIONS( printf strftime wcscpy wcsncpy wcscat wcschr wcsstr wcslen
wcscmp wcsncmp wcscspn )
#todo: wcstoq is bsd equiv of wcstoll, we can use that...
CHECK_OPTIONAL_FUNCTIONS( wcsupr wcscasecmp wcsicmp wcstoll wprintf lltow
wcstod wcsdup strupr strlwr lltoa strtoll gettimeofday _vsnwprintf mmap "MapViewOfFile(0,0,0,0,0)"
)
#make decisions about which functions to use...
CHOOSE_FUNCTION(fileHandleStat "fstati64;_fstati64;fstat64;fstat;_fstat")
IF ( _CL_HAVE_FUNCTION_FSTATI64 OR _CL_HAVE_FUNCTION__FSTATI64 OR _CL_HAVE_FUNCTION_FSTAT64 )
SET ( USE_STAT64 1 )
ENDIF ( _CL_HAVE_FUNCTION_FSTATI64 OR _CL_HAVE_FUNCTION__FSTATI64 OR _CL_HAVE_FUNCTION_FSTAT64 )
IF ( USE_STAT64 )
CHOOSE_FUNCTION(fileStat "stati64;_stati64;stat64;stat;_stat")
CHOOSE_FUNCTION(fileSize "filelengthi64;_filelengthi64;filelength;_filelength" "#define fileSize CL_NS(util)::Misc::filelength")
CHOOSE_FUNCTION(fileSeek "lseeki64;_lseeki64;lseek64;lseek;_lseek")
CHOOSE_MISC(TYPE_CL_STAT_T
HAVE_TYPE_CL_STAT_T
"struct stati64 x\;" "#define cl_stat_t stati64" "stati64"
"struct _stati64 x\;" "#define cl_stat_t _stati64" "_stati64"
"struct stat64 x\;" "#define cl_stat_t stat64" "stat64"
"struct stat x\;" "#define cl_stat_t stat" "stat"
"struct _stat x\;" "#define cl_stat_t _stat" "_stat"
)
ELSE( USE_STAT64 )
#borland doesn't have a fstat64, so we have to fallback to non 64 bit everything...
CHOOSE_FUNCTION(fileStat "stat;_stat")
CHOOSE_FUNCTION(fileSize "filelength;_filelength" "#define fileSize CL_NS(util)::Misc::filelength")
CHOOSE_FUNCTION(fileSeek "lseek;_lseek")
CHOOSE_MISC(TYPE_CL_STAT_T
HAVE_TYPE_CL_STAT_T
"struct stat x\;" "#define cl_stat_t stat" "stat"
"struct _stat x\;" "#define cl_stat_t _stat" "_stat"
)
ENDIF( USE_STAT64 )
#ftell (and probably soon ftell64) are POSIX standard functions, but tell and
#tell64 are not, so we define fileTell in terms of fileSeek.
CHOOSE_FUNCTION(fileTell "telli64;_telli64;tell64;tell;_tell" "#define fileTell(fhandle) fileSeek(fhandle, 0, SEEK_CUR)")
CHOOSE_FUNCTION(_realpath "realpath" "#define _realpath(rel,abs) ::_fullpath(abs,rel,CL_MAX_PATH)")
CHOOSE_FUNCTION(_rename "rename")
CHOOSE_FUNCTION(_close "_close((int)0);close")
CHOOSE_FUNCTION(_read "_read((int)0, (void*)0, (unsigned int)0);read")
CHOOSE_FUNCTION(_cl_open "_open(0,0,0);open")
CHOOSE_FUNCTION(_write "_write((int)0, (const void*)0, (unsigned int)0);write")
CHOOSE_FUNCTION(_unlink "_unlink((const char*)0);unlink")
CHOOSE_FUNCTION(_ftime "_ftime(0);ftime")
CHOOSE_FUNCTION(_mkdir "_mkdir((const char*)0)" "#define _mkdir(x) mkdir(x,0777)")
CHOOSE_FUNCTION(SLEEPFUNCTION "usleep;Sleep(0);_sleep")
CHOOSE_FUNCTION(_snprintf "snprintf;_snprintf")
CHOOSE_FUNCTION(_snwprintf "snwprintf;_snwprintf")
########################################################################
# test for symbols
########################################################################
CHOOSE_SYMBOL (_O_RANDOM "_O_RANDOM;O_RANDOM")
CHOOSE_SYMBOL (_O_BINARY "_O_BINARY;O_BINARY")
CHOOSE_SYMBOL (_S_IREAD "_S_IREAD;S_IREAD")
CHOOSE_SYMBOL (_S_IWRITE "_S_IWRITE;S_IWRITE")
#define defaults
IF ( NOT HAVE_SYMBOL__O_RANDOM )
SET (SYMBOL__O_RANDOM "#define _O_RANDOM 0")
ENDIF ( NOT HAVE_SYMBOL__O_RANDOM )
IF ( NOT HAVE_SYMBOL__O_BINARY )
SET (SYMBOL__O_BINARY "#define _O_BINARY 0")
ENDIF ( NOT HAVE_SYMBOL__O_BINARY)
IF ( NOT HAVE_SYMBOL__S_IREAD )
SET (SYMBOL__S_IREAD "#define _S_IREAD 0333")
ENDIF ( NOT HAVE_SYMBOL__S_IREAD )
IF ( NOT HAVE_SYMBOL__S_IWRITE )
SET (SYMBOL__S_IWRITE "#define _S_IWRITE 0333")
ENDIF ( NOT HAVE_SYMBOL__S_IWRITE )
#try and figure out the actual value of what _CL_MAX_PATH is
DEFINE_MAXPATH_VALUE (SYMBOL_CL_MAX_PATH)
########################################################################
# test for tchar replacments
########################################################################
IF ( ENABLE_ASCII_MODE )
CHOOSE_TYPE(TCHAR 1 "" "TCHAR;char" SYMBOL_TCHAR )
ELSE ( ENABLE_ASCII_MODE )
CHOOSE_TYPE(TCHAR -1 "" "TCHAR;wchar_t;unsigned short" SYMBOL_TCHAR)
ENDIF ( ENABLE_ASCII_MODE )
IF ( NOT SYMBOL_TCHAR STREQUAL "TCHAR" )
SET( SYMBOL_TCHAR "#define TCHAR ${SYMBOL_TCHAR}" )
ELSE ( NOT SYMBOL_TCHAR STREQUAL "TCHAR" )
SET( SYMBOL_TCHAR "/* #undef TCHAR */" )
ENDIF ( NOT SYMBOL_TCHAR STREQUAL "TCHAR" )
CHOOSE_SYMBOL (_T "_T" SYMBOL__T)
IF ( NOT HAVE_SYMBOL__T )
IF ( ENABLE_ASCII_MODE )
SET (SYMBOL__T "#define _T(x) x")
ELSE ( ENABLE_ASCII_MODE )
SET (SYMBOL__T "#define _T(x) L ## x")
ENDIF ( ENABLE_ASCII_MODE )
ELSE ( NOT HAVE_SYMBOL__T )
SET( SYMBOL__T "/* #undef _T */" )
ENDIF ( NOT HAVE_SYMBOL__T )
########################################################################
# test for compiler capabilities.
########################################################################
#check for pthreads
IF ( CMAKE_USE_WIN32_THREADS_INIT )
SET ( _CL_HAVE_WIN32_THREADS 1 )
ENDIF ( CMAKE_USE_WIN32_THREADS_INIT )
IF ( CMAKE_USE_PTHREADS_INIT AND NOT _CL_HAVE_WIN32_THREADS)
SET ( _CL_HAVE_PTHREAD 1 )
ENDIF (CMAKE_USE_PTHREADS_INIT AND NOT _CL_HAVE_WIN32_THREADS)
IF ( CMAKE_USE_SPROC_INIT OR CMAKE_HP_PTHREADS_INIT )
MESSAGE(FATAL_ERROR "Threads library not implemented")
ENDIF( CMAKE_USE_SPROC_INIT OR CMAKE_HP_PTHREADS_INIT )
#define if we have pthreads with recursive capabilities
CHECK_PTHREAD_RECURSIVE(_CL_HAVE_PTHREAD _CL_HAVE_PTHREAD_MUTEX_RECURSIVE)
CHECK_HAVE_GCC_ATOMIC_FUNCTIONS(_CL_HAVE_GCC_ATOMIC_FUNCTIONS)
#see if we can hide all symbols by default...
MACRO_CHECK_GCC_VISIBILITY(_CL_HAVE_GCCVISIBILITYPATCH)
#Check that we can handle try/catch
CHECK_HAVE_FUNCTION_TRY_BLOCKS (_CL_HAVE_TRY_BLOCKS)
#check that we support new float byte<->float conversions
CHECK_FLOAT_BYTE_WORKS(_CL_HAVE_NO_FLOAT_BYTE, 1)
#check how to use hashmaps
CHECK_HASH_MAPS (CL_NS_HASHING_VALUE LUCENE_DISABLE_HASHING)
#check that we have namespace support
CHECK_NAMESPACE (_CL_HAVE_NAMESPACES)
#check if snprintf functions are buggy
CHECK_SNPRINTF()
#define how we are going to define 64bit numbers
DEFINE_LONGLONG_SYNTAX()
#define how to define a static const (or fallback to enum)
DEFINE_STATIC_SYNTAX()
#test for ansi for scope (needed for msvc6)
INCLUDE(TestForANSIForScope)
IF ( CMAKE_ANSI_FOR_SCOPE )
SET ( CMAKE_ANSI_FOR_SCOPE 1 )
ELSE ( CMAKE_ANSI_FOR_SCOPE )
SET ( CMAKE_ANSI_FOR_SCOPE 0 )
ENDIF ( CMAKE_ANSI_FOR_SCOPE )
#check that all these definitions are set, or fail...
MUSTDEFINE_VAR("HAVE_TYPE_INT8_T;HAVE_TYPE_UINT8_T;HAVE_TYPE_INT16_T;HAVE_TYPE_UINT16_T;HAVE_TYPE_UINT16_T;" )
MUSTDEFINE_VAR("HAVE_TYPE_INT32_T;HAVE_TYPE_UINT32_T;HAVE_TYPE_INT64_T;HAVE_TYPE_UINT64_T;HAVE_TYPE_SIZE_T;HAVE_TYPE_CL_STAT_T")
MUSTDEFINE_VAR("_CL_HAVE_TRY_BLOCKS")
#must have timeb OR GETTIMEOFDAY
IF ( NOT HAVE_TYPE__TIMEB AND NOT _CL_HAVE_FUNCTION_GETTIMEOFDAY )
MESSAGE( FATAL_ERROR "timeb or gettimeofday must be available." )
ENDIF ( NOT HAVE_TYPE__TIMEB AND NOT _CL_HAVE_FUNCTION_GETTIMEOFDAY )
#now write out our configuration....
CONFIGURE_FILE(${clucene-shared_SOURCE_DIR}/CLucene/clucene-config.h.cmake ${clucene-shared_BINARY_DIR}/CLucene/clucene-config.h)
CONFIGURE_FILE(${clucene-shared_SOURCE_DIR}/CLucene/_clucene-config.h.cmake ${clucene-shared_BINARY_DIR}/CLucene/_clucene-config.h)
#add the files to our groups
SOURCE_GROUP("config" ./CLucene/config/*)
SOURCE_GROUP("debug" ./CLucene/debug/*)
SOURCE_GROUP("util" ./CLucene/util/*)
SOURCE_GROUP("zlib" ./zlib/*)
MACRO (GET_SHARED_FILES result)
IF ( "" STREQUAL "${ARGV2}" )
SET ( rel ${clucene-shared_SOURCE_DIR} )
ELSE ( "" STREQUAL "${ARGV2}" )
SET ( rel ${ARGV2} )
ENDIF ( "" STREQUAL "${ARGV2}" )
SET(${result}
${rel}/CLucene/SharedHeader.cpp
${rel}/CLucene/config/gunichartables.cpp
${rel}/CLucene/config/repl_tcslwr.cpp
${rel}/CLucene/config/repl_tcstoll.cpp
${rel}/CLucene/config/repl_tcscasecmp.cpp
${rel}/CLucene/config/repl_tprintf.cpp
${rel}/CLucene/config/repl_lltot.cpp
${rel}/CLucene/config/repl_tcstod.cpp
${rel}/CLucene/config/utf8.cpp
${rel}/CLucene/config/threads.cpp
${rel}/CLucene/debug/condition.cpp
${rel}/CLucene/util/StringBuffer.cpp
${rel}/CLucene/util/Misc.cpp
${rel}/CLucene/util/dirent.cpp
)
IF ( NOT ZLIB_FOUND )
SET(${result} ${${result}}
${clucene-ext_SOURCE_DIR}/zlib/adler32.c
${clucene-ext_SOURCE_DIR}/zlib/compress.c
${clucene-ext_SOURCE_DIR}/zlib/crc32.c
${clucene-ext_SOURCE_DIR}/zlib/deflate.c
${clucene-ext_SOURCE_DIR}/zlib/gzio.c
${clucene-ext_SOURCE_DIR}/zlib/inffast.c
${clucene-ext_SOURCE_DIR}/zlib/inflate.c
${clucene-ext_SOURCE_DIR}/zlib/inftrees.c
${clucene-ext_SOURCE_DIR}/zlib/trees.c
${clucene-ext_SOURCE_DIR}/zlib/zutil.c
)
ENDIF ( NOT ZLIB_FOUND )
ENDMACRO (GET_SHARED_FILES)
GET_SHARED_FILES(clucene_shared_Files ".")
#find our headers
file(GLOB_RECURSE HEADERS ${clucene-shared_SOURCE_DIR}/*.h)
add_library(clucene-shared SHARED
${clucene_shared_Files} ${HEADERS}
)
#set properties on the libraries
SET_TARGET_PROPERTIES(clucene-shared PROPERTIES
VERSION ${CLUCENE_VERSION}
SOVERSION ${CLUCENE_SOVERSION}
COMPILE_DEFINITIONS_DEBUG _DEBUG
)
TARGET_LINK_LIBRARIES(clucene-shared ${CMAKE_THREAD_LIBS_INIT})
IF ( EXTRA_LIBS )
TARGET_LINK_LIBRARIES(clucene-shared ${EXTRA_LIBS})
ENDIF ( EXTRA_LIBS )
install(TARGETS clucene-shared
DESTINATION ${LIB_DESTINATION}
COMPONENT development )
IF ( BUILD_STATIC_LIBRARIES )
add_library(clucene-shared-static STATIC
${clucene_shared_Files} ${HEADERS}
)
SET_TARGET_PROPERTIES(clucene-shared-static PROPERTIES
VERSION ${CLUCENE_VERSION}
SOVERSION ${CLUCENE_SOVERSION}
COMPILE_DEFINITIONS_DEBUG _DEBUG
)
TARGET_LINK_LIBRARIES(clucene-shared-static ${CMAKE_THREAD_LIBS_INIT})
install(TARGETS clucene-shared-static
DESTINATION ${LIB_DESTINATION}
COMPONENT runtime )
ENDIF ( BUILD_STATIC_LIBRARIES )