17
17
#
18
18
################################################################################
19
19
20
- cmake_minimum_required (VERSION 2.8.12 )
20
+ cmake_minimum_required (VERSION 3.15 )
21
21
22
22
# In-source builds are not possible and so disabled.
23
23
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
@@ -84,6 +84,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${output_dir})
84
84
if (MSVC OR XCODE)
85
85
set (output_dir ${output_dir} /$<CONFIG>)
86
86
set (boot_dir ${boot_dir} /$<CONFIG>)
87
+ elseif (MINGW)
88
+ set (output_dir ${CMAKE_BINARY_DIR} )
87
89
endif ()
88
90
89
91
if (MSVC AND DEFAULT_CONFIGURATION)
@@ -98,7 +100,7 @@ if (XCODE)
98
100
string (TOUPPER ${conf} conf2)
99
101
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_${conf2} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} /${conf} /bin)
100
102
endforeach ()
101
- elseif (UNIX )
103
+ elseif (UNIX OR MINGW )
102
104
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${output_dir} /bin)
103
105
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${output_dir} /bin)
104
106
endif ()
@@ -147,8 +149,8 @@ endif()
147
149
148
150
include (Configure)
149
151
150
- if (FREEBSD)
151
- # temporary
152
+ if (FREEBSD OR MINGW )
153
+ # Build-time temporary installation path
152
154
set (CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} )
153
155
endif ()
154
156
@@ -159,21 +161,55 @@ set(FB_SERVICE_NAME "gds_db")
159
161
set (FB_SERVICE_PORT 3050)
160
162
161
163
if (WIN32 )
162
- set (FB_PREFIX "c:\\\\ Program Files\\\\ Firebird\\\\ " )
164
+ if (MSVC )
165
+ set (FB_PREFIX "c:\\\\ Program Files\\\\ Firebird\\\\ " )
166
+ else ()
167
+ set (FB_PREFIX ${CMAKE_INSTALL_PREFIX} )
168
+ endif ()
163
169
set (FB_IPC_NAME "FIREBIRD" )
164
170
endif ()
165
171
172
+ if (MINGW)
173
+ set (FB_BINDIR "${FB_PREFIX} /bin" )
174
+ set (FB_SBINDIR "${FB_PREFIX} /bin" )
175
+ set (FB_INCDIR "${FB_PREFIX} /include" )
176
+ set (FB_LIBDIR "${FB_PREFIX} /lib" )
177
+ set (FB_CONFDIR "${FB_PREFIX} /etc/firebird" )
178
+ set (FB_GUARDDIR "${FB_PREFIX} /etc/firebird" )
179
+ set (FB_LOGDIR "${FB_PREFIX} /etc/firebird" )
180
+ set (FB_MSGDIR "${FB_PREFIX} /etc/firebird" )
181
+ set (FB_SECDBDIR "${FB_PREFIX} /etc/firebird" )
182
+ set (FB_DOCDIR "${FB_PREFIX} /share/firebird/doc" )
183
+ set (FB_INTLDIR "${FB_PREFIX} /share/firebird/intl" )
184
+ set (FB_MISCDIR "${FB_PREFIX} /share/firebird/misc" )
185
+ set (FB_PLUGDIR "${FB_PREFIX} /share/firebird/plugins" )
186
+ set (FB_SAMPLEDBDIR "${FB_PREFIX} /share/firebird/examples/empbuild" )
187
+ set (FB_SAMPLEDIR "${FB_PREFIX} /share/firebird/examples" )
188
+ set (FB_TZDATADIR "${FB_PREFIX} /share/firebird/tzdata" )
189
+ endif ()
190
+
166
191
set (AUTOCONFIG_SRC ${CMAKE_SOURCE_DIR} /src/include /gen/autoconfig.h.in)
167
192
set (AUTOCONFIG ${CMAKE_BINARY_DIR} /src/include /gen/autoconfig.h)
168
193
configure_file (${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY)
169
194
195
+ if (MINGW)
196
+ # Set the final installation path
197
+ set (FB_PREFIX ${FB_INSTALL_PREFIX} )
198
+
199
+ set (FBCONFIG_SRC ${CMAKE_SOURCE_DIR} /builds/install /arch-specific/mingw/fb_config.in)
200
+ set (FBCONFIG ${CMAKE_BINARY_DIR} /fb_config)
201
+ configure_file (${FBCONFIG_SRC} ${FBCONFIG} @ONLY)
202
+ endif ()
203
+
170
204
################################################################################
171
205
#
172
206
# compiler & linker settings
173
207
#
174
208
################################################################################
175
209
176
- add_definitions (-DDEV_BUILD)
210
+ if ("${CMAKE_BUILD_TYPE} " STREQUAL "Debug" )
211
+ add_definitions (-DDEV_BUILD)
212
+ endif ()
177
213
178
214
if (WIN32 )
179
215
set (OS_DIR win32 )
@@ -192,20 +228,71 @@ if (WIN32)
192
228
endif ()
193
229
endif (MSVC )
194
230
195
- set (LIB_Ws2_32 Ws2_32 )
231
+ set (LIB_ws2_32 ws2_32 )
196
232
set (LIB_comctl32 comctl32)
197
233
set (LIB_mpr mpr)
198
234
set (LIB_version version )
199
235
endif (WIN32 )
200
236
201
237
if (MINGW)
202
- # clear unix-style prefixes
238
+ # Clear unix-style prefixes
203
239
set (CMAKE_SHARED_LIBRARY_PREFIX )
204
240
set (CMAKE_SHARED_MODULE_PREFIX )
205
241
set (CMAKE_STATIC_LIBRARY_PREFIX )
206
242
207
- add_definitions (-D_WIN32_WINNT=0x0600)
243
+ if ("${CMAKE_BUILD_TYPE} " STREQUAL "Debug" )
244
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb" )
245
+ set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DDEBUG" )
246
+ else ()
247
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3" )
248
+ set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DNDEBUG" )
249
+ endif ()
250
+
251
+ add_definitions (-DWIN_NT -DMINGW -DMINGW_HAS_SECURE_API -DTTMATH_NOASM)
252
+
253
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shift-count-overflow" )
208
254
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4 -std=c++17" )
255
+
256
+ # Suppress myriad of warnings
257
+ set (cxx_flags "" )
258
+ list (APPEND cxx_flags
259
+ -Wundef
260
+ -Wno-format
261
+ -Wno-deprecated-declarations
262
+ -Wno-ignored-attributes
263
+ -Wno-invalid-offsetof
264
+ -Wno-long-long
265
+ -Wno-non-virtual-dtor
266
+ -Wno-parentheses
267
+ -Wno-shift-count-overflow
268
+ -Wno-sign-compare
269
+ -Wno-switch
270
+ -Wno-unused-variable
271
+ -Wno-write-strings
272
+ )
273
+ if (CLANG)
274
+ list (APPEND cxx_flags
275
+ -Wno-varargs
276
+ -Wno-constant-conversion
277
+ -Wno-inconsistent-missing-override
278
+ -Wno-tautological-constant-out-of-range-compare
279
+ -Wno-c++11-narrowing
280
+ )
281
+ else ()
282
+ list (APPEND cxx_flags
283
+ -Wno-class-memaccess
284
+ -Wno-overflow
285
+ -Wno-return-local-addr
286
+ -Wno-stringop-overflow
287
+ -Wno-stringop-overread
288
+ -Wno-narrowing
289
+ )
290
+ endif ()
291
+ string (REPLACE ";" " " cxx_flags "${cxx_flags} " )
292
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flags} " )
293
+
294
+ set (LIB_iconv iconv)
295
+ set (LIB_re2 re2)
209
296
endif ()
210
297
211
298
if (UNIX )
@@ -214,8 +301,12 @@ if (UNIX)
214
301
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
215
302
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -msse4 -std=c++17" )
216
303
304
+ set (FB_INTERNAL_TOMMATH ON )
305
+ set (FB_INTERNAL_EDITLINE ON )
306
+
307
+ set (LIB_re2 re2)
217
308
if (NOT CMAKE_CROSSCOMPILING )
218
- set (LIB_readline readline )
309
+ set (LIB_editline editline )
219
310
endif ()
220
311
if (NOT FREEBSD)
221
312
set (LIB_dl dl)
@@ -251,7 +342,7 @@ endif()
251
342
#
252
343
################################################################################
253
344
254
- if (WIN32 )
345
+ if (MSVC )
255
346
# icu
256
347
if (NOT ICU_EXTRACT)
257
348
message (STATUS "Extracting pre-built ICU" )
@@ -324,29 +415,50 @@ if (NOT CMAKE_CROSSCOMPILING)
324
415
create_boot_commands()
325
416
create_master_commands()
326
417
327
- endif () # if (NOT CMAKE_CROSSCOMPILING)
418
+ endif () # (NOT CMAKE_CROSSCOMPILING)
328
419
329
420
crosscompile_prebuild_steps()
330
421
331
- include_directories ("extern/libtommath" )
332
- include_directories ("extern/libtomcrypt/src/headers" )
422
+ if (FB_INTERNAL_TOMMATH)
423
+ include_directories ("extern/libtommath" )
424
+ include_directories ("extern/libtomcrypt/src/headers" )
425
+ set (LIB_tommath libtommath)
426
+ set (LIB_tomcrypt libtomcrypt)
427
+ else ()
428
+ set (LIB_tommath tommath)
429
+ set (LIB_tomcrypt tomcrypt)
430
+ endif ()
431
+
432
+ if (UNIX )
433
+ if (FB_INTERNAL_EDITLINE)
434
+ include_directories ("extern/editline" )
435
+ endif ()
436
+ endif ()
437
+
333
438
include_directories ("extern/decNumber" )
334
- include_directories ("extern/icu/include" )
335
- include_directories ("extern/zlib" )
439
+ include_directories ("extern/libcds" )
440
+ include_directories ("extern/re2" )
441
+
442
+ if (MSVC OR ANDROID)
443
+ include_directories ("extern/icu/include" )
444
+ include_directories ("extern/zlib" )
445
+ endif ()
336
446
337
447
include_directories ("src/include" )
338
448
include_directories ("src/include/gen" )
339
449
include_directories ("${CMAKE_CURRENT_BINARY_DIR} /src/include" )
340
450
include_directories ("${CMAKE_CURRENT_BINARY_DIR} /src/include/gen" )
341
451
452
+
453
+ if (FB_INTERNAL_TOMMATH)
342
454
########################################
343
455
# LIBRARY libtommath
344
456
########################################
345
457
346
458
file (GLOB libtommath_src "extern/libtommath/*.c" "extern/libtommath/*.h" )
347
459
348
- add_library (libtommath ${libtommath_src} )
349
- project_group (libtommath Extern)
460
+ add_library (libtommath ${libtommath_src} )
461
+ project_group (libtommath Extern)
350
462
351
463
352
464
########################################
@@ -362,6 +474,8 @@ add_library (libtomcrypt ${libtomcrypt_src})
362
474
target_compile_definitions (libtomcrypt PRIVATE LTC_NO_ROLC LTC_SOURCE)
363
475
project_group (libtomcrypt Extern)
364
476
477
+ endif () # (FB_INTERNAL_TOMMATH)
478
+
365
479
366
480
########################################
367
481
# LIBRARY decNumber
@@ -375,6 +489,30 @@ add_library (decNumber ${decNumber_src})
375
489
project_group (decNumber Extern)
376
490
377
491
492
+ if (FB_INTERNAL_EDITLINE)
493
+ ########################################
494
+ # LIBRARY editline
495
+ ########################################
496
+
497
+ file (GLOB editline_src "extern/editline/src/*.c" "extern/editline/src/*.h" )
498
+
499
+ add_library (editline ${editline_src} )
500
+ project_group (editline Extern)
501
+
502
+ endif () # (FB_INTERNAL_EDITLINE)
503
+
504
+
505
+ ########################################
506
+ # LIBRARY libcds
507
+ ########################################
508
+
509
+ file (GLOB_RECURSE libcds_src "extern/libcds/src/*.cpp" )
510
+
511
+ add_library (libcds ${libcds_src} )
512
+ target_compile_definitions (libcds PUBLIC CDS_BUILD_STATIC_LIB)
513
+ project_group (libcds Extern)
514
+
515
+
378
516
########################################
379
517
# EXECUTABLE btyacc
380
518
########################################
@@ -383,25 +521,27 @@ file(GLOB btyacc_src "extern/btyacc/*.c" "extern/btyacc/*.h")
383
521
384
522
if (NOT CMAKE_CROSSCOMPILING )
385
523
386
- add_executable (btyacc ${btyacc_src} )
387
- project_group (btyacc Extern )
388
- set_output_directory (btyacc . CURRENT_DIR )
524
+ add_executable (btyacc ${btyacc_src} )
525
+ set_output_directory (btyacc src CURRENT_DIR )
526
+ project_group (btyacc Extern )
389
527
390
- endif () # if (NOT CMAKE_CROSSCOMPILING)
528
+ endif () # (NOT CMAKE_CROSSCOMPILING)
391
529
392
530
########################################
393
531
# EXECUTABLE cloop
394
532
########################################
395
533
396
534
file (GLOB cloop_src "extern/cloop/src/cloop/*.cpp" "extern/cloop/src/cloop/*.h" )
397
535
398
- add_executable (cloop ${cloop_src} )
399
- project_group (cloop Extern)
536
+ add_executable (cloop ${cloop_src} )
537
+ set_output_directory (cloop src CURRENT_DIR)
538
+ project_group (cloop Extern)
400
539
401
540
########################################
402
541
# subdirectories
403
542
########################################
404
543
544
+ add_subdirectory ("extern/re2" )
405
545
add_subdirectory ("examples" )
406
546
add_subdirectory ("src" )
407
547
0 commit comments