-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
881 lines (721 loc) · 28.7 KB
/
CMakeLists.txt
File metadata and controls
881 lines (721 loc) · 28.7 KB
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
cmake_minimum_required(VERSION 3.26.0)
# Minimum macOS version.
# Must be set before the project.
set(CMAKE_OSX_DEPLOYMENT_TARGET "15.0" CACHE STRING "macOS minimum supported target")
# Compiler selection (must be processed before project())
# Provides POCO_COMPILER and POCO_CROSS_COMPILE cache variables.
include(cmake/PocoCompilerSelect.cmake)
project(Poco)
file(STRINGS "${PROJECT_SOURCE_DIR}/libversion" SHARED_LIBRARY_VERSION)
# Read the version information from the VERSION file
file(STRINGS "${PROJECT_SOURCE_DIR}/VERSION" PACKAGE_VERSION)
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${PACKAGE_VERSION})
string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${PACKAGE_VERSION})
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_PATCH ${PACKAGE_VERSION})
set(PROJECT_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(RELEASE_NAME "Unstable-trunk")
# Put the libaries and binaries that get built into directories at the
# top of the build tree rather than in hard-to-find leaf
# directories. This simplifies manual testing and the use of the build
# tree rather than installed Boost libraries.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Library output")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Archive output")
# Windows DLLs are "runtime" for CMake. Output them to "bin" like the Visual Studio projects do.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Runtime output")
# Reset output dirs for multi-config builds
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin CACHE PATH "Runtime output for ${OUTPUTCONFIG}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib CACHE PATH "Library output for ${OUTPUTCONFIG}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib CACHE PATH "Archive output for ${OUTPUTCONFIG}")
endforeach(OUTPUTCONFIG)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Append our module directory to CMake
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
#################################################################################
# Setup C/C++ compiler options
#################################################################################
# Detect if compiler supports C++20 standard (preferred)
include(CXX2x)
check_for_cxx20_compiler(CXX20_COMPILER)
if (EMSCRIPTEN)
set(CXX20_COMPILER OFF)
endif()
if(CXX20_COMPILER)
set(CMAKE_CXX_STANDARD 20)
message(STATUS "Building Poco with C++20 standard")
else()
# Fall back to C++17
include(CXX1x)
check_for_cxx17_compiler(CXX17_COMPILER)
if(NOT CXX17_COMPILER)
message(FATAL_ERROR "Compiler does not support C++17 or later.")
endif()
set(CMAKE_CXX_STANDARD 17)
message(STATUS "Building Poco with C++17 standard (C++20 not available)")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
# Enable standard installation directories
include(GNUInstallDirs)
# Include some common macros to simpilfy the Poco CMake files
include(PocoMacros)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(POCO_MINIMAL_BUILD "Build only bare minimum Poco libraries identifoed with ENABLE options." OFF)
set(POCO_SANITIZEFLAGS CACHE STRING "Compiler-dependent sanitizer flags (like -fsanitize=address or /fsanitize=address")
if(MSVC)
option(POCO_MT "Set to OFF|ON (default is OFF) to control static build of POCO as /MT instead of /MD" OFF)
if(BUILD_SHARED_LIBS AND POCO_MT)
message(FATAL_ERROR "Cannot have both BUILD_SHARED_LIBS and POCO_MT")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif()
#
# Path to OpenSSL installation root can be provided by setting a variable
# OPENSSL_ROOT_DIR.
#
# CMake pre-4.1 does not have fixes to find ARM Windows OpenSSL built-in yet.
# Corrected find script is included with Poco for older version of CMake.
if (WIN32 AND CMAKE_VERSION VERSION_LESS "4.1.0")
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ARM64")
message(STATUS "OpenSSL: Importing custom FindOpenSSL with updates for ARM64 Windows.")
cmake_minimum_required(VERSION 3.29.0)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/openssl)
endif()
endif()
# Resolve zlib before find_package(OpenSSL ...): in static builds FindOpenSSL
# transitively imports ZLIB::ZLIB non-globally at this scope, which would then
# block dependencies/zlib from promoting it to IMPORTED_GLOBAL. The other dep
# subdirs are feature-gated on ENABLE_XML / ENABLE_DATA_SQLITE / ENABLE_PDF
# and stay at their original post-cascade position.
#
# POCO_UNBUNDLED / POCO_SQLITE_UNBUNDLED are declared here because
# dependencies/zlib reads them. ENABLE_TRACE / ENABLE_FASTLOGGER and
# DefinePlatformSpecific are pulled up so their directory-scope compile
# definitions reach a bundled zlib object library.
option(POCO_UNBUNDLED
"Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF)
option(POCO_SQLITE_UNBUNDLED
"Set to OFF|ON (default is OFF) to control linking sqlite dependency as external" OFF)
if (POCO_UNBUNDLED)
set(POCO_SQLITE_UNBUNDLED ON CACHE BOOL "Enable Unbundled SQLite" FORCE)
endif()
option(ENABLE_TRACE "Enable stack tracing" OFF)
option(ENABLE_FASTLOGGER "Enable FastLogger (Quill-based high-performance logger)" ON)
# FastLogger uses Quill which only supports specific platforms.
# Auto-disable on unsupported OS or CPU architecture.
# Supported platforms are derived from quill source code:
# OS: ThreadUtilities.h (get_thread_id), BackendWorkerLock.h
# Arch: Rdtsc.h
set(_FASTLOGGER_SUPPORTED_OS FALSE)
set(_FASTLOGGER_SUPPORTED_ARCH FALSE)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|Linux|Darwin|FreeBSD|NetBSD|OpenBSD|DragonFly|Android)$")
set(_FASTLOGGER_SUPPORTED_OS TRUE)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^([xX]86_64|[aA][mM][dD]64|[xX]86|i[3-6]86|aarch64|[aA][rR][mM]64|[aA][rR][mM]|riscv|loongarch64|s390x)")
set(_FASTLOGGER_SUPPORTED_ARCH TRUE)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ppc64|powerpc64)")
set(_FASTLOGGER_SUPPORTED_ARCH TRUE)
endif()
if(NOT _FASTLOGGER_SUPPORTED_OS OR NOT _FASTLOGGER_SUPPORTED_ARCH OR EMSCRIPTEN)
if(ENABLE_FASTLOGGER)
message(STATUS "FastLogger disabled: unsupported platform (${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR})")
endif()
set(ENABLE_FASTLOGGER OFF CACHE BOOL "Enable FastLogger" FORCE)
endif()
include(DefinePlatformSpecific)
add_compile_definitions(POCO_CMAKE)
if (POCO_UNBUNDLED)
add_subdirectory(dependencies/zlib)
endif()
if (NOT POCO_MINIMAL_BUILD)
find_package(OpenSSL 1.1.1)
find_package(MySQL)
find_package(PostgreSQL)
find_package(ODBC)
find_package(APR)
find_package(APRUTIL)
find_package(Apache2)
if(OPENSSL_FOUND)
option(ENABLE_NETSSL "Enable NetSSL" ON)
option(ENABLE_CRYPTO "Enable Crypto" ON)
option(ENABLE_JWT "Enable JWT" ON)
else()
option(ENABLE_NETSSL "Enable NetSSL" OFF)
option(ENABLE_CRYPTO "Enable Crypto" OFF)
option(ENABLE_JWT "Enable JWT" OFF)
endif()
if(APR_FOUND AND APRUTIL_FOUND AND APACHE2_FOUND AND
EXISTS ${PROJECT_SOURCE_DIR}/ApacheConnector)
option(ENABLE_APACHECONNECTOR "Enable ApacheConnector" ON)
else()
option(ENABLE_APACHECONNECTOR "Enable ApacheConnector" OFF)
endif()
if(MYSQL_FOUND)
option(ENABLE_DATA_MYSQL "Enable Data MySQL or MariaDB" ON)
else()
option(ENABLE_DATA_MYSQL "Enable Data MySQL or MariaDB" OFF)
endif()
if(PostgreSQL_FOUND)
option(ENABLE_DATA_POSTGRESQL "Enable Data PosgreSQL" ON)
else()
option(ENABLE_DATA_POSTGRESQL "Enable Data PosgreSQL" OFF)
endif()
if(ODBC_FOUND)
option(ENABLE_DATA_ODBC "Enable Data ODBC" ON)
option(ENABLE_DATA_SQL_SERVER_BIG_STRINGS "Enable MS SQL Server big strings" ON)
else()
option(ENABLE_DATA_ODBC "Enable Data ODBC" OFF)
option(ENABLE_DATA_SQL_SERVER_BIG_STRINGS "Enable MS SQL Server big strings" OFF)
endif()
set(_enable_default ON)
else()
option(ENABLE_NETSSL "Enable NetSSL" OFF)
option(ENABLE_CRYPTO "Enable Crypto" OFF)
option(ENABLE_JWT "Enable JWT" OFF)
option(ENABLE_APACHECONNECTOR "Enable ApacheConnector" OFF)
option(ENABLE_DATA_MYSQL "Enable Data MySQL or MariaDB" OFF)
option(ENABLE_DATA_POSTGRESQL "Enable Data PosgreSQL" OFF)
option(ENABLE_DATA_ODBC "Enable Data ODBC" OFF)
option(ENABLE_DATA_SQL_SERVER_BIG_STRINGS "Enable MS SQL Server big strings" OFF)
set(_enable_default OFF)
endif()
# Foundation is always required; force it ON regardless of user setting
set(ENABLE_FOUNDATION ON CACHE BOOL "Enable Foundation (required)" FORCE)
# Allow enabling and disabling optional components
option(ENABLE_ENCODINGS "Enable Encodings" ${_enable_default})
option(ENABLE_XML "Enable XML" ${_enable_default})
option(ENABLE_JSON "Enable JSON" ${_enable_default})
option(ENABLE_DATA "Enable Data" ${_enable_default})
option(ENABLE_DATA_SQLITE "Enable Data SQlite" ${_enable_default})
option(ENABLE_MONGODB "Enable MongoDB" ${_enable_default})
option(ENABLE_REDIS "Enable Redis" ${_enable_default})
option(ENABLE_SSH "Enable SSH" OFF)
option(ENABLE_PROMETHEUS "Enable Prometheus" ${_enable_default})
option(ENABLE_UTIL "Enable Util" ${_enable_default})
option(ENABLE_NET "Enable Net" ${_enable_default})
option(ENABLE_ZIP "Enable Zip" ${_enable_default})
option(ENABLE_PAGECOMPILER "Enable PageCompiler" ${_enable_default})
option(ENABLE_PAGECOMPILER_FILE2PAGE "Enable File2Page" ${_enable_default})
option(ENABLE_ACTIVERECORD "Enable ActiveRecord" ${_enable_default})
option(ENABLE_ACTIVERECORD_COMPILER "Enable ActiveRecord Compiler" ${_enable_default})
if(WIN32)
option(ENABLE_NETSSL_WIN "Enable NetSSL Windows" OFF)
else()
set(ENABLE_NETSSL_WIN OFF CACHE BOOL "Enable NetSSL Windows (Windows only)" FORCE)
endif()
option(ENABLE_ENCODINGS_COMPILER "Enable Encodings Compiler" OFF)
option(ENABLE_DNSSD "Enable DNSSD" OFF)
option(ENABLE_DNSSD_DEFAULT "Enable DNSSD Default" OFF)
option(ENABLE_DNSSD_AVAHI "Enable DNSSD Avahi" OFF)
option(ENABLE_DNSSD_BONJOUR "Enable DNSSD Bonjour" OFF)
option(ENABLE_SEVENZIP "Enable SevenZip" OFF)
option(ENABLE_CPPPARSER "Enable C++ parser" OFF)
option(ENABLE_POCODOC "Enable Poco Documentation Generator" OFF)
option(ENABLE_PDF "Enable PDF" OFF)
if(POCO_ENABLE_CPP20)
option(ENABLE_MODULES "Build Poco.* C++ modules" OFF)
endif()
option(ENABLE_BENCHMARK
"Set to OFF|ON (default is OFF) to enable Benchmark application (requires Google Benchmark library)" OFF)
option(ENABLE_CPPUNIT
"Set to OFF|ON (default is OFF) to enable CppUnit library" OFF)
option(ENABLE_INSTALL_CPPUNIT
"Set to OFF|ON (default is OFF) to install CppUnit headers and libraries" OFF)
option(ENABLE_TESTS
"Set to OFF|ON (default is OFF) to control build of POCO tests" OFF)
option(ENABLE_TEST_DEPRECATED
"Set to OFF|ON (default is OFF) to enable build of tests for deprecated functionality" OFF)
option(POCO_DATA_NO_SQL_PARSER "Disable SQL parser" OFF)
option(ENABLE_COMPILER_WARNINGS
"Set to OFF|ON (default is OFF) to enable additional compiler warnings. Intended primarily for maintainers." OFF)
option(ENABLE_SAMPLES
"Set to OFF|ON (default is OFF) to control build of POCO samples" OFF)
option(ENABLE_FUZZING
"Set to OFF|ON (default is OFF) to control build of fuzzing targets for oss-fuzz (Clang compiler is required)" OFF)
option(POCO_SOO
"Set to OFF|ON (default is ON) to control small object optimization in Poco::Foundation" ON)
if(ENABLE_TESTS)
include(CTest)
enable_testing()
message(STATUS "Building with unit tests")
if(ENABLE_TEST_DEPRECATED)
add_compile_definitions(POCO_TEST_DEPRECATED)
endif()
else()
message(STATUS "Building without unit tests")
endif()
if(ENABLE_SAMPLES)
message(STATUS "Building with samples")
else()
message(STATUS "Building without samples")
endif()
if(ENABLE_FUZZING)
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(FATAL_ERROR "ENABLE_FUZZING flag requires using Clang compiler")
else()
message(STATUS "Building fuzzing test targets with engine $ENV{LIB_FUZZING_ENGINE}")
endif()
endif()
# Disable fork exec
option(POCO_NO_FORK_EXEC "Set to OFF|ON (default is OFF) to disable use of fork() and exec*() which are not allowed on some Apple platforms (iOS, watchOS, iPadOS, tvOS)." OFF)
if(POCO_NO_FORK_EXEC)
add_definitions(-DPOCO_NO_FORK_EXEC=1)
endif()
option(POCO_ENABLE_STD_MUTEX "Set to OFF|NO using mutex from standard library (default OFF)" OFF)
if (POCO_ENABLE_STD_MUTEX)
add_compile_definitions(POCO_ENABLE_STD_MUTEX)
endif ()
if(ENABLE_TRACE)
add_compile_definitions(POCO_ENABLE_TRACE)
endif()
# Collect the built libraries and include dirs, the will be used to create the PocoConfig.cmake file
set(Poco_COMPONENTS "")
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/OSP)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/OSP/cmake)
include (PocoProOspSetup)
endif()
# - resolve dependencies
if(ENABLE_SAMPLES)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
set(ENABLE_JSON ON CACHE BOOL "Enable JSON" FORCE)
set(ENABLE_XML ON CACHE BOOL "Enable XML" FORCE)
endif()
if(ENABLE_ENCODINGS_COMPILER)
set(ENABLE_NET ON CACHE BOOL "Enable Net" FORCE)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
endif()
if(ENABLE_APACHECONNECTOR)
set(ENABLE_NET ON CACHE BOOL "Enable Net" FORCE)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
endif()
if(ENABLE_PAGECOMPILER)
set(ENABLE_NET ON CACHE BOOL "Enable Net" FORCE)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
endif()
if(ENABLE_PAGECOMPILER_FILE2PAGE)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
endif()
if(ENABLE_ACTIVERECORD_COMPILER)
set(ENABLE_ACTIVERECORD ON CACHE BOOL "Enable ActiveRecord" FORCE)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
endif()
if(ENABLE_ACTIVERECORD)
set(ENABLE_DATA ON CACHE BOOL "Enable Data" FORCE)
set(ENABLE_XML ON CACHE BOOL "Enable XML" FORCE)
endif()
if(ENABLE_DATA_MYSQL OR ENABLE_DATA_ODBC OR ENABLE_DATA_POSTGRESQL)
set(ENABLE_DATA ON CACHE BOOL "Enable Data" FORCE)
endif()
if (ENABLE_DNSSD)
set(ENABLE_NET ON CACHE BOOL "Enable Net" FORCE)
endif()
if(ENABLE_JWT)
set(ENABLE_CRYPTO ON CACHE BOOL "Enable Crypto" FORCE)
set(ENABLE_JSON ON CACHE BOOL "Enable JSON" FORCE)
endif()
if(ENABLE_MONGODB OR ENABLE_REDIS OR ENABLE_PROMETHEUS)
set(ENABLE_NET ON CACHE BOOL "Enable Net" FORCE)
endif()
if(ENABLE_SSH)
find_package(libssh CONFIG)
if(NOT libssh_FOUND)
message(STATUS "libssh not found - disabling SSH")
set(ENABLE_SSH OFF CACHE BOOL "Enable SSH" FORCE)
endif()
endif()
if(ENABLE_NETSSL)
set(ENABLE_CRYPTO ON CACHE BOOL "Enable Crypto" FORCE)
set(ENABLE_NET ON CACHE BOOL "Enable Net" FORCE)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
endif()
if(ENABLE_NETSSL_WIN)
set(ENABLE_NET ON CACHE BOOL "Enable Net" FORCE)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
endif()
if(ENABLE_BENCHMARK)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
endif()
if(ENABLE_PDF)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
set(ENABLE_XML ON CACHE BOOL "Enable XML" FORCE)
endif()
if(ENABLE_POCODOC)
set(ENABLE_UTIL ON CACHE BOOL "Enable Util" FORCE)
set(ENABLE_XML ON CACHE BOOL "Enable XML" FORCE)
set(ENABLE_CPPPARSER ON CACHE BOOL "Enable C++ parser" FORCE)
set(ENABLE_DATA ON CACHE BOOL "Enable Data" FORCE)
set(ENABLE_DATA_SQLITE ON CACHE BOOL "Enable Data SQLite" FORCE)
endif()
if(ENABLE_INSTALL_CPPUNIT)
set(ENABLE_CPPUNIT ON CACHE BOOL "Enable CppUnit" FORCE)
endif()
if(ENABLE_TESTS)
set(ENABLE_CPPUNIT ON CACHE BOOL "Enable CppUnit" FORCE)
if (ENABLE_DATA OR ENABLE_ACTIVERECORD)
set(ENABLE_DATA_SQLITE ON CACHE BOOL "Enable Data SQlite" FORCE)
endif()
if(ENABLE_UTIL)
set(ENABLE_JSON ON CACHE BOOL "Enable JSON" FORCE)
set(ENABLE_XML ON CACHE BOOL "Enable XML" FORCE)
endif()
endif()
if(ENABLE_DATA_SQLITE)
set(ENABLE_DATA ON CACHE BOOL "Enable Data" FORCE)
endif()
# - find external dependencies
if(ENABLE_APACHECONNECTOR)
find_package(APR REQUIRED)
find_package(APRUTIL REQUIRED)
find_package(Apache2 REQUIRED)
endif()
if(ENABLE_CRYPTO OR ENABLE_NETSSL OR ENABLE_JWT)
find_package(OpenSSL 1.1.1 REQUIRED)
endif()
if(ENABLE_DATA_MYSQL)
find_package(MySQL REQUIRED)
endif()
if(ENABLE_DATA_POSTGRESQL)
find_package(PostgreSQL REQUIRED)
endif()
if(ENABLE_DATA_ODBC)
find_package(ODBC REQUIRED)
endif()
# Feature-gated dep subdirs must run after the enablement cascade so
# ENABLE_XML / ENABLE_DATA_SQLITE / ENABLE_PDF etc. are finalised. zlib may
# already have been added early; dependencies/CMakeLists.txt skips it in that
# case.
add_subdirectory(dependencies)
# Enable detailed compiler warnings for Poco code only (after dependencies to exclude them)
poco_enable_detailed_compiler_warnings()
if(ENABLE_FOUNDATION)
add_subdirectory(Foundation)
list(APPEND Poco_COMPONENTS "Foundation")
endif()
if(ENABLE_CPPUNIT)
add_subdirectory(CppUnit)
list(APPEND Poco_COMPONENTS "CppUnit")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Encodings AND ENABLE_ENCODINGS)
add_subdirectory(Encodings)
list(APPEND Poco_COMPONENTS "Encodings")
endif()
if(ENABLE_XML)
add_subdirectory(XML)
list(APPEND Poco_COMPONENTS "XML")
endif()
if(ENABLE_JSON)
add_subdirectory(JSON)
list(APPEND Poco_COMPONENTS "JSON")
endif()
if(ENABLE_UTIL)
add_subdirectory(Util)
list(APPEND Poco_COMPONENTS "Util")
endif()
if(ENABLE_NET)
add_subdirectory(Net)
list(APPEND Poco_COMPONENTS "Net")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/MongoDB AND ENABLE_MONGODB)
add_subdirectory(MongoDB)
list(APPEND Poco_COMPONENTS "MongoDB")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Redis AND ENABLE_REDIS)
add_subdirectory(Redis)
list(APPEND Poco_COMPONENTS "Redis")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/SSH AND ENABLE_SSH)
add_subdirectory(SSH)
list(APPEND Poco_COMPONENTS "SSH")
endif()
if(ENABLE_DNSSD)
add_subdirectory(DNSSD)
list(APPEND Poco_COMPONENTS "DNSSD")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Prometheus AND ENABLE_PROMETHEUS)
add_subdirectory(Prometheus)
list(APPEND Poco_COMPONENTS "Prometheus")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/PDF AND ENABLE_PDF)
add_subdirectory(PDF)
list(APPEND Poco_COMPONENTS "PDF")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/JWT AND ENABLE_JWT)
add_subdirectory(JWT)
list(APPEND Poco_COMPONENTS "JWT")
endif()
#NetSSL
if(WIN32 AND EXISTS ${PROJECT_SOURCE_DIR}/NetSSL_Win AND ENABLE_NETSSL_WIN)
add_subdirectory(NetSSL_Win)
list(APPEND Poco_COMPONENTS "NetSSL_Win")
endif(WIN32 AND EXISTS ${PROJECT_SOURCE_DIR}/NetSSL_Win AND ENABLE_NETSSL_WIN)
if(OPENSSL_FOUND)
if(EXISTS ${PROJECT_SOURCE_DIR}/NetSSL_OpenSSL AND ENABLE_NETSSL)
add_subdirectory(NetSSL_OpenSSL)
list(APPEND Poco_COMPONENTS "NetSSL_OpenSSL")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Crypto AND ENABLE_CRYPTO)
add_subdirectory(Crypto)
list(APPEND Poco_COMPONENTS "Crypto")
endif()
endif(OPENSSL_FOUND)
if(EXISTS ${PROJECT_SOURCE_DIR}/Data AND ENABLE_DATA)
if(POCO_DATA_NO_SQL_PARSER)
add_compile_definitions(POCO_DATA_NO_SQL_PARSER=1)
endif()
add_subdirectory(Data)
list(APPEND Poco_COMPONENTS "Data")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Data/SQLite AND ENABLE_DATA_SQLITE)
list(APPEND Poco_COMPONENTS "Data/SQLite")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Data/MySQL AND ENABLE_DATA_MYSQL)
list(APPEND Poco_COMPONENTS "Data/MySQL")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Data/PostgreSQL AND ENABLE_DATA_POSTGRESQL)
list(APPEND Poco_COMPONENTS "Data/PostgreSQL")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Data/ODBC AND ENABLE_DATA_ODBC)
list(APPEND Poco_COMPONENTS "Data/ODBC")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/ActiveRecord AND ENABLE_ACTIVERECORD)
add_subdirectory(ActiveRecord)
list(APPEND Poco_COMPONENTS "ActiveRecord")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/ActiveRecord/Compiler AND ENABLE_ACTIVERECORD_COMPILER)
add_subdirectory(ActiveRecord/Compiler)
list(APPEND Poco_COMPONENTS "ActiveRecordCompiler")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/SevenZip AND ENABLE_SEVENZIP)
add_subdirectory(SevenZip)
list(APPEND Poco_COMPONENTS "SevenZip")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Zip AND ENABLE_ZIP)
add_subdirectory(Zip)
list(APPEND Poco_COMPONENTS "Zip")
endif()
if(APRUTIL_FOUND AND APACHE2_FOUND AND
EXISTS ${PROJECT_SOURCE_DIR}/ApacheConnector AND ENABLE_APACHECONNECTOR)
add_subdirectory(ApacheConnector)
list(APPEND Poco_COMPONENTS "ApacheConnector")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/CppParser AND ENABLE_CPPPARSER)
add_subdirectory(CppParser)
list(APPEND Poco_COMPONENTS "CppParser")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/PocoDoc AND ENABLE_POCODOC)
add_subdirectory(PocoDoc)
list(APPEND Poco_COMPONENTS "PocoDoc")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/PageCompiler AND ENABLE_PAGECOMPILER)
add_subdirectory(PageCompiler)
list(APPEND Poco_COMPONENTS "PageCompiler")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/PageCompiler/File2Page AND ENABLE_PAGECOMPILER_FILE2PAGE)
add_subdirectory(PageCompiler/File2Page)
list(APPEND Poco_COMPONENTS "File2Page")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/Encodings/Compiler AND ENABLE_ENCODINGS_COMPILER)
add_subdirectory(Encodings/Compiler)
list(APPEND Poco_COMPONENTS "EncodingsCompiler")
endif()
if(ENABLE_MODULES AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
add_subdirectory(modules)
list(APPEND Poco_COMPONENTS "C++ modules")
endif()
#############################################################
# Benchmark application (optional, requires Google Benchmark)
if(ENABLE_BENCHMARK)
find_package(benchmark QUIET)
if(benchmark_FOUND)
message(STATUS "Google Benchmark found - building Benchmark application")
add_subdirectory(Benchmark)
list(APPEND Poco_COMPONENTS "Benchmark")
else()
message(STATUS "Google Benchmark not found - skipping Benchmark application")
message(STATUS "Install with: brew install google-benchmark (macOS) or apt install libbenchmark-dev (Linux)")
endif()
endif()
#############################################################
# Uninstall stuff see: http://www.vtk.org/Wiki/CMake_FAQ
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall-poco
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)
#############################################################
# Enable packaging
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
include(InstallRequiredSystemLibraries)
endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Poco Libraries")
set(CPACK_PACKAGE_VENDOR "Applied Informatics Software Engineering GmbH")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr/local")
include(CPack)
#############################################################
# cmake config files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# Set config script install location in a location that find_package() will
# look for, which is different on MS Windows than for UNIX
# Note: also set in POCO_GENERATE_PACKAGE macro in cmake/PocoMacros.cmake
if(WIN32)
set(PocoConfigPackageLocation "cmake")
else()
set(PocoConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
endif()
configure_file(cmake/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" @ONLY)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION
"${PocoConfigPackageLocation}"
COMPONENT
Devel
)
message(STATUS " * CMake '${CMAKE_VERSION}' successfully configured '${PROJECT_NAME}'")
message(STATUS " * ${PROJECT_NAME} package version: '${PROJECT_VERSION}'")
# -- Dependency status summary --
# Report which third-party libraries are bundled (internal) vs system (external).
# Always present: zlib, pcre2, utf8proc.
# Feature-gated: expat (XML), sqlite (Data/SQLite), libpng (PDF).
# Printed after the enablement cascade and find_package() calls above so the
# status reflects the final resolved state.
set(_opt_deps "")
if(ENABLE_XML)
string(APPEND _opt_deps ", expat")
endif()
if(ENABLE_DATA_SQLITE)
string(APPEND _opt_deps ", sqlite")
endif()
if(ENABLE_PDF)
string(APPEND _opt_deps ", libpng")
endif()
if(ENABLE_TRACE)
string(APPEND _opt_deps ", cpptrace")
endif()
if(POCO_UNBUNDLED)
# All bundled deps become external
message(STATUS "Using external zlib, pcre2, utf8proc${_opt_deps}")
elseif(POCO_SQLITE_UNBUNDLED)
# Only sqlite is external; rebuild the internal list without it
if(ENABLE_DATA_SQLITE)
message(STATUS "Using external sqlite")
endif()
set(_int_deps "")
if(ENABLE_XML)
string(APPEND _int_deps ", expat")
endif()
if(ENABLE_PDF)
string(APPEND _int_deps ", libpng")
endif()
message(STATUS "Using internal zlib, pcre2, utf8proc${_int_deps}")
else()
# Fully bundled
message(STATUS "Using internal zlib, pcre2, utf8proc${_opt_deps}")
endif()
# Always-external dependencies: these are never bundled, only report when enabled
set(_ext_deps "")
if(ENABLE_NETSSL OR ENABLE_CRYPTO OR ENABLE_JWT)
list(APPEND _ext_deps "OpenSSL")
endif()
if(ENABLE_DATA_MYSQL)
list(APPEND _ext_deps "MySQL")
endif()
if(ENABLE_DATA_POSTGRESQL)
list(APPEND _ext_deps "PostgreSQL")
endif()
if(ENABLE_DATA_ODBC)
list(APPEND _ext_deps "ODBC")
endif()
if(ENABLE_APACHECONNECTOR)
list(APPEND _ext_deps "APR" "Apache")
endif()
if(_ext_deps)
list(JOIN _ext_deps ", " _ext_deps_str)
message(STATUS "Using external ${_ext_deps_str}")
endif()
math(EXPR POCO_ARCH "${CMAKE_SIZEOF_VOID_P} * 8")
if(BUILD_SHARED_LIBS)
message(STATUS "Building dynamic libraries")
else()
message(STATUS "Building static libraries")
endif()
message(STATUS "[cmake] Installation target path: ${CMAKE_INSTALL_PREFIX}")
if(CMAKE_TOOLCHAIN_FILE)
message(STATUS "[cmake] Use toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
endif()
if(POCO_COMPILER_SELECTION)
message(STATUS "[cmake] POCO compiler select: ${POCO_COMPILER_SELECTION}")
endif()
message(STATUS "[cmake] C compiler: ${CMAKE_C_COMPILER}")
message(STATUS "[cmake] C++ compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "[cmake] C++ compiler ID: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "[cmake] C++ compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
if (ENABLE_MODULES)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
message(STATUS "Building Poco.* C++ modules")
else()
message(WARNING "Skipping Poco.* C++ modules (requires CMake 3.28+, found ${CMAKE_VERSION})")
endif()
endif()
message(STATUS "[cmake] Build for OS type: ${CMAKE_SYSTEM_NAME}")
message(STATUS "[cmake] Build for OS version: ${CMAKE_SYSTEM_VERSION}")
message(STATUS "[cmake] Build for CPU type: ${CMAKE_SYSTEM_PROCESSOR} (${POCO_ARCH}-bit)")
message(STATUS "[cmake] Generator: ${CMAKE_GENERATOR}")
message(STATUS "[cmake] Generator platorm: ${CMAKE_GENERATOR_PLATFORM}")
message(STATUS "[cmake] Build type: ${CMAKE_BUILD_TYPE}")
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
message(STATUS "[cmake] Build with C++ flags: ${CMAKE_CXX_FLAGS_${BUILD_TYPE}} ${CMAKE_CXX_FLAGS}")
message(STATUS "[cmake] Build with C flags: ${CMAKE_C_FLAGS_${BUILD_TYPE}} ${CMAKE_C_FLAGS}")
message(STATUS "[cmake] C++ symbol visibility: ${CMAKE_CXX_VISIBILITY_PRESET}")
foreach(component ${Poco_COMPONENTS})
message(STATUS "Building: ${component}")
endforeach()
# Uniform feature status summary. Every feature is printed as
# Feature: <name> <enabled|disabled>
# so the state of each option is explicit regardless of its default.
# Features are phrased in the positive form; options that carry a
# negated name (POCO_NO_*, POCO_DATA_NO_*) are inverted before printing.
function(poco_feature_status name value)
if(value)
message(STATUS "Feature: ${name} enabled")
else()
message(STATUS "Feature: ${name} disabled")
endif()
endfunction()
if(POCO_DATA_NO_SQL_PARSER)
set(_poco_data_sql_parser OFF)
else()
set(_poco_data_sql_parser ON)
endif()
if(POCO_NO_FORK_EXEC)
set(_poco_fork_exec OFF)
else()
set(_poco_fork_exec ON)
endif()
poco_feature_status("minimal build" ${POCO_MINIMAL_BUILD})
poco_feature_status("small object optimization" ${POCO_SOO})
poco_feature_status("stack tracing" ${ENABLE_TRACE})
poco_feature_status("FastLogger" ${ENABLE_FASTLOGGER})
poco_feature_status("Data SQL parser" ${_poco_data_sql_parser})
poco_feature_status("Process uses fork()/exec*()" ${_poco_fork_exec})
poco_feature_status("Poco::Mutex on std::mutex" ${POCO_ENABLE_STD_MUTEX})
poco_feature_status("compiler warnings" ${ENABLE_COMPILER_WARNINGS})
poco_feature_status("deprecated tests" ${ENABLE_TEST_DEPRECATED})
poco_feature_status("CppUnit build" ${ENABLE_CPPUNIT})
poco_feature_status("CppUnit install" ${ENABLE_INSTALL_CPPUNIT})
poco_feature_status("Encodings Compiler" ${ENABLE_ENCODINGS_COMPILER})