summaryrefslogtreecommitdiff
path: root/examples/CMakeLists.txt
blob: 8912cffdfbc515310f4e25fcfac5623334ce97b2 (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
#
# CMakeLists.txt used to build example apps by the CMake build system
#
# Copyright 2020-2023 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
#
################################################################################

include (../CMake/fl_create_example.cmake)
include (../CMake/FLTK-Functions.cmake)

set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/examples)
file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})

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

# create separate lists of all source (.cxx) files
# depending on the required FLTK and system libraries

############################################################
# simple examples w/o extra libs
############################################################

set (SIMPLE_SOURCES
  browser-simple
  callbacks
  chart-simple
  draggable-group
  grid-simple
  howto-add_fd-and-popen
  howto-browser-with-icons
  howto-drag-and-drop
  howto-draw-an-x
  howto-flex-simple
  howto-menu-with-images
  howto-parse-args
  howto-remap-numpad-keyboard-keys
  howto-text-over-image-button
  menubar-add
  nativefilechooser-simple
  nativefilechooser-simple-app
  progress-simple
  shapedwindow
  simple-terminal
  table-as-container
  table-simple
  table-sort
  table-spreadsheet
  table-spreadsheet-with-keyboard-nav
  table-with-keynav
  table-with-right-column-stretch-fit
  table-with-right-click-menu
  tabs-simple
  textdisplay-with-colors
  texteditor-simple
  texteditor-with-dynamic-colors
  tree-as-container
  tree-custom-draw-items
  tree-custom-sort
  tree-of-tables
  tree-simple
  wizard-simple
)

############################################################
# simple FLUID examples w/o extra libs
############################################################

set (FLUID_SOURCES
  fluid-callback
)

############################################################
# examples requiring fltk_images
############################################################

set (IMAGE_SOURCES
  animgifimage
  animgifimage-play
  animgifimage-resize
  animgifimage-simple
  howto-simple-svg
)

############################################################
# examples requiring cairo
############################################################

set (CAIRO_SOURCES
  cairo-draw-x
)

############################################################
# examples requiring OpenGL + libGLEW
############################################################

set (OPENGL_SOURCES
  OpenGL3-glut-test
  OpenGL3test
)

############################################################
# create simple example programs
############################################################

foreach (src ${SIMPLE_SOURCES})
  CREATE_EXAMPLE (${src} ${src}.cxx fltk)
endforeach (src)

############################################################
# create FLUID example programs
############################################################

foreach (src ${FLUID_SOURCES})
  CREATE_EXAMPLE (${src} ${src}.fl fltk)
endforeach (src)

############################################################
# create example programs with fltk_images library
############################################################

foreach (src ${IMAGE_SOURCES})
  CREATE_EXAMPLE (${src} ${src}.cxx "fltk_images;fltk")
endforeach (src)

############################################################
# create example programs requiring cairo
############################################################

if (FLTK_HAVE_CAIRO)
  set (cairo_libs "fltk;cairo")
  if (TARGET fltk_cairo)
    set (cairo_libs fltk_cairo ${cairo_libs})
  endif ()
else ()
  set(cairo_libs "fltk")
endif ()

foreach (src ${CAIRO_SOURCES})
  CREATE_EXAMPLE (${src} ${src}.cxx "${cairo_libs}")
endforeach (src)

############################################################
# create example programs with OpenGL + libGLEW
############################################################

# Note: macOS does not need libGLEW

if (APPLE AND (NOT OPTION_APPLE_X11))
  if (NOT LIB_GLEW)
    set (LIB_GLEW TRUE)
  endif ()
  set (REQUIRED_LIBS fltk_gl fltk ${OPENGL_LIBRARIES})
else ()
  set (REQUIRED_LIBS fltk_gl fltk ${LIB_GLEW} ${OPENGL_LIBRARIES})
endif ()

if (OPENGL_FOUND AND LIB_GLEW)
  foreach (src ${OPENGL_SOURCES})
    CREATE_EXAMPLE (${src} ${src}.cxx "${REQUIRED_LIBS}")
  endforeach (src)
else ()
  message (STATUS
    "OpenGL or libGLEW not present: OpenGL example programs will not be built.")
  fl_debug_var (OPENGL_FOUND)
  fl_debug_var (LIB_GLEW)
  message ("")
endif (OPENGL_FOUND AND LIB_GLEW)

unset (REQUIRED_LIBS)