-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
1817 lines (1530 loc) · 59.8 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
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
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
#
#
cmake_minimum_required(VERSION 3.0) # setting this is required
project(cxproc) # this sets the project name
# https://stackoverflow.com/questions/24460486/cmake-build-type-is-not-being-used-in-cmakelists-txt
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Profile" CACHE STRING "" FORCE)
#set(CMAKE_BUILD_TYPE "Debug")
include (CTest)
# for profiling s. https://stackoverflow.com/questions/26491948/how-to-use-gprof-with-cmake
# cmake -DCMAKE_CXX_FLAGS=-pg -DCMAKE_EXE_LINKER_FLAGS=-pg -DCMAKE_SHARED_LINKER_FLAGS=-pg ..
# gprof bin/cxproc | ../build/gprof2dot.py | dot -Tpng -o gprof.png
# or see test/main.sh and https://github.com/jrfonseca/gprof2dot
# http://gernotklingler.com/blog/gprof-valgrind-gperftools-evaluation-tools-application-level-cpu-profiling-linux/
# https://cmake.org/Wiki/CMake/Testing_With_CTest#Simple_Testing
#enable_testing()
# s. https://cmake.org/Wiki/CMake_Useful_Variables
# CMAKE_POLICY(SET CMP0026 OLD)
# SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
SET(CMAKE_VERBOSE_MAKEFILE ON)
# http://www.vtk.org/Wiki/CMake:Eclipse_UNIX_Tutorial
# http://stackoverflow.com/questions/9453851/how-to-configure-eclipse-cdt-for-cmake
#FIND_PACKAGE(EclipseCDT4)
# (shell-command "(cmake --graphviz=cxproc.dot --build x86_64-gnu-linux-debug/ && dot -T png -o cxproc.png cxproc.dot.cxproc)")
FIND_PACKAGE(PkgConfig)
FIND_PATH(CXPROC_SRC_DIR
NAME cxproc.c
PATHS "src")
FIND_PATH(CXPROC_SRCLIB_DIR
NAME cgi-util
PATHS "third-party")
SET(CXPROC_PREFIX "${PROJECT_BINARY_DIR}/.." CACHE PATH "Prefix")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/third-party" "${PROJECT_SOURCE_DIR}/third-party/option" "${CXPROC_SRC_DIR}" "${CXPROC_SRC_DIR}/option" "${CXPROC_PREFIX}/include")
# working directory for tests
SET(CXPROC_TEST_DIR "${PROJECT_SOURCE_DIR}/test")
SET(CXPROC_TEMP_DIR "${CXPROC_PREFIX}/tmp")
# https://www.mattkeeter.com/blog/2018-01-06-versioning/
execute_process(COMMAND git describe --tags --long
OUTPUT_VARIABLE GIT_TAG
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
string(STRIP "${GIT_TAG}" GIT_TAG)
execute_process(COMMAND git branch --show-current
OUTPUT_VARIABLE GIT_BRANCH
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
set(PROJECT_VERSION_MAJOR "1")
set(PROJECT_VERSION_MINOR "3")
set(PROJECT_VERSION_PATCH "2")
# https://vicrucann.github.io/tutorials/quick-cmake-doxygen/
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
option(CXPROC_DOC "Build documentation" OFF)
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
if (CXPROC_DOC)
# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND DOXYGEN_NAME=${CMAKE_PROJECT_NAME} DOXYGEN_OUTPUT=${PROJECT_BINARY_DIR}/.. ${DOXYGEN_EXECUTABLE} ${PROJECT_SOURCE_DIR}/misc/Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
endif ()
# Configuration checks
INCLUDE(CheckIncludeFile)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckTypeSize)
CHECK_INCLUDE_FILE(assert.h HAVE_ASSERT_H)
CHECK_INCLUDE_FILE(ctype.h HAVE_CTYPE_H)
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
CHECK_INCLUDE_FILE(errno.h HAVE_ERRNO_H)
CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE(limits.h HAVE_LIMITS_H)
CHECK_INCLUDE_FILE(math.h HAVE_MATH_H)
CHECK_INCLUDE_FILE(stdarg.h HAVE_stdarg_H)
CHECK_INCLUDE_FILE(stddef.h HAVE_stddef_H)
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
CHECK_INCLUDE_FILE(stdio.h HAVE_STDIO_H)
CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H)
CHECK_INCLUDE_FILE(string.h HAVE_STRING_H)
CHECK_INCLUDE_FILE(sys/dir.h HAVE_SYS_DIR_H)
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE(time.h HAVE_TIME_H)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
IF(MSVC)
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
ELSE(MSVC)
ENDIF(MSVC)
SET(FILEX_HEADERS
${CXPROC_SRC_DIR}/version.h
# ${CXPROC_SRC_DIR}/git_revision.h
# ${CXPROC_SRC_DIR}/git_info.h
${CXPROC_SRC_DIR}/basics.h
${CXPROC_SRC_DIR}/dom.h
${CXPROC_SRC_DIR}/res_node/res_node.h
${CXPROC_SRC_DIR}/res_node/res_node_list.h
${CXPROC_SRC_DIR}/res_node/res_node_io.h
${CXPROC_SRC_DIR}/res_node/res_node_ops.h
${CXPROC_SRC_DIR}/res_node/res_path.h
${CXPROC_SRC_DIR}/res_node/res_mime.h
${CXPROC_SRC_DIR}/plain_text.h
${CXPROC_SRC_DIR}/option/pie/calendar_element.h
${CXPROC_SRC_DIR}/utils.h
)
SET(FILEX_SOURCES
${CXPROC_SRC_DIR}/dom.c
${CXPROC_SRC_DIR}/res_node/res_node.c
${CXPROC_SRC_DIR}/res_node/res_node_list.c
${CXPROC_SRC_DIR}/res_node/res_node_properties.c
${CXPROC_SRC_DIR}/res_node/res_node_io.c
${CXPROC_SRC_DIR}/res_node/res_node_ops.c
${CXPROC_SRC_DIR}/res_node/res_path.c
${CXPROC_SRC_DIR}/res_node/res_mime.c
${CXPROC_SRC_DIR}/plain_text.c
${CXPROC_SRC_DIR}/option/pie/calendar_element.c
${CXPROC_SRC_DIR}/utils.c
)
SET(CXPROC_HEADERS
${CXPROC_SRC_DIR}/version.h
# ${CXPROC_SRC_DIR}/git_revision.h
# ${CXPROC_SRC_DIR}/git_info.h
${CXPROC_SRC_DIR}/basics.h
${CXPROC_SRC_DIR}/cxp/cxp_dtd.h
${CXPROC_SRC_DIR}/cxp/cxp_context_enc.h
${CXPROC_SRC_DIR}/cxp/cxp_context.h
${CXPROC_SRC_DIR}/cxp/cxp_context_cli.h
${CXPROC_SRC_DIR}/cxp/cxp_context_cache.h
${CXPROC_SRC_DIR}/cxp/cxp_subst.h
${CXPROC_SRC_DIR}/cxp/cxp_dir.h
${CXPROC_SRC_DIR}/dom.h
${CXPROC_SRC_DIR}/res_node/res_node.h
${CXPROC_SRC_DIR}/res_node/res_node_list.h
${CXPROC_SRC_DIR}/res_node/res_node_io.h
${CXPROC_SRC_DIR}/res_node/res_node_ops.h
${CXPROC_SRC_DIR}/res_node/res_path.h
${CXPROC_SRC_DIR}/res_node/res_mime.h
${CXPROC_SRC_DIR}/plain_text.h
${CXPROC_SRC_DIR}/option/pie/calendar_element.h
${CXPROC_SRC_DIR}/utils.h
)
SET(CXPROC_SOURCES
${CXPROC_SRC_DIR}/cxp/cxp_context.c
${CXPROC_SRC_DIR}/cxp/cxp_context_cli.c
${CXPROC_SRC_DIR}/cxp/cxp_context_cache.c
${CXPROC_SRC_DIR}/cxp/cxp_context_enc.c
${CXPROC_SRC_DIR}/cxp/cxp_subst.c
${CXPROC_SRC_DIR}/cxp/cxp.c
${CXPROC_SRC_DIR}/cxp/cxp_dir.c
${CXPROC_SRC_DIR}/dom.c
${CXPROC_SRC_DIR}/res_node/res_node.c
${CXPROC_SRC_DIR}/res_node/res_node_list.c
${CXPROC_SRC_DIR}/res_node/res_node_properties.c
${CXPROC_SRC_DIR}/res_node/res_node_io.c
${CXPROC_SRC_DIR}/res_node/res_node_ops.c
${CXPROC_SRC_DIR}/res_node/res_path.c
${CXPROC_SRC_DIR}/res_node/res_mime.c
${CXPROC_SRC_DIR}/plain_text.c
${CXPROC_SRC_DIR}/option/pie/calendar_element.c
${CXPROC_SRC_DIR}/utils.c
)
###############################################################################
## target definitions #########################################################
###############################################################################
IF(MSVC)
SET(FILEX_SOURCES ${FILEX_SOURCES} ${CXPROC_SRC_DIR}/version.rc)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/version.rc)
ENDIF(MSVC)
################################################################################
#
# pthread
#
#FIND_PACKAGE( Threads )
#IF(CMAKE_USE_PTHREADS_INIT)
# MESSAGE(STATUS "Found optional libpthtread: ${CMAKE_THREAD_LIBS_INIT}")
# OPTION (CXPROC_PTHREAD "Enable support for linking cxproc with libpthread." OFF)
#ELSE ()
# OPTION (CXPROC_THREAD "Enable support native threads." OFF)
#ENDIF ()
#MARK_AS_ADVANCED(CXPROC_THREAD)
IF(CXPROC_PTHREAD)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/cxp/cxp_threadp.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/cxp/cxp_threadp.c)
add_definitions(-DHAVE_LIBPTHREAD)
ELSEIF (CXPROC_THREAD)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/cxp/cxp_threadp.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/cxp/cxp_threadp.c)
add_definitions(-DWITH_THREAD)
ENDIF (CXPROC_PTHREAD)
################################################################################
#
# either local LibArchive or system LibArchive
#
find_path(LibArchive_INCLUDE_DIR NAMES archive.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (LibArchive_INCLUDE_DIR)
find_library(LibArchive_LIBRARIES NAMES libarchive archive archive_static
HINTS "${CXPROC_PREFIX}/lib"
)
IF (LibArchive_LIBRARIES)
SET(LibArchive_FOUND ON)
ELSE(LibArchive_LIBRARIES)
FIND_PACKAGE( LibArchive )
ENDIF (LibArchive_LIBRARIES)
ELSE(LibArchive_INCLUDE_DIR)
FIND_PACKAGE( LibArchive )
ENDIF (LibArchive_INCLUDE_DIR)
IF (LibArchive_FOUND)
MESSAGE(STATUS "Found optional LibArchive: ${LibArchive_LIBRARIES}")
OPTION(CXPROC_ARCHIVE "Enable support for linking cxproc with libarchive." OFF)
ENDIF (LibArchive_FOUND)
IF (CXPROC_ARCHIVE)
INCLUDE_DIRECTORIES(${LibArchive_INCLUDE_DIR})
SET(FILEX_HEADERS ${FILEX_HEADERS} ${CXPROC_SRC_DIR}/option/archive/archive.h)
SET(FILEX_SOURCES ${FILEX_SOURCES} ${CXPROC_SRC_DIR}/option/archive/archive.c)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/option/archive/cxp_archive.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/option/archive/cxp_archive.c ${CXPROC_SRC_DIR}/option/archive/archive.c)
add_definitions(-DHAVE_LIBARCHIVE)
IF (${LibArchive_LIBRARIES} MATCHES ".+static\\.lib$" OR ${LibArchive_LIBRARIES} MATCHES ".+\\.a$")
add_definitions(-DLIBARCHIVE_STATIC)
ENDIF ()
ENDIF (CXPROC_ARCHIVE)
################################################################################
#
# SQLite3 library
#
find_path(SQLITE3_INCLUDE_DIR NAMES sqlite3.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (SQLITE3_INCLUDE_DIR)
IF (EXISTS "${SQLITE3_INCLUDE_DIR}/sqlite3.c")
SET(SQLITE3_SOURCE_FILE "${SQLITE3_INCLUDE_DIR}/sqlite3.c")
SET(SQLITE3_FOUND ON)
ELSE()
find_library(SQLITE3_LIBRARIES NAMES libsqlite3 sqlite3
HINTS "${CXPROC_PREFIX}/lib"
)
IF (SQLITE3_LIBRARIES)
SET(SQLITE3_FOUND ON)
ELSE(SQLITE3_LIBRARIES)
FIND_PACKAGE( SQLite3 )
ENDIF (SQLITE3_LIBRARIES)
ENDIF()
ELSE(SQLITE3_INCLUDE_DIR)
FIND_PACKAGE( SQLITE3 )
ENDIF (SQLITE3_INCLUDE_DIR)
IF (SQLITE3_FOUND)
MESSAGE(STATUS "Found optional sqlite3: ${SQLITE3_SOURCE_FILE} ${SQLITE3_LIBRARIES}")
OPTION (CXPROC_SQLITE3 "Enable support for linking cxproc with sqlite3." OFF)
ENDIF (SQLITE3_FOUND)
IF (CXPROC_SQLITE3)
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/option/database/database.h ${CXPROC_SRC_DIR}/option/database/cxp_database.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/option/database/database.c ${CXPROC_SRC_DIR}/option/database/cxp_database.c)
SET(FILEX_HEADERS ${FILEX_HEADERS} ${CXPROC_SRC_DIR}/option/database/database.h)
SET(FILEX_SOURCES ${FILEX_SOURCES} ${CXPROC_SRC_DIR}/option/database/database.c)
add_definitions(-DHAVE_LIBSQLITE3)
IF (SQLITE3_SOURCE_FILE)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${SQLITE3_SOURCE_FILE})
SET(FILEX_SOURCES ${FILEX_SOURCES} ${SQLITE3_SOURCE_FILE})
add_definitions(-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION)
ENDIF ()
ENDIF (CXPROC_SQLITE3)
################################################################################
#
# either local libid3tag or system libid3tag
#
# code of libid3tag is not C++ compilable and memory management should be separated
#
#TODO: OPTION(CXPROC_LIBVORBIS "Include OGG/Vorbis code" OFF)
#SET(CXPROC_LIBVORBIS OFF)
find_path(LIBID3TAG_INCLUDE_DIR NAMES id3tag.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (LIBID3TAG_INCLUDE_DIR)
find_library(LIBID3TAG_LIBRARIES NAMES libid3tag.a id3tag libid3tag.lib
HINTS "${CXPROC_PREFIX}/lib"
)
IF (LIBID3TAG_LIBRARIES)
SET(LIBID3TAG_FOUND ON)
ELSE (LIBID3TAG_LIBRARIES)
# FIND_PACKAGE( LIBID3TAG )
ENDIF (LIBID3TAG_LIBRARIES)
ENDIF (LIBID3TAG_INCLUDE_DIR)
IF (LIBID3TAG_FOUND)
MESSAGE(STATUS "Found optional LIBID3TAG: ${LIBID3TAG_LIBRARIES}")
OPTION (CXPROC_LIBID3TAG "Enable support for linking cxproc with libid3tag." OFF)
ENDIF (LIBID3TAG_FOUND)
IF (CXPROC_LIBID3TAG)
INCLUDE_DIRECTORIES(${LIBID3TAG_INCLUDE_DIR})
add_definitions(-DHAVE_LIBID3TAG)
ENDIF (CXPROC_LIBID3TAG)
IF (CXPROC_LIBID3TAG OR CXPROC_LIBVORBIS)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/option/audio/audio.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/option/audio/audio.c)
SET(FILEX_HEADERS ${FILEX_HEADERS} ${CXPROC_SRC_DIR}/option/audio/audio.h)
SET(FILEX_SOURCES ${FILEX_SOURCES} ${CXPROC_SRC_DIR}/option/audio/audio.c)
ENDIF ()
################################################################################
#
# JSON
#
OPTION(CXPROC_JSON "Include JSON code" OFF)
MARK_AS_ADVANCED(CXPROC_JSON)
IF (CXPROC_JSON)
add_definitions(-DHAVE_JSON)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/option/json/json.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/option/json/json.c)
ENDIF (CXPROC_JSON)
################################################################################
#
# local pcre2 (impact on PIE)
#
FIND_PATH(LIBPCRE2_INCLUDE_DIR NAME pcre2.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (LIBPCRE2_INCLUDE_DIR)
FIND_LIBRARY(LIBPCRE2_LIBRARIES NAMES pcre2-8 pcre2-8d libpcre2-8.a
HINTS "${CXPROC_PREFIX}/lib"
)
ELSE ()
FIND_LIBRARY(LIBPCRE2_LIBRARIES NAMES pcre2)
ENDIF (LIBPCRE2_INCLUDE_DIR)
IF (LIBPCRE2_LIBRARIES)
SET(LIBPCRE2_FOUND ON)
ENDIF ()
IF (LIBPCRE2_FOUND)
MESSAGE(STATUS "Found optional libpcre2: ${LIBPCRE2_LIBRARIES}")
OPTION(CXPROC_PCRE2 "Enable support for linking cxproc with libpcre2." ON)
OPTION(CXPROC_PIE "Include PIE code" ON)
ELSE (LIBPCRE2_FOUND)
SET(CXPROC_PCRE2 OFF)
ENDIF (LIBPCRE2_FOUND)
IF (CXPROC_PCRE2)
add_definitions(-DHAVE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8)
IF (${LIBPCRE2_LIBRARIES} MATCHES ".+static.*\\.lib$" OR ${LIBPCRE2_LIBRARIES} MATCHES ".+\\.a$")
#ADD_LIBRARY(pcre2-8 STATIC IMPORTED)
add_definitions(-DPCRE2_STATIC)
ENDIF ()
ELSE ()
ENDIF ()
################################################################################
#
# PIE
#
IF (CXPROC_PIE)
add_definitions(-DHAVE_PIE)
SET(CXPROC_HEADERS ${CXPROC_HEADERS}
${CXPROC_SRC_DIR}/option/pie/pie_calendar.h
${CXPROC_SRC_DIR}/option/pie/pie_element.h
${CXPROC_SRC_DIR}/option/pie/pie_text_tags.h
${CXPROC_SRC_DIR}/option/pie/pie_text_blocks.h
${CXPROC_SRC_DIR}/option/pie/pie_text.h ${CXPROC_SRC_DIR}/option/pie/pie_dtd.h
${CXPROC_SRC_DIR}/option/pie/pie_timezone.h
${CXPROC_SRCLIB_DIR}/option/sunriset/sunriset.h
${CXPROC_SRC_DIR}/option/ics/ics.h
${CXPROC_SRC_DIR}/option/vcf/vcf.h
)
SET(CXPROC_SOURCES ${CXPROC_SOURCES}
${CXPROC_SRC_DIR}/option/pie/pie_calendar.c
${CXPROC_SRC_DIR}/option/pie/pie_element.c
${CXPROC_SRC_DIR}/option/pie/pie_text_tags.c
${CXPROC_SRC_DIR}/option/pie/pie_text_blocks.c
${CXPROC_SRC_DIR}/option/pie/pie_text.c
${CXPROC_SRC_DIR}/option/pie/pie_timezone.c
${CXPROC_SRCLIB_DIR}/option/sunriset/sunriset.c
${CXPROC_SRC_DIR}/option/ics/ics.c
${CXPROC_SRC_DIR}/option/vcf/vcf.c
)
SET(FILEX_SOURCES ${FILEX_SOURCES}
${CXPROC_SRC_DIR}/option/pie/pie_element.h
${CXPROC_SRC_DIR}/option/pie/pie_text_tags.h
${CXPROC_SRC_DIR}/option/pie/pie_text_blocks.h
${CXPROC_SRC_DIR}/option/pie/pie_dtd.h
${CXPROC_SRC_DIR}/option/pie/pie_timezone.h
${CXPROC_SRC_DIR}/option/ics/ics.h
${CXPROC_SRC_DIR}/option/vcf/vcf.h
)
SET(FILEX_SOURCES ${FILEX_SOURCES}
${CXPROC_SRC_DIR}/option/pie/pie_element.c
${CXPROC_SRC_DIR}/option/pie/pie_text_tags.c
${CXPROC_SRC_DIR}/option/pie/pie_text_blocks.c
${CXPROC_SRC_DIR}/option/pie/pie_timezone.c
${CXPROC_SRC_DIR}/option/ics/ics.c
${CXPROC_SRC_DIR}/option/vcf/vcf.c
)
OPTION(CXPROC_MARKDOWN "Compile MARKDOWN code" ON)
ELSE ()
SET(CXPROC_MARKDOWN OFF)
ENDIF (CXPROC_PIE)
IF (CXPROC_MARKDOWN)
add_definitions(-DWITH_MARKDOWN)
ENDIF (CXPROC_MARKDOWN)
################################################################################
#
# PETRINET
#
OPTION(CXPROC_PETRINET "Include Petrinet code" ON)
IF (CXPROC_PETRINET)
add_definitions(-DHAVE_PETRINET)
SET(CXPROC_SOURCES ${CXPROC_SOURCES}
${CXPROC_SRC_DIR}/option/petrinet/petrinet.c ${CXPROC_SRC_DIR}/option/petrinet/petrinet.h
)
ENDIF (CXPROC_PETRINET)
################################################################################
#
# either local ZLIB or system ZLIB
#
find_path(ZLIB_INCLUDE_DIR NAMES zlib.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (ZLIB_INCLUDE_DIR)
find_library(ZLIB_LIBRARIES NAMES libz zlib zlibd zlibStatic
HINTS "${CXPROC_PREFIX}/lib"
)
IF (ZLIB_LIBRARIES)
SET(ZLIB_FOUND ON)
ELSE(ZLIB_LIBRARIES)
FIND_PACKAGE( ZLIB )
ENDIF (ZLIB_LIBRARIES)
ELSE(ZLIB_INCLUDE_DIR)
FIND_PACKAGE( ZLIB )
ENDIF (ZLIB_INCLUDE_DIR)
IF (ZLIB_FOUND)
MESSAGE(STATUS "Found zlib: ${ZLIB_LIBRARIES}")
SET(CXPROC_LIBZ ON)
ELSE (ZLIB_FOUND)
MESSAGE(FATAL_ERROR "zlib must be available (libxml2)")
ENDIF (ZLIB_FOUND)
IF (CXPROC_LIBZ)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CXPROC_SRCLIB_DIR}/minizip)
add_definitions(-DHAVE_ZLIB)
SET(FILEX_SOURCES ${FILEX_SOURCES}
${CXPROC_SRCLIB_DIR}/minizip/ioapi.c
${CXPROC_SRCLIB_DIR}/minizip/zip.c
${CXPROC_SRCLIB_DIR}/minizip/unzip.c
${CXPROC_SRCLIB_DIR}/xmlzipio/xmlzipio.c)
SET(FILEX_HEADERS ${FILEX_HEADERS}
${CXPROC_SRCLIB_DIR}/minizip/ioapi.h
${CXPROC_SRCLIB_DIR}/minizip/zip.h
${CXPROC_SRCLIB_DIR}/minizip/unzip.h
${CXPROC_SRCLIB_DIR}/xmlzipio/xmlzipio.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES}
${CXPROC_SRCLIB_DIR}/minizip/ioapi.c
${CXPROC_SRCLIB_DIR}/minizip/zip.c
${CXPROC_SRCLIB_DIR}/minizip/unzip.c
${CXPROC_SRCLIB_DIR}/xmlzipio/xmlzipio.c)
SET(CXPROC_HEADERS ${CXPROC_HEADERS}
${CXPROC_SRCLIB_DIR}/minizip/ioapi.h
${CXPROC_SRCLIB_DIR}/minizip/zip.h
${CXPROC_SRCLIB_DIR}/minizip/unzip.h
${CXPROC_SRCLIB_DIR}/xmlzipio/xmlzipio.h)
IF (${ZLIB_LIBRARIES} MATCHES ".+static.*\\.lib$" OR ${ZLIB_LIBRARIES} MATCHES ".+\\.a$")
add_definitions(-DZLIB_STATIC)
ENDIF ()
ENDIF (CXPROC_LIBZ)
################################################################################
#
# either local liblzma or system liblzma
#
find_path(LIBLZMA_INCLUDE_DIR NAMES lzma.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (LIBLZMA_INCLUDE_DIR)
find_library(LIBLZMA_LIBRARIES NAMES liblzma lzma lzmad lzma_static
HINTS "${CXPROC_PREFIX}/lib"
)
IF (LIBLZMA_LIBRARIES)
SET(LIBLZMA_FOUND ON)
ELSE(LIBLZMA_LIBRARIES)
FIND_PACKAGE( LibLZMA )
ENDIF (LIBLZMA_LIBRARIES)
ELSE(LIBLZMA_INCLUDE_DIR)
FIND_PACKAGE( LibLZMA )
ENDIF (LIBLZMA_INCLUDE_DIR)
IF (LIBLZMA_FOUND)
MESSAGE(STATUS "Found liblzma: ${LIBLZMA_LIBRARIES}")
SET(CXPROC_LZMA ON)
ELSE (LIBLZMA_FOUND)
MESSAGE(FATAL_ERROR "liblzma must be available (libxml2)")
ENDIF (LIBLZMA_FOUND)
################################################################################
#
# RP
#
#OPTION(CXPROC_RP "Include RP code" OFF)
IF (CXPROC_RP)
add_definitions(-DHAVE_RP)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/rp.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/rp.c)
ENDIF (CXPROC_RP)
################################################################################
#
# local duktape
#
FIND_PATH(DUKTAPE_INCLUDE_DIR NAME duktape.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (DUKTAPE_INCLUDE_DIR)
IF (EXISTS "${DUKTAPE_INCLUDE_DIR}/duktape.c")
SET(DUKTAPE_SOURCE_FILE "${DUKTAPE_INCLUDE_DIR}/duktape.c")
SET(DUKTAPE_FOUND ON)
ELSE()
FIND_LIBRARY(DUKTAPE_LIBRARIES NAMES duktape
HINTS "${CXPROC_PREFIX}/lib"
)
IF (DUKTAPE_LIBRARIES)
SET(DUKTAPE_FOUND ON)
ENDIF (DUKTAPE_LIBRARIES)
ENDIF()
ENDIF (DUKTAPE_INCLUDE_DIR)
IF (DUKTAPE_FOUND)
MESSAGE(STATUS "Found optional duktape: ${DUKTAPE_LIBRARIES}")
OPTION (CXPROC_DUKTAPE "Enable support for linking cxproc with duktape." OFF)
ENDIF (DUKTAPE_FOUND)
IF (CXPROC_DUKTAPE)
add_definitions(-DHAVE_JS)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/option/script/script.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/option/script/script.c)
IF (DUKTAPE_SOURCE_FILE)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${DUKTAPE_INCLUDE_DIR}/duktape.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${DUKTAPE_SOURCE_FILE})
ENDIF (DUKTAPE_SOURCE_FILE)
INCLUDE_DIRECTORIES(${DUKTAPE_INCLUDE_DIR})
ENDIF (CXPROC_DUKTAPE)
################################################################################
#
# either local libexif or system libexif
#
find_path(LIBEXIF_INCLUDE_DIR NAMES libexif/exif-data.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (LIBEXIF_INCLUDE_DIR)
find_library(LIBEXIF_LIBRARY NAMES libexif.a libexif
HINTS "${CXPROC_PREFIX}/lib"
)
IF (LIBEXIF_LIBRARY)
SET(LIBEXIF_FOUND ON)
ELSE ()
# FIND_PACKAGE( LIBEXIF )
SET(LIBEXIF_LIBRARY "")
ENDIF ()
ELSE (LIBEXIF_INCLUDE_DIR)
# FIND_PACKAGE( LIBEXIF )
ENDIF (LIBEXIF_INCLUDE_DIR)
IF (LIBEXIF_FOUND)
MESSAGE(STATUS "Found optional LIBEXIF: ${LIBEXIF_LIBRARY}")
OPTION (CXPROC_LIBEXIF "Enable support for linking cxproc with libexif." OFF)
ENDIF (LIBEXIF_FOUND)
IF (CXPROC_LIBEXIF)
INCLUDE_DIRECTORIES(${LIBEXIF_INCLUDE_DIR})
add_definitions(-DHAVE_LIBEXIF)
ENDIF (CXPROC_LIBEXIF)
IF (CXPROC_LIBEXIF)
SET(FILEX_HEADERS ${FILEX_HEADERS} ${CXPROC_SRC_DIR}/option/image/image_exif.h)
SET(FILEX_SOURCES ${FILEX_SOURCES} ${CXPROC_SRC_DIR}/option/image/image_exif.c)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/option/image/image_exif.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/option/image/image_exif.c)
ENDIF ()
################################################################################
#
# libmagick
#
#OPTION(CXPROC_LIBMAGICK "Include ImageMagick code" OFF)
SET(CXPROC_LIBMAGICK OFF)
IF (CXPROC_LIBMAGICK)
INCLUDE_DIRECTORIES(${LIBMAGICK_INCLUDE_DIR})
add_definitions(-DHAVE_LIBMAGICK)
ENDIF (CXPROC_LIBMAGICK)
IF (CXPROC_LIBMAGICK)
SET(CXPROC_HEADERS ${CXPROC_HEADERS} ${CXPROC_SRC_DIR}/option/image/image.h)
SET(CXPROC_SOURCES ${CXPROC_SOURCES} ${CXPROC_SRC_DIR}/option/image/image.c)
ENDIF ()
################################################################################
# The data is just added to the executable, because in some IDEs (QtCreator)
# files are invisible when they are not explicitly part of the project.
ADD_EXECUTABLE(filex
${CXPROC_SRC_DIR}/filex.c
${FILEX_SOURCES} ${FILEX_HEADERS})
ADD_EXECUTABLE(cxproc
${CXPROC_SRC_DIR}/cxproc.c
${CXPROC_SOURCES} ${CXPROC_HEADERS})
ADD_EXECUTABLE(cxproc-test
${CXPROC_SRC_DIR}/cxproc-test.c
${CXPROC_SOURCES} ${CXPROC_HEADERS})
target_compile_definitions(cxproc-test PUBLIC
TESTCODE
BUILDPREFIX="${CXPROC_PREFIX}/"
TESTPREFIX="${CXPROC_TEST_DIR}/"
TEMPPREFIX="${CXPROC_TEMP_DIR}/"
HTTPPREFIX="http://localhost:8189/")
ADD_EXECUTABLE(cxproc-cgi
${CXPROC_SRC_DIR}/cxproc-cgi.c
${CXPROC_SRC_DIR}/cxp/cxp_context_cgi.c ${CXPROC_SRC_DIR}/cxp/cxp_context_cgi.h
${CXPROC_SRCLIB_DIR}/cgi-util/cgi-util.c ${CXPROC_SRCLIB_DIR}/cgi-util/cgi-util.h
${CXPROC_SOURCES} ${CXPROC_HEADERS})
target_compile_definitions(cxproc-cgi
PUBLIC HAVE_CGI)
ADD_EXECUTABLE(test-cgi
${CXPROC_SRC_DIR}/test/test-cgi.c)
#IF (LIBMICROHTTPD_FOUND)
# ADD_EXECUTABLE(cxproc-httpd
# ${CXPROC_SRC_DIR}/cxproc-httpd.c
# ${CXPROC_SOURCES} ${CXPROC_HEADERS})
#
# target_compile_definitions(cxproc-httpd
# PUBLIC HAVE_HTTPD)
#ENDIF ()
# This copies all resource files in the build directory.
# We need this, because we want to work with paths relative to the executable.
#file(COPY ${data} DESTINATION resources)
###############################################################################
## dependencies ###############################################################
###############################################################################
################################################################################
#
# local libiconv
#
FIND_PATH(LIBICONV_INCLUDE_DIR NAME iconv.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (LIBICONV_INCLUDE_DIR)
IF (MSVC)
FIND_LIBRARY(LIBICONV_LIBRARY NAMES libiconv iconv
HINTS "${CXPROC_PREFIX}/lib"
)
FIND_LIBRARY(LIBCHARSET_LIBRARY NAMES libcharset charset
HINTS "${CXPROC_PREFIX}/lib"
)
IF (LIBICONV_LIBRARY AND LIBCHARSET_LIBRARY)
SET(LIBICONV_FOUND ON)
ELSE ()
# select interactively
ENDIF ()
ELSE ()
# no library file on Linux
SET(LIBICONV_FOUND ON)
ENDIF ()
ENDIF (LIBICONV_INCLUDE_DIR)
IF (LIBICONV_FOUND)
MESSAGE(STATUS "Found required libiconv: ${LIBICONV_LIBRARY} ${LIBCHARSET_LIBRARY}")
ELSE (LIBICONV_FOUND)
MESSAGE(FATAL_ERROR "libiconv must be available")
ENDIF (LIBICONV_FOUND)
add_definitions(-DICONV_CODE_UNIT_WIDTH=8)
################################################################################
#
# either local libxml2 or system libxml2
#
find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
HINTS "${CXPROC_PREFIX}/include/libxml2"
HINTS "${CXPROC_PREFIX}/include"
)
IF (LIBXML2_INCLUDE_DIR)
find_library(LIBXML2_LIBRARIES NAMES xml2 libxml2 libxml2.a libxml2_a
HINTS "${CXPROC_PREFIX}/lib"
)
IF (LIBXML2_LIBRARIES)
SET(LIBXML2_FOUND ON)
ELSE ()
FIND_PACKAGE( LibXml2 )
ENDIF ()
ELSE (LIBXML2_INCLUDE_DIR)
FIND_PACKAGE( LibXml2 )
ENDIF (LIBXML2_INCLUDE_DIR)
IF (LIBXML2_FOUND)
MESSAGE(STATUS "Found required libxml2: ${LIBXML2_LIBRARIES}")
ELSE (LIBXML2_FOUND)
MESSAGE(FATAL_ERROR "libxml2 must be available")
ENDIF (LIBXML2_FOUND)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
#add_definitions(-D${LIBXML2_DEFINITIONS})
IF (${LIBXML2_LIBRARIES} MATCHES ".+static.*\\.lib$" OR ${LIBXML2_LIBRARIES} MATCHES ".+\\.a$")
add_definitions(-DLIBXML_STATIC)
IF(MSVC)
target_link_libraries(filex ws2_32.lib)
target_link_libraries(cxproc ws2_32.lib)
target_link_libraries(cxproc-test ws2_32.lib)
target_link_libraries(cxproc-cgi ws2_32.lib)
# IF (LIBMICROHTTPD_FOUND)
# target_link_libraries(cxproc-httpd ws2_32.lib)
# ENDIF ()
ENDIF (MSVC)
ENDIF ()
################################################################################
#
# either local libxslt or system libxslt
#
find_path(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (LIBXSLT_INCLUDE_DIR)
find_library(LIBXSLT_LIBRARIES NAMES xslt libxslt libxslt.a libxslt_a
HINTS "${CXPROC_PREFIX}/lib"
)
IF (LIBXSLT_LIBRARIES)
SET(LIBXSLT_FOUND ON)
ELSE ()
FIND_PACKAGE( LibXslt )
ENDIF ()
ELSE (LIBXSLT_INCLUDE_DIR)
FIND_PACKAGE( LibXslt )
ENDIF (LIBXSLT_INCLUDE_DIR)
IF (LIBXSLT_FOUND)
MESSAGE(STATUS "Found required libxslt: ${LIBXSLT_LIBRARIES}")
ELSE (LIBXSLT_FOUND)
MESSAGE(FATAL_ERROR "libxslt must be available")
ENDIF (LIBXSLT_FOUND)
INCLUDE_DIRECTORIES(${LIBXSLT_INCLUDE_DIR})
#add_definitions(-D${LIBXSLT_DEFINITIONS})
IF (${LIBXSLT_LIBRARIES} MATCHES ".+static.*\\.lib$" OR ${LIBXSLT_LIBRARIES} MATCHES ".+\\.a$")
add_definitions(-DLIBXSLT_STATIC)
ENDIF ()
################################################################################
#
# configurable options
#
# Note: CMakeSetup displays these in alphabetical order, regardless of
# the order we use here.
#SET(CXPROC_BUFSIZE 4096 CACHE NUMBER "Default size for buffers.")
#OPTION(CXPROC_BUFSIZE "Default size for buffers." "4096")
SET(CXPROC_LEGACY ON CACHE BOOL "Compile code for handling of legacy issues")
MARK_AS_ADVANCED(CXPROC_LEGACY)
IF (CXPROC_LEGACY)
add_definitions(-DLEGACY)
ENDIF (CXPROC_LEGACY)
SET(CXPROC_EXPERIMENTAL OFF CACHE BOOL "Compile experimental code")
MARK_AS_ADVANCED(CXPROC_EXPERIMENTAL)
IF (CXPROC_EXPERIMENTAL)
add_definitions(-DEXPERIMENTAL)
ENDIF (CXPROC_EXPERIMENTAL)
SET(CXPROC_AJAX ON CACHE BOOL "Compile AJAX code")
IF (CXPROC_AJAX)
add_definitions(-DWITH_AJAX)
ENDIF (CXPROC_AJAX)
add_definitions(-DCXP_VER_FILE_VERSION_STR="${GIT_TAG}" -DCXP_VER_FILE_BRANCH_STR="${GIT_BRANCH}")
IF(MSVC)
SET(CMAKE_C_FLAGS "/MT /Gm- /MP /GS /GR- /Gd /analyze- /errorreport:prompt -D_REENTRANT -DDEF_MEM_LEVEL=8 -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN")
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG /Od /Z7 /W4")
SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -Ot -Oy-")
set(CMAKE_C_FLAGS_PROFILE "")
#set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
ELSE(MSVC)
set(CMAKE_C_FLAGS "-D_REENTRANT -DDEF_MEM_LEVEL=8 -D_DEFAULT_SOURCE")
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O0 -unused -Wall -Wpedantic -Wuninitialized")
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3")
set(CMAKE_C_FLAGS_PROFILE "-pg -DNDEBUG -O3")
#set(CMAKE_SHARED_LINKER_FLAGS "")
ENDIF (MSVC)
# for strict compiling only!
OPTION (CXPROC_CXX "Compile as C++ code" OFF)
MARK_AS_ADVANCED(CXPROC_CXX)
# assign c++ options to c
IF (CXPROC_CXX)
IF(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP")
ELSE(MSVC)
set(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER})
#set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fpermissive")
#set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
#set(CMAKE_C_FLAGS_PROFILE ${CMAKE_CXX_FLAGS_PROFILE})
ENDIF (MSVC)
ELSE(CXPROC_CXX)
IF(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TC")
ELSE(MSVC)
set(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
#set(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
#set(CMAKE_C_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
ENDIF (MSVC)
ENDIF (CXPROC_CXX)
################################################################################
#
# local pcre2
#
IF (CXPROC_PCRE2)
target_link_libraries(filex ${LIBPCRE2_LIBRARIES})
target_link_libraries(cxproc ${LIBPCRE2_LIBRARIES})
target_link_libraries(cxproc-test ${LIBPCRE2_LIBRARIES})
target_link_libraries(cxproc-cgi ${LIBPCRE2_LIBRARIES})
#IF (LIBMICROHTTPD_FOUND)
# target_link_libraries(cxproc-httpd ${LIBPCRE2_LIBRARIES})
#ENDIF ()
ENDIF ()
################################################################################
#
# local duktape
#
IF (CXPROC_DUKTAPE)
IF (DUKTAPE_SOURCE_FILE)
ELSE (DUKTAPE_SOURCE_FILE)
target_link_libraries(cxproc ${DUKTAPE_LIBRARIES})
target_link_libraries(cxproc-test ${DUKTAPE_LIBRARIES})
target_link_libraries(cxproc-cgi ${DUKTAPE_LIBRARIES})
#IF (LIBMICROHTTPD_FOUND)
# target_link_libraries(cxproc-httpd ${DUKTAPE_LIBRARIES})
#ENDIF ()
ENDIF ()
ENDIF (CXPROC_DUKTAPE)
################################################################################
#
# SQLite3 library
#
IF (CXPROC_SQLITE3)
IF (SQLITE3_SOURCE_FILE)
ELSE (SQLITE3_SOURCE_FILE)
target_link_libraries(filex ${SQLITE3_LIBRARIES})
target_link_libraries(cxproc ${SQLITE3_LIBRARIES})
target_link_libraries(cxproc-test ${SQLITE3_LIBRARIES})
target_link_libraries(cxproc-cgi ${SQLITE3_LIBRARIES})
#IF (LIBMICROHTTPD_FOUND)
# target_link_libraries(cxproc-httpd ${SQLITE3_LIBRARIES})
#ENDIF ()
ENDIF ()
ENDIF (CXPROC_SQLITE3)
################################################################################
#
# either local ZLIB or system ZLIB
#
IF (CXPROC_LIBZ)
target_link_libraries(filex ${ZLIB_LIBRARIES})
target_link_libraries(cxproc ${ZLIB_LIBRARIES})
target_link_libraries(cxproc-test ${ZLIB_LIBRARIES})
target_link_libraries(cxproc-cgi ${ZLIB_LIBRARIES})
#IF (LIBMICROHTTPD_FOUND)
# target_link_libraries(cxproc-httpd ${ZLIB_LIBRARIES})
#ENDIF ()
ENDIF (CXPROC_LIBZ)
################################################################################
#
# either local LIBBZ2 or system LIBBZ2
#
find_path(LIBBZ2_INCLUDE_DIR NAMES bzlib.h
HINTS "${CXPROC_PREFIX}/include"
)
IF (LIBBZ2_INCLUDE_DIR)
find_library(LIBBZ2_LIBRARIES NAMES libbz2 bz2 bz2d bzip2 libbz2 libbz2Static
HINTS "${CXPROC_PREFIX}/lib"
)
IF (LIBBZ2_LIBRARIES)
SET(LIBBZ2_FOUND ON)
ELSE(LIBBZ2_LIBRARIES)
FIND_PACKAGE( LIBBZ2 )
ENDIF (LIBBZ2_LIBRARIES)
ELSE(LIBBZ2_INCLUDE_DIR)
FIND_PACKAGE( BZip2 )
ENDIF (LIBBZ2_INCLUDE_DIR)
IF (LIBBZ2_FOUND)
MESSAGE(STATUS "Found optional LIBBZ2: ${LIBBZ2_LIBRARIES}")
OPTION (CXPROC_LIBBZ2 "Enable support for linking cxproc with libbz2." OFF)
ELSE(LIBBZ2_FOUND)
SET(CXPROC_LIBBZ2 OFF)
ENDIF (LIBBZ2_FOUND)