summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
blob: 405dd302b424fb966f7d8c2bc57346df337f1986 (plain)
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
#
# CMakeLists.txt to build the FLTK library using CMake (www.cmake.org)
#
# Copyright 1998-2022 by Bill Spitzak and others.
#
# This library is free software. Distribution and use rights are outlined in
# the file "COPYING" which should have been included with this file.  If this
# file is missing or damaged, see the license at:
#
#     https://www.fltk.org/COPYING.php
#
# Please see the following page on how to report bugs and issues:
#
#     https://www.fltk.org/bugs.php
#

set (CPPFILES
  Fl.cxx
  Fl_Adjuster.cxx
  Fl_Bitmap.cxx
  Fl_Browser.cxx
  Fl_Browser_.cxx
  Fl_Browser_load.cxx
  Fl_Box.cxx
  Fl_Button.cxx
  Fl_Chart.cxx
  Fl_Check_Browser.cxx
  Fl_Check_Button.cxx
  Fl_Choice.cxx
  Fl_Clock.cxx
  Fl_Color_Chooser.cxx
  Fl_Copy_Surface.cxx
  Fl_Counter.cxx
  Fl_Device.cxx
  Fl_Dial.cxx
  Fl_Double_Window.cxx
  Fl_File_Browser.cxx
  Fl_File_Chooser.cxx
  Fl_File_Chooser2.cxx
  Fl_File_Icon.cxx
  Fl_File_Input.cxx
  Fl_Graphics_Driver.cxx
  Fl_Group.cxx
  Fl_Help_View.cxx
  Fl_Image.cxx
  Fl_Image_Surface.cxx
  Fl_Input.cxx
  Fl_Input_.cxx
  Fl_Input_Choice.cxx
  Fl_Light_Button.cxx
  Fl_Menu.cxx
  Fl_Menu_.cxx
  Fl_Menu_Bar.cxx
  Fl_Menu_Button.cxx
  Fl_Menu_Window.cxx
  Fl_Menu_add.cxx
  Fl_Menu_global.cxx
  Fl_Message.cxx
  Fl_Multi_Label.cxx
  Fl_Native_File_Chooser.cxx
  Fl_Overlay_Window.cxx
  Fl_Pack.cxx
  Fl_Paged_Device.cxx
  Fl_Pixmap.cxx
  Fl_Positioner.cxx
  Fl_Preferences.cxx
  Fl_Printer.cxx
  Fl_Progress.cxx
  Fl_Repeat_Button.cxx
  Fl_Return_Button.cxx
  Fl_Roller.cxx
  Fl_Round_Button.cxx
  Fl_Screen_Driver.cxx
  Fl_Scroll.cxx
  Fl_Scrollbar.cxx
  Fl_Shared_Image.cxx
  Fl_Simple_Terminal.cxx
  Fl_Single_Window.cxx
  Fl_Slider.cxx
  Fl_Spinner.cxx
  Fl_String.cxx
  Fl_Sys_Menu_Bar.cxx
  Fl_System_Driver.cxx
  Fl_Table.cxx
  Fl_Table_Row.cxx
  Fl_Tabs.cxx
  Fl_Text_Buffer.cxx
  Fl_Text_Display.cxx
  Fl_Text_Editor.cxx
  Fl_Tile.cxx
  Fl_Tiled_Image.cxx
  Fl_Timeout.cxx
  Fl_Tooltip.cxx
  Fl_Tree.cxx
  Fl_Tree_Item_Array.cxx
  Fl_Tree_Item.cxx
  Fl_Tree_Prefs.cxx
  Fl_Valuator.cxx
  Fl_Value_Input.cxx
  Fl_Value_Output.cxx
  Fl_Value_Slider.cxx
  Fl_Widget.cxx
  Fl_Widget_Surface.cxx
  Fl_Window.cxx
  Fl_Window_Driver.cxx
  Fl_Window_fullscreen.cxx
  Fl_Window_hotspot.cxx
  Fl_Window_iconize.cxx
  Fl_Wizard.cxx
  Fl_XBM_Image.cxx
  Fl_XPM_Image.cxx
  Fl_abort.cxx
  Fl_add_idle.cxx
  Fl_arg.cxx
  Fl_compose.cxx
  Fl_display.cxx
  Fl_get_system_colors.cxx
  Fl_grab.cxx
  Fl_lock.cxx
  Fl_own_colormap.cxx
  Fl_visual.cxx
  filename_absolute.cxx
  filename_expand.cxx
  filename_ext.cxx
  filename_isdir.cxx
  filename_list.cxx
  filename_match.cxx
  filename_setext.cxx
  fl_arc.cxx
  fl_ask.cxx
  fl_boxtype.cxx
  fl_color.cxx
  fl_cursor.cxx
  fl_curve.cxx
  fl_diamond_box.cxx
  fl_draw.cxx
  fl_draw_pixmap.cxx
  fl_encoding_latin1.cxx
  fl_encoding_mac_roman.cxx
  fl_engraved_label.cxx
  fl_file_dir.cxx
  fl_font.cxx
  fl_gleam.cxx
  fl_gtk.cxx
  fl_labeltype.cxx
  fl_open_uri.cxx
  fl_oval_box.cxx
  fl_overlay.cxx
  fl_plastic.cxx
  fl_read_image.cxx
  fl_rect.cxx
  fl_round_box.cxx
  fl_rounded_box.cxx
  fl_set_font.cxx
  fl_scroll_area.cxx
  fl_shadow_box.cxx
  fl_shortcut.cxx
  fl_show_colormap.cxx
  fl_string_functions.cxx
  fl_symbols.cxx
  fl_utf8.cxx
  fl_vertex.cxx
  print_button.cxx
  screen_xywh.cxx
)

# find all header files in source directory <FL/...>
file (GLOB
  HEADER_FILES
  "../FL/*.[hH]"
)

# add generated header files in build directory
list (APPEND HEADER_FILES
  ${CMAKE_CURRENT_BINARY_DIR}/../FL/fl_config.h
  ${CMAKE_CURRENT_BINARY_DIR}/../config.h
)

set (GL_HEADER_FILES)  # FIXME: not (yet?) defined

if (FLTK_USE_X11 AND NOT OPTION_PRINT_SUPPORT)
  set (PSFILES
  )
else ()
  set (PSFILES
    drivers/PostScript/Fl_PostScript.cxx
    drivers/PostScript/Fl_PostScript_image.cxx
  )
endif (FLTK_USE_X11 AND NOT OPTION_PRINT_SUPPORT)

set (DRIVER_FILES)

if (FLTK_USE_X11)

  # X11 (including APPLE with X11)

  set (DRIVER_FILES
    drivers/Posix/Fl_Posix_Printer_Driver.cxx
    drivers/X11/Fl_X11_Screen_Driver.cxx
    drivers/X11/Fl_X11_Window_Driver.cxx
    drivers/Posix/Fl_Posix_System_Driver.cxx
    drivers/Unix/Fl_Unix_System_Driver.cxx
    drivers/X11/Fl_X11_System_Driver.cxx
    drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
    drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx
    drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx
    drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
    drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx
    drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
    drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
    drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
    drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
    drivers/X11/fl_X11_platform_init.cxx
    Fl_x.cxx
    fl_dnd_x.cxx
    Fl_Native_File_Chooser_FLTK.cxx
    Fl_Native_File_Chooser_GTK.cxx
    Fl_get_key.cxx
  )

  if (OPTION_USE_KDIALOG)
    set (DRIVER_FILES ${DRIVER_FILES} Fl_Native_File_Chooser_Kdialog.cxx)
  endif (OPTION_USE_KDIALOG)

  if (USE_XFT)
    set (DRIVER_FILES ${DRIVER_FILES}
      drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
    )
    if (USE_PANGO)
      set (DRIVER_FILES ${DRIVER_FILES} drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx)
    endif (USE_PANGO)
  else ()
    set (DRIVER_FILES ${DRIVER_FILES}
      drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
    )
  endif (USE_XFT)

  set (DRIVER_HEADER_FILES
    drivers/Posix/Fl_Posix_System_Driver.H
    drivers/X11/Fl_X11_Screen_Driver.H
    drivers/X11/Fl_X11_Window_Driver.H
    drivers/X11/Fl_X11_System_Driver.H
    drivers/Xlib/Fl_Font.H
    drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.H
    drivers/Xlib/Fl_Xlib_Image_Surface_Driver.H
    drivers/Unix/Fl_Unix_System_Driver.H
 )

elseif (OPTION_USE_WAYLAND)
  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}")
  set (DRIVER_FILES
    drivers/Posix/Fl_Posix_System_Driver.cxx
    drivers/Posix/Fl_Posix_Printer_Driver.cxx
    drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
    drivers/Wayland/Fl_Wayland_Window_Driver.cxx
    drivers/Wayland/Fl_Wayland_System_Driver.cxx
    drivers/Unix/Fl_Unix_System_Driver.cxx
    drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
    drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx
    drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx
    drivers/Wayland/fl_wayland_clipboard_dnd.cxx
    drivers/Wayland/fl_wayland_platform_init.cxx
    drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
    Fl_Native_File_Chooser_FLTK.cxx
    Fl_Native_File_Chooser_GTK.cxx
    Fl_Native_File_Chooser_Kdialog.cxx
  )
  set (DRIVER_HEADER_FILES
    drivers/Posix/Fl_Posix_System_Driver.H
    drivers/Wayland/Fl_Wayland_System_Driver.H
    drivers/Wayland/Fl_Wayland_Screen_Driver.H
    drivers/Wayland/Fl_Wayland_Window_Driver.H
    drivers/Wayland/Fl_Wayland_Graphics_Driver.H
    drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.H
    drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H
    drivers/Unix/Fl_Unix_System_Driver.H
  )

elseif (APPLE)

  # Apple Quartz

  set (DRIVER_FILES
    drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
    drivers/Quartz/Fl_Quartz_Graphics_Driver_color.cxx
    drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
    drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
    drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx
    drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
    drivers/Quartz/Fl_Quartz_Graphics_Driver_arci.cxx
    drivers/Quartz/Fl_Quartz_Graphics_Driver_line_style.cxx
    drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx
    drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
    drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
    drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
    drivers/Posix/Fl_Posix_System_Driver.cxx
    drivers/Darwin/Fl_Darwin_System_Driver.cxx
    Fl_get_key_mac.cxx
    drivers/Darwin/fl_macOS_platform_init.cxx
  )
  set (DRIVER_HEADER_FILES
    drivers/Posix/Fl_Posix_System_Driver.H
    drivers/Darwin/Fl_Darwin_System_Driver.H
    drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
    drivers/Cocoa/Fl_Cocoa_Window_Driver.H
    drivers/Cocoa/Fl_MacOS_Sys_Menu_Bar_Driver.H
    drivers/Quartz/Fl_Quartz_Graphics_Driver.H
    drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H
    drivers/Quartz/Fl_Font.H
    drivers/Quartz/Fl_Quartz_Image_Surface_Driver.H
  )

else ()

  # Windows (GDI)

  set (DRIVER_FILES
    drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
    drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
    drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
    drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx
    drivers/GDI/Fl_GDI_Graphics_Driver.cxx
    drivers/GDI/Fl_GDI_Graphics_Driver_arci.cxx
    drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx
    drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
    drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
    drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx
    drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx
    drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx
    drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
    drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx
    Fl_win32.cxx
    fl_dnd_win32.cxx
    Fl_Native_File_Chooser_WIN32.cxx
    Fl_get_key_win32.cxx
    drivers/WinAPI/fl_WinAPI_platform_init.cxx
  )
  set (DRIVER_HEADER_FILES
    drivers/WinAPI/Fl_WinAPI_System_Driver.H
    drivers/WinAPI/Fl_WinAPI_Screen_Driver.H
    drivers/WinAPI/Fl_WinAPI_Window_Driver.H
    drivers/GDI/Fl_GDI_Graphics_Driver.H
    drivers/GDI/Fl_Font.H
    drivers/GDI/Fl_GDI_Copy_Surface_Driver.H
    drivers/GDI/Fl_GDI_Image_Surface_Driver.H
  )

endif (FLTK_USE_X11)

source_group("Header Files" FILES ${HEADER_FILES})
source_group("Driver Source Files" FILES ${DRIVER_FILES})
source_group("Driver Header Files" FILES ${DRIVER_HEADER_FILES})

set (CPPFILES
  ${CPPFILES}
  ${DRIVER_FILES}
)

set (FORMS_FILES
  forms_compatibility.cxx
  forms_bitmap.cxx
  forms_free.cxx
  forms_fselect.cxx
  forms_pixmap.cxx
  forms_timer.cxx
)

set (GLCPPFILES
  Fl_Gl_Choice.cxx
  Fl_Gl_Device_Plugin.cxx
  Fl_Gl_Overlay.cxx
  Fl_Gl_Window.cxx
  freeglut_geometry.cxx
  freeglut_stroke_mono_roman.cxx
  freeglut_stroke_roman.cxx
  freeglut_teapot.cxx
  gl_draw.cxx
  gl_start.cxx
  glut_compatibility.cxx
  glut_font.cxx
)

set (GL_DRIVER_FILES
  drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
  # the following file doesn't contribute any code:
  # drivers/OpenGL/Fl_OpenGL_Graphics_Driver.cxx
  drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx
  drivers/OpenGL/Fl_OpenGL_Graphics_Driver_color.cxx
  drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx
  drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx
  drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
  drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
)
if (FLTK_USE_X11)
  set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/X11/Fl_X11_Gl_Window_Driver.cxx drivers/X11/fl_X11_gl_platform_init.cxx)
  set (GL_DRIVER_HEADER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.H)
elseif (OPTION_USE_WAYLAND)
  set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx drivers/Wayland/fl_wayland_gl_platform_init.cxx)
  set (GL_DRIVER_HEADER_FILES drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H)
elseif (APPLE)
  set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx drivers/Cocoa/fl_macOS_gl_platform_init.cxx)
  set (GL_DRIVER_HEADER_FILES drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H)
elseif (WIN32)
  set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx)
  set (GL_DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H)
endif (FLTK_USE_X11)

set (GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES}
  drivers/OpenGL/Fl_OpenGL_Display_Device.H
  drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H
)

source_group("Driver Header Files" FILES ${GL_DRIVER_HEADER_FILES})
source_group("Driver Source Files" FILES ${GL_DRIVER_FILES})

set (GLCPPFILES
  ${GLCPPFILES}
  ${GL_DRIVER_FILES}
)

set (IMGCPPFILES
  fl_images_core.cxx
  fl_write_png.cxx
  Fl_BMP_Image.cxx
  Fl_File_Icon2.cxx
  Fl_GIF_Image.cxx
  Fl_Help_Dialog.cxx
  Fl_JPEG_Image.cxx
  Fl_PNG_Image.cxx
  Fl_PNM_Image.cxx
  Fl_Image_Reader.cxx
  Fl_SVG_Image.cxx
  drivers/SVG/Fl_SVG_File_Surface.cxx
)

set (CFILES
  flstring.c
  numericsort.c
  vsnprintf.c
  xutf8/is_right2left.c
  xutf8/is_spacing.c
  xutf8/case.c
)

if (FLTK_USE_X11)
  list (APPEND CFILES
    xutf8/keysym2Ucs.c
    scandir_posix.c
  )
  if (NOT USE_XFT)
    list (APPEND CFILES
      xutf8/utf8Utils.c
      xutf8/utf8Wrap.c
      # xutf8/utf8Input.c  # not used
    )
  endif (NOT USE_XFT)
endif (FLTK_USE_X11)

if (OPTION_USE_WAYLAND)
  pkg_check_modules(DBUS dbus-1)
  include_directories(${DBUS_INCLUDE_DIRS})
  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR} -fPIC -D_GNU_SOURCE  -DHAS_DBUS")
  if (OPTION_USE_SYSTEM_LIBDECOR)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SYSTEM_LIBDECOR")
    get_filename_component(PATH_TO_SHARED_LIBS ${HAVE_LIB_PANGO} DIRECTORY)
    set (LIBDECOR_PLUGIN_DIR "\\\"${PATH_TO_SHARED_LIBS}/libdecor/plugins-1\\\" " )
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIBDECOR_PLUGIN_DIR=${LIBDECOR_PLUGIN_DIR} ")
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_SYSTEM_LIBDECOR")
  else()
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src   -DLIBDECOR_PLUGIN_API_VERSION=1 -DLIBDECOR_PLUGIN_DIR=\\\"/usr/local/lib/libdecor/plugins-1\\\" ")
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SYSTEM_LIBDECOR=0 -DHAVE_MEMFD_CREATE -DHAVE_MKOSTEMP -DHAVE_POSIX_FALLOCATE")
  endif (OPTION_USE_SYSTEM_LIBDECOR)

  if (GTK_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_GTK")
  endif (GTK_FOUND)

  list (APPEND CFILES
    xutf8/keysym2Ucs.c
    scandir_posix.c
    ../libdecor/src/cursor-settings.c
    ../libdecor/src/os-compatibility.c
    ../libdecor/build/fl_libdecor-plugins.c
    )
  if (NOT OPTION_USE_SYSTEM_LIBDECOR)
    list (APPEND CFILES
    ../libdecor/build/fl_libdecor.c
    ../libdecor/src/plugins/cairo/libdecor-cairo-blur.c
    )
  endif (NOT OPTION_USE_SYSTEM_LIBDECOR)
endif (OPTION_USE_WAYLAND)

if (WIN32)
  list (APPEND CFILES
    scandir_win32.c
  )
endif (WIN32)

if (APPLE AND (NOT OPTION_APPLE_X11))
  set (MMFILES
    Fl_cocoa.mm
    drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
    Fl_Native_File_Chooser_MAC.mm
    Fl_MacOS_Sys_Menu_Bar.mm
  )
else()
  set (MMFILES
  )
endif (APPLE AND (NOT OPTION_APPLE_X11))


#######################################################################

# prepare source files for shared and static FLTK libraries

set (SHARED_FILES ${CPPFILES} ${MMFILES} ${CFILES} ${PSFILES})
list (APPEND SHARED_FILES ${HEADER_FILES} ${DRIVER_HEADER_FILES})

set (STATIC_FILES ${SHARED_FILES})

if (WIN32)
  list (APPEND STATIC_FILES fl_call_main.c)
endif (WIN32)

add_definitions(-DFL_LIBRARY)

#######################################################################

# prepare optional libs for shared and static FLTK libraries

set (OPTIONAL_LIBS)

if (LIB_dl)
  list (APPEND OPTIONAL_LIBS ${LIB_dl})
endif (LIB_dl)

if (USE_THREADS)
  list (APPEND OPTIONAL_LIBS ${CMAKE_THREAD_LIBS_INIT})
endif (USE_THREADS)

if (FLTK_USE_X11)
  list (APPEND OPTIONAL_LIBS ${X11_LIBRARIES})
endif (FLTK_USE_X11)

if (WIN32)
  list (APPEND OPTIONAL_LIBS comctl32 ws2_32)
  if (USE_GDIPLUS)
    list (APPEND OPTIONAL_LIBS gdiplus)
  endif ()
endif (WIN32)

if (HAVE_XINERAMA)
  list (APPEND OPTIONAL_LIBS ${X11_Xinerama_LIB})
endif (HAVE_XINERAMA)

if (HAVE_XFIXES)
  list (APPEND OPTIONAL_LIBS ${X11_Xfixes_LIB})
endif (HAVE_XFIXES)

if (HAVE_XCURSOR)
  list (APPEND OPTIONAL_LIBS ${X11_Xcursor_LIB})
endif (HAVE_XCURSOR)

if (HAVE_XRENDER)
  list (APPEND OPTIONAL_LIBS ${X11_Xrender_LIB})
endif (HAVE_XRENDER)

if (USE_PANGO)
  ### FIXME ###  This needs to use the PKG_* variables directly
  list (APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGO} ${HAVE_LIB_PANGOXFT} ${HAVE_LIB_PANGOCAIRO})
  list (APPEND OPTIONAL_LIBS ${HAVE_LIB_CAIRO} ${HAVE_LIB_GOBJECT})
endif (USE_PANGO)

if (USE_XFT)
  list (APPEND OPTIONAL_LIBS ${X11_Xft_LIB})
  if (LIB_fontconfig)
    list (APPEND OPTIONAL_LIBS ${LIB_fontconfig})
  endif (LIB_fontconfig)
endif (USE_XFT)

if (OPTION_USE_WAYLAND)
  if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD")
    set(PROTOCOLS /usr/local/share/wayland-protocols)
  else ()
    set(PROTOCOLS /usr/share/wayland-protocols)
  endif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD")
  add_custom_command(
    OUTPUT xdg-shell-protocol.c xdg-shell-client-protocol.h
    COMMAND wayland-scanner private-code ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.c
    COMMAND wayland-scanner client-header ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml xdg-shell-client-protocol.h
    DEPENDS ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml
    VERBATIM
  )
  list (APPEND STATIC_FILES "xdg-shell-protocol.c")
  list (APPEND SHARED_FILES "xdg-shell-protocol.c")
  if (NOT OPTION_USE_SYSTEM_LIBDECOR)
    add_custom_command(
      OUTPUT xdg-decoration-protocol.c xdg-decoration-client-protocol.h
      COMMAND wayland-scanner private-code ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml xdg-decoration-protocol.c
      COMMAND wayland-scanner client-header ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml xdg-decoration-client-protocol.h
      DEPENDS ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
      VERBATIM
    )
    list (APPEND STATIC_FILES "xdg-decoration-protocol.c")
    list (APPEND SHARED_FILES "xdg-decoration-protocol.c")
  endif (NOT OPTION_USE_SYSTEM_LIBDECOR)
  add_custom_command(
    OUTPUT text-input-protocol.c text-input-client-protocol.h
    COMMAND wayland-scanner private-code ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml text-input-protocol.c
    COMMAND wayland-scanner client-header ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml text-input-client-protocol.h
    DEPENDS ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml
    VERBATIM
  )
  list (APPEND STATIC_FILES "text-input-protocol.c")
  list (APPEND SHARED_FILES "text-input-protocol.c")

  if (OPTION_USE_GL)
    list (APPEND OPTIONAL_LIBS "-lwayland-egl -lEGL")
  endif (OPTION_USE_GL)
  if (OPTION_USE_SYSTEM_LIBDECOR)
    list (APPEND OPTIONAL_LIBS "-ldecor-0")
  endif (OPTION_USE_SYSTEM_LIBDECOR)
  list (APPEND OPTIONAL_LIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldl -ldbus-1")
  if (GTK_FOUND)
    list (APPEND OPTIONAL_LIBS ${GTK_LDFLAGS} )
  endif (GTK_FOUND)
  if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux" AND NOT OPTION_BUILD_SHARED_LIBS)
    list (APPEND OPTIONAL_LIBS "-no-pie")
  endif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux" AND NOT OPTION_BUILD_SHARED_LIBS)
endif (OPTION_USE_WAYLAND)

#######################################################################

FL_ADD_LIBRARY (fltk STATIC "${STATIC_FILES}")
target_link_libraries (fltk ${OPTIONAL_LIBS})

#######################################################################

FL_ADD_LIBRARY (fltk_forms STATIC "${FORMS_FILES}")
target_link_libraries (fltk_forms fltk)

#######################################################################

FL_ADD_LIBRARY (fltk_images STATIC "${IMGCPPFILES}")
target_link_libraries (fltk_images fltk)

if (FLTK_USE_BUILTIN_JPEG)
  target_link_libraries (fltk_images fltk_jpeg)
else()
  target_link_libraries (fltk_images ${FLTK_JPEG_LIBRARIES})
endif ()

if (FLTK_USE_BUILTIN_ZLIB)
  target_link_libraries (fltk_images fltk_z)
else()
  target_link_libraries (fltk_images ${FLTK_ZLIB_LIBRARIES})
endif ()

if (FLTK_USE_BUILTIN_PNG)
  target_link_libraries (fltk_images fltk_png)
else()
  target_link_libraries (fltk_images ${FLTK_PNG_LIBRARIES})
endif ()

#######################################################################

if (OPENGL_FOUND)
  FL_ADD_LIBRARY (fltk_gl STATIC "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}")
  target_link_libraries (fltk_gl fltk ${OPENGL_LIBRARIES})
endif (OPENGL_FOUND)

#######################################################################
# Build shared libraries (optional)
#######################################################################
# Shared libraries, part 1: everything except Visual Studio (MSVC)
#######################################################################

if (OPTION_BUILD_SHARED_LIBS AND NOT MSVC)

  FL_ADD_LIBRARY (fltk SHARED "${SHARED_FILES}")
  target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS})

  ###################################################################

  FL_ADD_LIBRARY (fltk_forms SHARED "${FORMS_FILES}")
  target_link_libraries (fltk_forms_SHARED fltk_SHARED)

  ###################################################################

  FL_ADD_LIBRARY (fltk_images SHARED "${IMGCPPFILES}")
  target_link_libraries (fltk_images_SHARED fltk_SHARED)

  if (FLTK_USE_BUILTIN_JPEG)
    target_link_libraries (fltk_images_SHARED fltk_jpeg_SHARED)
  else()
    target_link_libraries (fltk_images_SHARED ${FLTK_JPEG_LIBRARIES})
  endif ()

  if (FLTK_USE_BUILTIN_PNG)
    target_link_libraries (fltk_images_SHARED fltk_png_SHARED)
  else()
    target_link_libraries (fltk_images_SHARED ${FLTK_PNG_LIBRARIES})
  endif ()

  if (FLTK_USE_BUILTIN_ZLIB)
    target_link_libraries (fltk_images_SHARED fltk_z_SHARED)
  else()
    target_link_libraries (fltk_images_SHARED ${FLTK_ZLIB_LIBRARIES})
  endif ()

  ###################################################################

  if (OPENGL_FOUND)
    FL_ADD_LIBRARY (fltk_gl SHARED "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}")
    target_link_libraries (fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES})
  endif (OPENGL_FOUND)

endif (OPTION_BUILD_SHARED_LIBS AND NOT MSVC)

#######################################################################
# Shared libraries, part 2: Visual Studio (MSVC)
#######################################################################

# Note to devs: As of June 2020 we can't build separate shared libs (DLL's)
# under Windows with Visual Studio (MSVC) but we can build one big DLL
# that comprises all FLTK and optional PNG, JPEG, and ZLIB libs.
# AlbrechtS

if (OPTION_BUILD_SHARED_LIBS AND MSVC)

  set (SOURCES ${SHARED_FILES} ${FORMS_FILES} ${IMGCPPFILES})
  if (OPENGL_FOUND)
    list (APPEND SOURCES ${GLCPPFILES} ${GL_HEADER_FILES} ${GL_DRIVER_HEADER_FILES})
  endif (OPENGL_FOUND)

  FL_ADD_LIBRARY (fltk SHARED "${SOURCES}")
  target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS})

  if (FLTK_USE_BUILTIN_JPEG)
    target_link_libraries (fltk_SHARED fltk_jpeg_SHARED)
  else()
    target_link_libraries (fltk_SHARED ${FLTK_JPEG_LIBRARIES})
  endif ()

  if (FLTK_USE_BUILTIN_PNG)
    target_link_libraries (fltk_SHARED fltk_png_SHARED)
  else()
    target_link_libraries (fltk_SHARED ${FLTK_PNG_LIBRARIES})
  endif ()

  if (FLTK_USE_BUILTIN_ZLIB)
    target_link_libraries (fltk_SHARED fltk_z_SHARED)
  else()
    target_link_libraries (fltk_SHARED ${FLTK_ZLIB_LIBRARIES})
  endif ()

  if (OPENGL_FOUND)
    target_link_libraries (fltk_SHARED ${OPENGL_LIBRARIES})
  endif (OPENGL_FOUND)

endif (OPTION_BUILD_SHARED_LIBS AND MSVC)

#######################################################################