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,10 +161,33 @@ 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)
@@ -173,7 +198,9 @@ configure_file(${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY)
173
198
#
174
199
################################################################################
175
200
176
- add_definitions (-DDEV_BUILD)
201
+ if ("${CMAKE_BUILD_TYPE} " STREQUAL "Debug" )
202
+ add_definitions (-DDEV_BUILD)
203
+ endif ()
177
204
178
205
if (WIN32 )
179
206
set (OS_DIR win32 )
@@ -192,20 +219,71 @@ if (WIN32)
192
219
endif ()
193
220
endif (MSVC )
194
221
195
- set (LIB_Ws2_32 Ws2_32 )
222
+ set (LIB_ws2_32 ws2_32 )
196
223
set (LIB_comctl32 comctl32)
197
224
set (LIB_mpr mpr)
198
225
set (LIB_version version )
199
226
endif (WIN32 )
200
227
201
228
if (MINGW)
202
- # clear unix-style prefixes
229
+ # Clear unix-style prefixes
203
230
set (CMAKE_SHARED_LIBRARY_PREFIX )
204
231
set (CMAKE_SHARED_MODULE_PREFIX )
205
232
set (CMAKE_STATIC_LIBRARY_PREFIX )
206
233
207
- add_definitions (-D_WIN32_WINNT=0x0600)
234
+ if ("${CMAKE_BUILD_TYPE} " STREQUAL "Debug" )
235
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb" )
236
+ set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DDEBUG" )
237
+ else ()
238
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3" )
239
+ set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DNDEBUG" )
240
+ endif ()
241
+
242
+ add_definitions (-DMINGW_HAS_SECURE_API -DTTMATH_NOASM)
243
+
244
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shift-count-overflow" )
208
245
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4 -std=c++17" )
246
+
247
+ # Suppress myriad of warnings
248
+ set (cxx_flags "" )
249
+ list (APPEND cxx_flags
250
+ -Wundef
251
+ -Wno-format
252
+ -Wno-deprecated-declarations
253
+ -Wno-ignored-attributes
254
+ -Wno-invalid-offsetof
255
+ -Wno-long-long
256
+ -Wno-non-virtual-dtor
257
+ -Wno-parentheses
258
+ -Wno-shift-count-overflow
259
+ -Wno-sign-compare
260
+ -Wno-switch
261
+ -Wno-unused-variable
262
+ -Wno-write-strings
263
+ )
264
+ if (CLANG)
265
+ list (APPEND cxx_flags
266
+ -Wno-varargs
267
+ -Wno-constant-conversion
268
+ -Wno-inconsistent-missing-override
269
+ -Wno-tautological-constant-out-of-range-compare
270
+ -Wno-c++11-narrowing
271
+ )
272
+ else ()
273
+ list (APPEND cxx_flags
274
+ -Wno-class-memaccess
275
+ -Wno-overflow
276
+ -Wno-return-local-addr
277
+ -Wno-stringop-overflow
278
+ -Wno-stringop-overread
279
+ -Wno-narrowing
280
+ )
281
+ endif ()
282
+ string (REPLACE ";" " " cxx_flags "${cxx_flags} " )
283
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flags} " )
284
+
285
+ set (LIB_iconv iconv)
286
+ set (LIB_re2 re2)
209
287
endif ()
210
288
211
289
if (UNIX )
@@ -214,8 +292,12 @@ if (UNIX)
214
292
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
215
293
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -msse4 -std=c++17" )
216
294
295
+ set (FB_INTERNAL_TOMMATH ON )
296
+ set (FB_INTERNAL_EDITLINE ON )
297
+
298
+ set (LIB_re2 re2)
217
299
if (NOT CMAKE_CROSSCOMPILING )
218
- set (LIB_readline readline )
300
+ set (LIB_editline editline )
219
301
endif ()
220
302
if (NOT FREEBSD)
221
303
set (LIB_dl dl)
@@ -251,7 +333,7 @@ endif()
251
333
#
252
334
################################################################################
253
335
254
- if (WIN32 )
336
+ if (MSVC )
255
337
# icu
256
338
if (NOT ICU_EXTRACT)
257
339
message (STATUS "Extracting pre-built ICU" )
@@ -324,29 +406,50 @@ if (NOT CMAKE_CROSSCOMPILING)
324
406
create_boot_commands()
325
407
create_master_commands()
326
408
327
- endif () # if (NOT CMAKE_CROSSCOMPILING)
409
+ endif () # (NOT CMAKE_CROSSCOMPILING)
328
410
329
411
crosscompile_prebuild_steps()
330
412
331
- include_directories ("extern/libtommath" )
332
- include_directories ("extern/libtomcrypt/src/headers" )
413
+ if (FB_INTERNAL_TOMMATH)
414
+ include_directories ("extern/libtommath" )
415
+ include_directories ("extern/libtomcrypt/src/headers" )
416
+ set (LIB_tommath libtommath)
417
+ set (LIB_tomcrypt libtomcrypt)
418
+ else ()
419
+ set (LIB_tommath tommath)
420
+ set (LIB_tomcrypt tomcrypt)
421
+ endif ()
422
+
423
+ if (UNIX )
424
+ if (FB_INTERNAL_EDITLINE)
425
+ include_directories ("extern/editline" )
426
+ endif ()
427
+ endif ()
428
+
333
429
include_directories ("extern/decNumber" )
334
- include_directories ("extern/icu/include" )
335
- include_directories ("extern/zlib" )
430
+ include_directories ("extern/libcds" )
431
+ include_directories ("extern/re2" )
432
+
433
+ if (MSVC OR ANDROID)
434
+ include_directories ("extern/icu/include" )
435
+ include_directories ("extern/zlib" )
436
+ endif ()
336
437
337
438
include_directories ("src/include" )
338
439
include_directories ("src/include/gen" )
339
440
include_directories ("${CMAKE_CURRENT_BINARY_DIR} /src/include" )
340
441
include_directories ("${CMAKE_CURRENT_BINARY_DIR} /src/include/gen" )
341
442
443
+
444
+ if (FB_INTERNAL_TOMMATH)
342
445
########################################
343
446
# LIBRARY libtommath
344
447
########################################
345
448
346
449
file (GLOB libtommath_src "extern/libtommath/*.c" "extern/libtommath/*.h" )
347
450
348
- add_library (libtommath ${libtommath_src} )
349
- project_group (libtommath Extern)
451
+ add_library (libtommath ${libtommath_src} )
452
+ project_group (libtommath Extern)
350
453
351
454
352
455
########################################
@@ -362,6 +465,8 @@ add_library (libtomcrypt ${libtomcrypt_src})
362
465
target_compile_definitions (libtomcrypt PRIVATE LTC_NO_ROLC LTC_SOURCE)
363
466
project_group (libtomcrypt Extern)
364
467
468
+ endif () # (FB_INTERNAL_TOMMATH)
469
+
365
470
366
471
########################################
367
472
# LIBRARY decNumber
@@ -375,6 +480,30 @@ add_library (decNumber ${decNumber_src})
375
480
project_group (decNumber Extern)
376
481
377
482
483
+ if (FB_INTERNAL_EDITLINE)
484
+ ########################################
485
+ # LIBRARY editline
486
+ ########################################
487
+
488
+ file (GLOB editline_src "extern/editline/src/*.c" "extern/editline/src/*.h" )
489
+
490
+ add_library (editline ${editline_src} )
491
+ project_group (editline Extern)
492
+
493
+ endif () # (FB_INTERNAL_EDITLINE)
494
+
495
+
496
+ ########################################
497
+ # LIBRARY libcds
498
+ ########################################
499
+
500
+ file (GLOB_RECURSE libcds_src "extern/libcds/src/*.cpp" )
501
+
502
+ add_library (libcds ${libcds_src} )
503
+ target_compile_definitions (libcds PUBLIC CDS_BUILD_STATIC_LIB)
504
+ project_group (libcds Extern)
505
+
506
+
378
507
########################################
379
508
# EXECUTABLE btyacc
380
509
########################################
@@ -383,25 +512,27 @@ file(GLOB btyacc_src "extern/btyacc/*.c" "extern/btyacc/*.h")
383
512
384
513
if (NOT CMAKE_CROSSCOMPILING )
385
514
386
- add_executable (btyacc ${btyacc_src} )
387
- project_group (btyacc Extern )
388
- set_output_directory (btyacc . CURRENT_DIR )
515
+ add_executable (btyacc ${btyacc_src} )
516
+ set_output_directory (btyacc src CURRENT_DIR )
517
+ project_group (btyacc Extern )
389
518
390
- endif () # if (NOT CMAKE_CROSSCOMPILING)
519
+ endif () # (NOT CMAKE_CROSSCOMPILING)
391
520
392
521
########################################
393
522
# EXECUTABLE cloop
394
523
########################################
395
524
396
525
file (GLOB cloop_src "extern/cloop/src/cloop/*.cpp" "extern/cloop/src/cloop/*.h" )
397
526
398
- add_executable (cloop ${cloop_src} )
399
- project_group (cloop Extern)
527
+ add_executable (cloop ${cloop_src} )
528
+ set_output_directory (cloop src CURRENT_DIR)
529
+ project_group (cloop Extern)
400
530
401
531
########################################
402
532
# subdirectories
403
533
########################################
404
534
535
+ add_subdirectory ("extern/re2" )
405
536
add_subdirectory ("examples" )
406
537
add_subdirectory ("src" )
407
538
0 commit comments