2020-08-13 21:32:56 +03:00
|
|
|
#
|
|
|
|
# CMakeLists.txt used to build example apps by the CMake build system
|
|
|
|
#
|
2024-02-07 20:30:11 +03:00
|
|
|
# Copyright 2020-2024 by Bill Spitzak and others.
|
2020-08-13 21:32:56 +03:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
include(../CMake/fl_create_example.cmake)
|
|
|
|
include(../CMake/FLTK-Functions.cmake)
|
2020-08-13 21:32:56 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/examples)
|
|
|
|
file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
|
2020-08-13 21:32:56 +03:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# create separate lists of all source (.cxx) files
|
|
|
|
# depending on the required FLTK and system libraries
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
# simple examples w/o extra libs
|
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
set(SIMPLE_SOURCES
|
2020-08-13 21:32:56 +03:00
|
|
|
browser-simple
|
2023-10-16 23:11:33 +03:00
|
|
|
callbacks
|
|
|
|
chart-simple
|
2020-08-13 21:32:56 +03:00
|
|
|
draggable-group
|
2023-10-16 23:11:33 +03:00
|
|
|
grid-simple
|
2020-08-13 21:32:56 +03:00
|
|
|
howto-add_fd-and-popen
|
|
|
|
howto-browser-with-icons
|
|
|
|
howto-drag-and-drop
|
|
|
|
howto-draw-an-x
|
2022-08-07 19:01:59 +03:00
|
|
|
howto-flex-simple
|
2020-08-13 21:32:56 +03:00
|
|
|
howto-menu-with-images
|
|
|
|
howto-parse-args
|
|
|
|
howto-remap-numpad-keyboard-keys
|
|
|
|
howto-text-over-image-button
|
|
|
|
menubar-add
|
|
|
|
nativefilechooser-simple
|
2023-10-16 23:11:33 +03:00
|
|
|
nativefilechooser-simple-app
|
2020-08-13 21:32:56 +03:00
|
|
|
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
|
2023-12-16 11:07:33 +03:00
|
|
|
table-with-right-click-menu
|
2020-08-13 21:32:56 +03:00
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2021-03-18 17:52:33 +03:00
|
|
|
############################################################
|
|
|
|
# simple FLUID examples w/o extra libs
|
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
set(FLUID_SOURCES
|
2021-03-18 17:52:33 +03:00
|
|
|
fluid-callback
|
|
|
|
)
|
|
|
|
|
2020-08-13 21:32:56 +03:00
|
|
|
############################################################
|
2024-05-01 18:31:17 +03:00
|
|
|
# examples requiring fltk::images
|
2020-08-13 21:32:56 +03:00
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
set(IMAGE_SOURCES
|
2023-01-21 19:27:58 +03:00
|
|
|
animgifimage
|
|
|
|
animgifimage-play
|
|
|
|
animgifimage-resize
|
|
|
|
animgifimage-simple
|
2020-08-13 21:32:56 +03:00
|
|
|
howto-simple-svg
|
|
|
|
)
|
|
|
|
|
2022-01-17 02:42:23 +03:00
|
|
|
############################################################
|
|
|
|
# examples requiring cairo
|
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
set(CAIRO_SOURCES
|
2022-01-17 02:42:23 +03:00
|
|
|
cairo-draw-x
|
|
|
|
)
|
|
|
|
|
2020-08-13 21:32:56 +03:00
|
|
|
############################################################
|
2024-05-01 18:31:17 +03:00
|
|
|
# examples requiring OpenGL3 + GLEW
|
2020-08-13 21:32:56 +03:00
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
set(OPENGL_SOURCES
|
2020-08-13 21:32:56 +03:00
|
|
|
OpenGL3-glut-test
|
|
|
|
OpenGL3test
|
|
|
|
)
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
# create simple example programs
|
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
foreach(src ${SIMPLE_SOURCES})
|
2024-02-11 18:06:17 +03:00
|
|
|
fl_create_example(${src} ${src}.cxx fltk::fltk)
|
2024-02-07 20:30:11 +03:00
|
|
|
endforeach(src)
|
2020-08-13 21:32:56 +03:00
|
|
|
|
2021-03-18 17:52:33 +03:00
|
|
|
############################################################
|
|
|
|
# create FLUID example programs
|
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
foreach(src ${FLUID_SOURCES})
|
2024-02-11 18:06:17 +03:00
|
|
|
fl_create_example(${src} ${src}.fl fltk::fltk)
|
2024-02-07 20:30:11 +03:00
|
|
|
endforeach(src)
|
2021-03-18 17:52:33 +03:00
|
|
|
|
2020-08-13 21:32:56 +03:00
|
|
|
############################################################
|
|
|
|
# create example programs with fltk_images library
|
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
foreach(src ${IMAGE_SOURCES})
|
2024-02-11 18:06:17 +03:00
|
|
|
fl_create_example(${src} ${src}.cxx "fltk::images")
|
2024-02-07 20:30:11 +03:00
|
|
|
endforeach(src)
|
2020-08-13 21:32:56 +03:00
|
|
|
|
2022-01-17 02:42:23 +03:00
|
|
|
############################################################
|
|
|
|
# create example programs requiring cairo
|
|
|
|
############################################################
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
foreach(src ${CAIRO_SOURCES})
|
2024-03-17 05:16:19 +03:00
|
|
|
fl_create_example(${src} ${src}.cxx fltk::fltk)
|
2024-02-07 20:30:11 +03:00
|
|
|
endforeach(src)
|
2022-01-17 02:42:23 +03:00
|
|
|
|
2020-08-13 21:32:56 +03:00
|
|
|
############################################################
|
2024-05-01 18:31:17 +03:00
|
|
|
# create example programs with OpenGL3 + GLEW
|
2020-08-13 21:32:56 +03:00
|
|
|
############################################################
|
2024-05-01 18:31:17 +03:00
|
|
|
#
|
|
|
|
# Note 1: macOS (Quartz) does not need GLEW, it's included in OpenGL
|
|
|
|
# Note 2: find_package(GLEW) finds either shared or static libs or both.
|
|
|
|
# Note 3: on Windows we set the variable GLEW_USE_STATIC_LIBS=TRUE because
|
|
|
|
# we *want* to find static libs but we *can* also use shared libs.
|
|
|
|
# Note 4: FindGLEW.cmake changed the library suffixes for MinGW in CMake 3.28.0,
|
|
|
|
# obviously "assuming" that ".lib" is Visual Studio only. There have been
|
|
|
|
# discussions about finding the "wrong" libraries since CMake 3.25 or so.
|
|
|
|
# Therefore the static lib "glew32s.lib" is not found if CMake 3.28 or
|
|
|
|
# higher is used (current version, as of this writing: 3.29.3). However,
|
|
|
|
# this assumption is probably not true for a pure C library (glew32s).
|
|
|
|
# This library *is* found and works well with CMake 3.15.0 - 3.27.9.
|
|
|
|
# Users may need to copy or rename "glew32s.lib" to "glew32s.a"
|
|
|
|
# if CMake 3.28 or higher is used.
|
|
|
|
# Albrecht-S, May 13, 2024
|
|
|
|
|
|
|
|
if(OPENGL_FOUND)
|
|
|
|
if(WIN32)
|
|
|
|
set(GLEW_USE_STATIC_LIBS TRUE)
|
|
|
|
endif()
|
|
|
|
set(_glew_lib GLEW::glew)
|
|
|
|
set(_glew_static FALSE)
|
|
|
|
if(APPLE AND NOT FLTK_BACKEND_X11) # macOS Quartz
|
|
|
|
set(_glew_lib)
|
|
|
|
set(GLEW_FOUND TRUE)
|
|
|
|
else()
|
|
|
|
# set(GLEW_VERBOSE TRUE) # make `find_package(GLEW)` verbose
|
|
|
|
set(_CMAKE_PREFIX_PATH_SAVED ${CMAKE_PREFIX_PATH})
|
|
|
|
set(CMAKE_PREFIX_PATH ${FLTK_GLEW_DIR} ${CMAKE_PREFIX_PATH})
|
|
|
|
find_package(GLEW MODULE)
|
|
|
|
set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH_SAVED})
|
|
|
|
unset(_CMAKE_PREFIX_PATH_SAVED)
|
|
|
|
# Did we find the static lib? If yes, use it
|
|
|
|
if(TARGET GLEW::glew_s)
|
|
|
|
set(_glew_lib GLEW::glew_s)
|
|
|
|
set(_glew_static TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-08-13 21:32:56 +03:00
|
|
|
|
2024-05-01 18:31:17 +03:00
|
|
|
if(0) # Debug
|
|
|
|
fl_debug_var(OPENGL_FOUND)
|
|
|
|
fl_debug_var(GLEW_FOUND)
|
|
|
|
fl_debug_var(GLEW_DIR)
|
|
|
|
fl_debug_var(_glew_lib)
|
|
|
|
fl_debug_target(GLEW::glew)
|
|
|
|
fl_debug_target(GLEW::glew_s)
|
|
|
|
fl_debug_target(GLEW::GLEW)
|
|
|
|
endif() # /Debug
|
2020-08-13 21:32:56 +03:00
|
|
|
|
2024-05-01 18:31:17 +03:00
|
|
|
endif(OPENGL_FOUND)
|
|
|
|
|
|
|
|
if(OPENGL_FOUND AND (TARGET "${_glew_lib}" OR APPLE))
|
|
|
|
|
|
|
|
# GLEW was found, create the OpenGL3 targets:
|
2024-02-07 20:30:11 +03:00
|
|
|
|
2024-02-11 18:06:17 +03:00
|
|
|
foreach(tgt ${OPENGL_SOURCES})
|
2024-05-01 18:31:17 +03:00
|
|
|
fl_create_example(${tgt} ${tgt}.cxx "fltk::gl;${_glew_lib}")
|
2024-02-11 18:06:17 +03:00
|
|
|
set_property(TARGET ${tgt} PROPERTY CXX_STANDARD 11)
|
|
|
|
set_property(TARGET ${tgt} PROPERTY CXX_STANDARD_REQUIRED TRUE)
|
2024-05-01 18:31:17 +03:00
|
|
|
# define preprocessor macro GLEW_STATIC only if we link to the static lib
|
|
|
|
if(_glew_static)
|
|
|
|
target_compile_definitions(${tgt} PRIVATE "GLEW_STATIC")
|
|
|
|
endif()
|
2024-02-11 18:06:17 +03:00
|
|
|
endforeach(tgt)
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
else()
|
2024-05-01 18:31:17 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
message(STATUS
|
2024-05-01 18:31:17 +03:00
|
|
|
"OpenGL or GLEW not present: OpenGL3 example programs will not be built.")
|
2024-02-07 20:30:11 +03:00
|
|
|
fl_debug_var(OPENGL_FOUND)
|
2024-05-01 18:31:17 +03:00
|
|
|
fl_debug_var(GLEW_FOUND)
|
2024-02-07 20:30:11 +03:00
|
|
|
message("")
|
2020-08-13 21:32:56 +03:00
|
|
|
|
2024-05-01 18:31:17 +03:00
|
|
|
endif() # (OPENGL_FOUND AND TARGET "${_glew_lib}")
|