2015-02-16 14:30:27 +00:00
|
|
|
#
|
|
|
|
|
# CMakeLists.txt to build fluid for the FLTK project using CMake (www.cmake.org)
|
|
|
|
|
#
|
2026-02-07 19:08:23 +00:00
|
|
|
# Copyright 1998-2026 by Bill Spitzak and others.
|
2015-02-16 14:30:27 +00: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:
|
|
|
|
|
#
|
2018-12-04 13:16:55 +00:00
|
|
|
# https://www.fltk.org/COPYING.php
|
2015-02-16 14:30:27 +00:00
|
|
|
#
|
2020-07-01 16:03:10 +00:00
|
|
|
# Please see the following page on how to report bugs and issues:
|
2015-02-16 14:30:27 +00:00
|
|
|
#
|
2020-07-01 16:03:10 +00:00
|
|
|
# https://www.fltk.org/bugs.php
|
2015-02-16 14:30:27 +00:00
|
|
|
#
|
2010-04-05 22:33:58 +00:00
|
|
|
|
2026-02-07 19:08:23 +00:00
|
|
|
# Targets that will be installed: fluid, fluid-shared, and fluid-cmd (Windows only)
|
2025-04-17 16:23:55 +00:00
|
|
|
set(TARGETS "")
|
2026-02-07 19:08:23 +00:00
|
|
|
# Targets that will be installed *and* "exported" as targets in CMake config file
|
|
|
|
|
set(EXPORTS "")
|
2025-04-17 16:23:55 +00:00
|
|
|
|
|
|
|
|
# Defaults to be used and potentially modified later
|
|
|
|
|
|
|
|
|
|
set(BACKEND_APPLE FALSE) # FIXME: should be global, e.g. FLTK_BACKEND_APPLE
|
|
|
|
|
set(ICON_NAME "")
|
|
|
|
|
set(ICON_PATH "")
|
|
|
|
|
set(SUFFIX "UNIX") # suffix for platform specific source files
|
|
|
|
|
|
|
|
|
|
# platform specific settings
|
|
|
|
|
|
|
|
|
|
if(APPLE AND NOT FLTK_BACKEND_X11) # macOS "native"
|
|
|
|
|
set(BACKEND_APPLE TRUE)
|
|
|
|
|
set(ICON_NAME fluid.icns)
|
|
|
|
|
set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}")
|
|
|
|
|
elseif(WIN32)
|
|
|
|
|
set(SUFFIX "WIN32")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# This macro is used to avoid duplicate code to create executable programs.
|
|
|
|
|
# This must be a macro because it changes at least one global variable: TARGETS.
|
|
|
|
|
# This macro also uses some (local) variables defined above.
|
|
|
|
|
# In the future this might be converted to a function to avoid side effects.
|
2026-02-07 19:08:23 +00:00
|
|
|
#
|
|
|
|
|
# Parameters:
|
|
|
|
|
# - TARGET target name, e.g. 'fluid', 'fluid-cmd', 'fluid-shared', ...
|
|
|
|
|
# - GUI TRUE (GUI) or FALSE (command-line)
|
|
|
|
|
# - SOURCES source files
|
|
|
|
|
# - LIBS link libraries
|
|
|
|
|
# - EXPORT_NAME should be the same as TARGET, unless there are reasons...
|
|
|
|
|
# - EXPORT TRUE if "exported" in config file, FALSE if not
|
|
|
|
|
# - (others) see local variables defined above !
|
2025-04-17 16:23:55 +00:00
|
|
|
|
2026-02-07 19:08:23 +00:00
|
|
|
macro(make_target TARGET GUI SOURCES LIBS EXPORT_NAME EXPORT)
|
2025-04-17 16:23:55 +00:00
|
|
|
|
|
|
|
|
if(ICON_PATH)
|
|
|
|
|
list(APPEND SOURCES ${ICON_PATH}) # macOS only
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-02-07 19:08:23 +00:00
|
|
|
# message(STATUS "[fluid] make_target ${TARGET} GUI:${GUI} ${SOURCES} ${LIBS} NAME:${EXPORT_NAME} EXPORT:${EXPORT}")
|
2025-04-17 16:23:55 +00:00
|
|
|
|
|
|
|
|
# Options WIN32 and MACOSX_BUNDLE build a Windows GUI program or macOS bundle,
|
|
|
|
|
# respectively. Both options are ignored on other platforms.
|
|
|
|
|
|
|
|
|
|
if(${GUI})
|
|
|
|
|
add_executable(${TARGET} WIN32 MACOSX_BUNDLE ${SOURCES})
|
|
|
|
|
else()
|
|
|
|
|
add_executable(${TARGET} ${SOURCES})
|
|
|
|
|
endif(${GUI})
|
|
|
|
|
|
2026-02-07 19:08:23 +00:00
|
|
|
if(${EXPORT})
|
|
|
|
|
list(APPEND EXPORTS ${TARGET})
|
|
|
|
|
else()
|
|
|
|
|
list(APPEND TARGETS ${TARGET})
|
|
|
|
|
endif()
|
2025-04-17 16:23:55 +00:00
|
|
|
|
|
|
|
|
if(BACKEND_APPLE)
|
|
|
|
|
|
|
|
|
|
# set bundle properties
|
|
|
|
|
set_target_properties(${TARGET} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.plist")
|
|
|
|
|
set_target_properties(${TARGET} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
|
|
|
|
|
set_target_properties(${TARGET} PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.${TARGET}")
|
|
|
|
|
|
|
|
|
|
# install command line tool
|
|
|
|
|
install(PROGRAMS $<TARGET_FILE:${TARGET}>
|
|
|
|
|
DESTINATION ${FLTK_BINDIR})
|
|
|
|
|
|
|
|
|
|
# create macOS bundle wrapper script
|
|
|
|
|
|
|
|
|
|
set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${TARGET}")
|
|
|
|
|
add_custom_command(
|
|
|
|
|
TARGET ${TARGET} POST_BUILD
|
|
|
|
|
COMMAND cp ${FLTK_SOURCE_DIR}/CMake/macOS-bundle-wrapper.in ${WRAPPER}
|
|
|
|
|
COMMAND chmod u+x,g+x,o+x ${WRAPPER}
|
|
|
|
|
BYPRODUCTS ${WRAPPER}
|
|
|
|
|
VERBATIM
|
|
|
|
|
)
|
|
|
|
|
unset(WRAPPER)
|
|
|
|
|
|
|
|
|
|
endif(BACKEND_APPLE)
|
|
|
|
|
|
|
|
|
|
target_link_libraries(${TARGET} PRIVATE ${LIBS})
|
|
|
|
|
set_target_properties(${TARGET} PROPERTIES EXPORT_NAME ${EXPORT_NAME})
|
|
|
|
|
|
2026-02-07 19:08:23 +00:00
|
|
|
endmacro(make_target TARGET GUI SOURCES LIBS EXPORT_NAME EXPORT)
|
2025-04-17 16:23:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Main source and header files used for the executable because macOS (Xcode)
|
|
|
|
|
# needs at least one source file (main.cxx) to link the main program properly
|
|
|
|
|
|
|
|
|
|
set(MAIN_FILES main.cxx main.h)
|
|
|
|
|
|
|
|
|
|
# Source files for 'fluid-lib': all source files except ${MAIN_FILES}
|
2024-02-07 17:30:11 +00:00
|
|
|
|
|
|
|
|
set(CPPFILES
|
2025-03-16 21:16:12 +00:00
|
|
|
Fluid.cxx
|
|
|
|
|
Project.cxx
|
|
|
|
|
app/args.cxx
|
|
|
|
|
app/Snap_Action.cxx
|
|
|
|
|
app/Image_Asset.cxx
|
|
|
|
|
app/history.cxx
|
|
|
|
|
app/Menu.cxx
|
2025-03-07 15:34:35 +00:00
|
|
|
app/shell_command.cxx
|
2025-03-16 21:16:12 +00:00
|
|
|
app/templates.cxx
|
2025-03-07 23:14:09 +00:00
|
|
|
io/Code_Writer.cxx
|
|
|
|
|
io/Project_Writer.cxx
|
|
|
|
|
io/Project_Reader.cxx
|
2025-03-16 21:16:12 +00:00
|
|
|
io/String_Writer.cxx
|
|
|
|
|
nodes/Tree.cxx
|
|
|
|
|
nodes/Button_Node.cxx
|
|
|
|
|
nodes/Function_Node.cxx
|
|
|
|
|
nodes/Grid_Node.cxx
|
|
|
|
|
nodes/Group_Node.cxx
|
|
|
|
|
nodes/Menu_Node.cxx
|
|
|
|
|
nodes/Node.cxx
|
|
|
|
|
nodes/Widget_Node.cxx
|
|
|
|
|
nodes/Window_Node.cxx
|
|
|
|
|
nodes/callbacks.cxx
|
2025-03-07 15:34:35 +00:00
|
|
|
nodes/factory.cxx
|
|
|
|
|
panels/about_panel.cxx
|
|
|
|
|
panels/codeview_panel.cxx
|
|
|
|
|
panels/function_panel.cxx
|
|
|
|
|
panels/settings_panel.cxx
|
|
|
|
|
panels/template_panel.cxx
|
|
|
|
|
panels/widget_panel.cxx
|
2025-03-16 21:16:12 +00:00
|
|
|
panels/widget_panel/Grid_Tab.cxx
|
|
|
|
|
panels/widget_panel/Grid_Child_Tab.cxx
|
|
|
|
|
proj/align_widget.cxx
|
2025-06-27 12:34:49 +00:00
|
|
|
proj/i18n.cxx
|
2025-03-16 21:16:12 +00:00
|
|
|
proj/mergeback.cxx
|
|
|
|
|
proj/undo.cxx
|
2025-03-07 15:34:35 +00:00
|
|
|
rsrcs/pixmaps.cxx
|
2025-04-17 16:23:55 +00:00
|
|
|
tools/ExternalCodeEditor_${SUFFIX}.cxx
|
2025-03-07 15:34:35 +00:00
|
|
|
tools/autodoc.cxx
|
2025-03-07 23:14:09 +00:00
|
|
|
tools/filename.cxx
|
2025-04-15 13:28:31 +00:00
|
|
|
widgets/App_Menu_Bar.cxx
|
2025-03-07 17:54:03 +00:00
|
|
|
widgets/Code_Editor.cxx
|
|
|
|
|
widgets/Code_Viewer.cxx
|
|
|
|
|
widgets/Text_Viewer.cxx
|
|
|
|
|
widgets/Formula_Input.cxx
|
|
|
|
|
widgets/Bin_Button.cxx
|
|
|
|
|
widgets/Style_Parser.cxx
|
2025-03-07 18:52:54 +00:00
|
|
|
widgets/Node_Browser.cxx
|
2004-10-18 20:29:58 +00:00
|
|
|
)
|
|
|
|
|
|
2023-05-07 19:18:52 +00:00
|
|
|
# List header files in Apple's Xcode IDE
|
2021-12-03 19:29:20 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
set(HEADERFILES
|
2025-03-16 21:16:12 +00:00
|
|
|
Fluid.h
|
|
|
|
|
Project.h
|
|
|
|
|
app/args.h
|
|
|
|
|
app/Snap_Action.h
|
|
|
|
|
app/Image_Asset.h
|
|
|
|
|
app/history.h
|
|
|
|
|
app/Menu.h
|
2025-03-07 15:34:35 +00:00
|
|
|
app/shell_command.h
|
2025-03-16 21:16:12 +00:00
|
|
|
app/templates.h
|
2025-03-07 23:14:09 +00:00
|
|
|
io/Code_Writer.h
|
|
|
|
|
io/Project_Writer.h
|
|
|
|
|
io/Project_Reader.h
|
2025-03-16 21:16:12 +00:00
|
|
|
io/String_Writer.h
|
|
|
|
|
nodes/Tree.h
|
|
|
|
|
nodes/Button_Node.h
|
|
|
|
|
nodes/Function_Node.h
|
|
|
|
|
nodes/Grid_Node.h
|
|
|
|
|
nodes/Group_Node.h
|
|
|
|
|
nodes/Menu_Node.h
|
|
|
|
|
nodes/Node.h
|
|
|
|
|
nodes/Widget_Node.h
|
|
|
|
|
nodes/Window_Node.h
|
|
|
|
|
nodes/callbacks.h
|
2025-03-07 15:34:35 +00:00
|
|
|
nodes/factory.h
|
|
|
|
|
panels/about_panel.h
|
|
|
|
|
panels/codeview_panel.h
|
|
|
|
|
panels/function_panel.h
|
|
|
|
|
panels/settings_panel.h
|
|
|
|
|
panels/template_panel.h
|
|
|
|
|
panels/widget_panel.h
|
2025-03-16 21:16:12 +00:00
|
|
|
panels/widget_panel/Grid_Tab.h
|
|
|
|
|
panels/widget_panel/Grid_Child_Tab.h
|
|
|
|
|
proj/align_widget.h
|
|
|
|
|
proj/mergeback.h
|
2025-06-27 12:34:49 +00:00
|
|
|
proj/i18n.h
|
2025-03-16 21:16:12 +00:00
|
|
|
proj/undo.h
|
2025-03-07 15:34:35 +00:00
|
|
|
rsrcs/comments.h
|
|
|
|
|
rsrcs/pixmaps.h
|
2025-04-17 16:23:55 +00:00
|
|
|
tools/ExternalCodeEditor_${SUFFIX}.h
|
2025-03-07 15:34:35 +00:00
|
|
|
tools/autodoc.h
|
2025-03-07 23:14:09 +00:00
|
|
|
tools/filename.h
|
2025-04-15 13:28:31 +00:00
|
|
|
widgets/App_Menu_Bar.h
|
2025-03-07 17:54:03 +00:00
|
|
|
widgets/Code_Editor.h
|
|
|
|
|
widgets/Code_Viewer.h
|
|
|
|
|
widgets/Text_Viewer.h
|
|
|
|
|
widgets/Formula_Input.h
|
|
|
|
|
widgets/Bin_Button.h
|
|
|
|
|
widgets/Style_Parser.h
|
2025-03-07 18:52:54 +00:00
|
|
|
widgets/Node_Browser.h
|
2021-12-03 19:29:20 +00:00
|
|
|
)
|
|
|
|
|
|
2025-03-07 15:34:35 +00:00
|
|
|
source_group(
|
|
|
|
|
TREE
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
FILES
|
|
|
|
|
${CPPFILES}
|
|
|
|
|
${HEADERFILES}
|
2025-04-04 13:54:36 +00:00
|
|
|
${MAIN_FILES}
|
2025-03-07 15:34:35 +00:00
|
|
|
CMakeLists.txt
|
|
|
|
|
)
|
2021-12-03 19:29:20 +00:00
|
|
|
|
2023-05-07 19:18:52 +00:00
|
|
|
# Build a local object library to avoid compiling all source files
|
2024-02-07 17:30:11 +00:00
|
|
|
# multiple times for all fluid targets on Windows (fluid + fluid-cmd).
|
2023-05-07 19:18:52 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
add_library(fluid-lib OBJECT EXCLUDE_FROM_ALL)
|
|
|
|
|
target_sources(fluid-lib PRIVATE ${CPPFILES} ${HEADERFILES})
|
2025-04-04 13:54:36 +00:00
|
|
|
target_include_directories(fluid-lib PUBLIC .)
|
2024-02-07 17:30:11 +00:00
|
|
|
target_link_libraries(fluid-lib PUBLIC fltk::images)
|
2023-05-07 19:18:52 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
# Build targets
|
2022-04-02 20:08:50 +00:00
|
|
|
|
2026-02-07 19:08:23 +00:00
|
|
|
make_target(fluid TRUE "${MAIN_FILES}" fluid-lib fluid TRUE)
|
2010-04-05 22:33:58 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
# Build the console app on Windows
|
|
|
|
|
# This is done for all Windows targets, even if cross-compiling.
|
2021-02-26 17:00:07 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(WIN32)
|
2026-02-07 19:08:23 +00:00
|
|
|
make_target(fluid-cmd FALSE "${MAIN_FILES}" fluid-lib fluid-cmd TRUE)
|
2024-02-12 15:33:40 +00:00
|
|
|
set(FLTK_FLUID_EXECUTABLE fltk::fluid-cmd)
|
|
|
|
|
else()
|
|
|
|
|
set(FLTK_FLUID_EXECUTABLE fltk::fluid)
|
2024-02-07 17:30:11 +00:00
|
|
|
endif()
|
2022-04-02 20:08:50 +00:00
|
|
|
|
2025-04-17 16:23:55 +00:00
|
|
|
# Add the "shared" executable (linked against the shared FLTK libs).
|
|
|
|
|
# Note 1: only the GUI version is built as "shared" executable.
|
|
|
|
|
# Note 2: For MSVC we need the special object library 'call_main'.
|
2024-02-12 15:33:40 +00:00
|
|
|
|
2025-04-17 16:23:55 +00:00
|
|
|
if(FLTK_BUILD_SHARED_LIBS)
|
2022-04-02 20:08:50 +00:00
|
|
|
|
2025-04-17 16:23:55 +00:00
|
|
|
add_library(fluid-lib-shared OBJECT EXCLUDE_FROM_ALL)
|
|
|
|
|
target_sources(fluid-lib-shared PRIVATE ${CPPFILES} ${HEADERFILES})
|
|
|
|
|
target_include_directories(fluid-lib-shared PUBLIC .)
|
|
|
|
|
if(MSVC)
|
|
|
|
|
target_link_libraries(fluid-lib-shared PUBLIC fltk::fltk-shared)
|
|
|
|
|
else()
|
|
|
|
|
target_link_libraries(fluid-lib-shared PUBLIC fltk::images-shared)
|
|
|
|
|
endif(MSVC)
|
|
|
|
|
|
|
|
|
|
if(MSVC)
|
2026-02-07 19:08:23 +00:00
|
|
|
make_target(fluid-shared TRUE "${MAIN_FILES}" "fluid-lib-shared;call_main" fluid-shared FALSE)
|
2025-04-17 16:23:55 +00:00
|
|
|
else()
|
2026-02-07 19:08:23 +00:00
|
|
|
make_target(fluid-shared TRUE "${MAIN_FILES}" fluid-lib-shared fluid-shared FALSE)
|
2025-04-17 16:23:55 +00:00
|
|
|
endif()
|
2022-04-02 20:08:50 +00:00
|
|
|
|
2025-04-17 16:23:55 +00:00
|
|
|
# experimental
|
|
|
|
|
# if(NOT WIN32)
|
|
|
|
|
# set(FLTK_FLUID_EXECUTABLE fltk::fluid-shared)
|
|
|
|
|
# message(STATUS "** experimental ** FLTK_FLUID_EXECUTABLE = ${FLTK_FLUID_EXECUTABLE}")
|
|
|
|
|
# endif()
|
2015-12-30 14:37:35 +00:00
|
|
|
|
2025-04-17 16:23:55 +00:00
|
|
|
endif(FLTK_BUILD_SHARED_LIBS)
|
2022-01-01 12:53:21 +00:00
|
|
|
|
2025-04-17 16:23:55 +00:00
|
|
|
# export the variable FLTK_FLUID_EXECUTABLE to the parent scope
|
2024-02-14 16:06:10 +00:00
|
|
|
|
2025-04-17 16:23:55 +00:00
|
|
|
set(FLTK_FLUID_EXECUTABLE "${FLTK_FLUID_EXECUTABLE}" PARENT_SCOPE)
|
2022-04-02 20:08:50 +00:00
|
|
|
|
2025-04-17 16:23:55 +00:00
|
|
|
# Create aliases for all targets
|
2022-04-02 20:08:50 +00:00
|
|
|
|
2026-02-07 19:08:23 +00:00
|
|
|
foreach(tgt ${TARGETS} ${EXPORTS})
|
2025-04-17 16:23:55 +00:00
|
|
|
add_executable(fltk::${tgt} ALIAS ${tgt})
|
|
|
|
|
endforeach()
|
2022-04-02 20:08:50 +00:00
|
|
|
|
2024-02-14 16:06:10 +00:00
|
|
|
# Install the GUI and (on Windows only) the commandline tool 'fluid-cmd'
|
2026-02-07 19:08:23 +00:00
|
|
|
# message(STATUS "[fluid] INSTALL + EXPORT: ${EXPORTS}")
|
|
|
|
|
# message(STATUS "[fluid] INSTALL - only : ${TARGETS}")
|
|
|
|
|
|
|
|
|
|
if(EXPORTS)
|
|
|
|
|
install(TARGETS ${EXPORTS}
|
|
|
|
|
EXPORT FLTK-Targets
|
|
|
|
|
RUNTIME DESTINATION ${FLTK_BINDIR}
|
|
|
|
|
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
|
|
|
|
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
|
|
|
|
BUNDLE DESTINATION ${FLTK_BINDIR} # macOS: bundles
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(TARGETS)
|
|
|
|
|
install(TARGETS ${TARGETS}
|
|
|
|
|
RUNTIME DESTINATION ${FLTK_BINDIR}
|
|
|
|
|
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
|
|
|
|
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
|
|
|
|
BUNDLE DESTINATION ${FLTK_BINDIR} # macOS: bundles
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2015-02-16 14:30:27 +00:00
|
|
|
|
2023-05-07 19:18:52 +00:00
|
|
|
# Install desktop files
|
2016-03-27 20:59:39 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(UNIX)
|
|
|
|
|
install(FILES fluid.desktop
|
2020-06-13 13:19:27 +00:00
|
|
|
DESTINATION ${FLTK_DATADIR}/applications
|
|
|
|
|
)
|
2024-02-07 17:30:11 +00:00
|
|
|
# Install mime-type file(x-fluid.desktop method is deprecated)
|
|
|
|
|
install(FILES fluid.xml
|
2020-06-13 13:19:27 +00:00
|
|
|
DESTINATION ${FLTK_DATADIR}/mime/packages
|
|
|
|
|
)
|
2015-02-16 14:30:27 +00:00
|
|
|
|
2020-06-13 13:19:27 +00:00
|
|
|
# Install desktop icons
|
2024-02-07 17:30:11 +00:00
|
|
|
foreach(icon 32 48 64 128)
|
2025-03-07 15:46:39 +00:00
|
|
|
install(FILES icons/fluid-${icon}.png
|
|
|
|
|
DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps
|
2020-06-13 13:19:27 +00:00
|
|
|
RENAME fluid.png
|
|
|
|
|
)
|
|
|
|
|
endforeach()
|
2024-02-07 17:30:11 +00:00
|
|
|
endif(UNIX)
|