summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2022-04-02 22:08:50 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2022-04-03 23:47:23 +0200
commit228d04d0e0d6e968c59bcab606e609eb1103f917 (patch)
treec7db9621ec19d42cca8231cba957609ab868e353 /fluid
parent5a8b9d9130d9c9bd0adeca33ac051eb9249953fb (diff)
Build and use fluid-cmd on Windows for .fl files (#224, #293)
On Windows fluid.exe is a "GUI" program and does not allow console output which can be a problem in automated builds. In Visual Studio the fluid GUI program would pop up console windows when generating .cxx and .h files from .fl files. The new (additional) fluid-cmd.exe is built as console application for users that need it and it is used in the FLTK build process on Windows to convert the .fl files.
Diffstat (limited to 'fluid')
-rw-r--r--fluid/CMakeLists.txt54
1 files changed, 42 insertions, 12 deletions
diff --git a/fluid/CMakeLists.txt b/fluid/CMakeLists.txt
index a5676aebc..443bdca1d 100644
--- a/fluid/CMakeLists.txt
+++ b/fluid/CMakeLists.txt
@@ -1,7 +1,7 @@
#
# CMakeLists.txt to build fluid for the FLTK project using CMake (www.cmake.org)
#
-# Copyright 1998-2021 by Bill Spitzak and others.
+# 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
@@ -84,7 +84,13 @@ endif (WIN32)
source_group("Header Files" FILES ${HEADERFILES})
+set (FLUID_TARGETS fluid) # fluid and optional fluid-cmd target
+set (FLUID_LIBS fltk fltk_images) # libraries used to link fluid executables
+
if (APPLE AND (NOT OPTION_APPLE_X11))
+
+ # macOS
+
set (ICON_NAME fluid.icns)
set (ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}")
add_executable (fluid MACOSX_BUNDLE ${CPPFILES} ${HEADERFILES} ${ICON_PATH})
@@ -97,20 +103,20 @@ if (APPLE AND (NOT OPTION_APPLE_X11))
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER}
COMMAND chmod u+x,g+x,o+x ${WRAPPER}
BYPRODUCTS ${WRAPPER}
- # COMMENT "Creating macOS bundle wrapper script ${WRAPPER}"
VERBATIM
)
unset (WRAPPER)
else ()
+
+ # option WIN32 builds a Windows GUI program, ignored on other platforms
add_executable (fluid WIN32 ${CPPFILES} ${HEADERFILES})
-endif (APPLE AND (NOT OPTION_APPLE_X11))
-target_link_libraries (fluid fltk fltk_images)
+endif ()
# we must link all programs with fltk_cairo if option CAIROEXT is enabled
if (FLTK_HAVE_CAIROEXT)
- target_link_libraries (fluid fltk_cairo cairo)
+ list (APPEND FLUID_LIBS fltk_cairo cairo)
endif (FLTK_HAVE_CAIROEXT)
if (FLTK_HAVE_CAIRO)
@@ -118,10 +124,26 @@ if (FLTK_HAVE_CAIRO)
endif (FLTK_HAVE_CAIRO)
if (USE_GDIPLUS) # can only be true on Windows
- target_link_libraries (fluid gdiplus)
+ list (APPEND FLUID_LIBS gdiplus)
endif (USE_GDIPLUS)
-# install fluid
+target_link_libraries (fluid ${FLUID_LIBS})
+
+
+# Add fluid-cmd console app (Windows only) for converting .fl to .cxx/.h files.
+# This is done for all Windows targets, even if cross-compiling.
+
+if (WIN32)
+ list (APPEND FLUID_TARGETS fluid-cmd)
+ add_executable (fluid-cmd ${CPPFILES} ${HEADERFILES})
+ target_link_libraries (fluid-cmd ${FLUID_LIBS})
+ if (FLTK_HAVE_CAIRO)
+ fl_target_link_directories (fluid-cmd PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}")
+ endif (FLTK_HAVE_CAIRO)
+endif ()
+
+
+# install fluid GUI and commandline tool
if (APPLE AND (NOT OPTION_APPLE_X11))
@@ -130,26 +152,34 @@ if (APPLE AND (NOT OPTION_APPLE_X11))
# full GUI. The binary without bundle should go into ${FLTK_BINDIR}, usually
# /usr/local/bin, so it will be picked up as a command line tool by
# the build process of other apps.
+ # On macOS the command line tool is the same target ('fluid') as the one
+ # included in the bundle.
# create bundle
set_target_properties (fluid PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/fluid.plist")
set_target_properties (fluid PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
+
# The line below would wrongly install /Applications/fluid.icns
- #set_target_properties (fluid PROPERTIES RESOURCE ${ICON_PATH})
- # install GUI tool
+ # ## set_target_properties (fluid PROPERTIES RESOURCE ${ICON_PATH})
+
+ # install fluid GUI and commandline tools
install (TARGETS fluid DESTINATION "/Applications")
# install command line tool
- install (PROGRAMS $<TARGET_FILE:fluid> DESTINATION ${FLTK_BINDIR} )
+ install (PROGRAMS $<TARGET_FILE:fluid> DESTINATION ${FLTK_BINDIR})
else()
- install (TARGETS fluid
+
+ # install Fluid GUI and optional commandline tool 'fluid-cmd' (only on Windows)
+
+ install (TARGETS ${FLUID_TARGETS}
EXPORT FLTK-Targets
RUNTIME DESTINATION ${FLTK_BINDIR}
LIBRARY DESTINATION ${FLTK_LIBDIR}
ARCHIVE DESTINATION ${FLTK_LIBDIR}
)
-endif (APPLE AND (NOT OPTION_APPLE_X11))
+
+ endif (APPLE AND (NOT OPTION_APPLE_X11))
# install desktop files