mirror of
https://github.com/fltk/fltk.git
synced 2026-02-05 15:59:50 +08:00
Fix "fully support ... own shared libraries" (#1238)
- If shared libraries are built, then fluid, fltk-options, and the "games" are linked against the shared FLTK libraries. On some platforms the static and the shared versions of fluid and fltk-options are built. The games are only built if FLTK_BUILD_TEST is enabled. - The CMake 'install' target now installs the games (if built) and their man pages on all platforms (no matter if that is useful, for instance on Windows). - On macOS 'CMAKE_INSTALL_RPATH' is set so *installed* programs automatically find their shared FLTK libraries. The "shared" versions of fluid and fltk-options got their own '.plist' files. This works for both the executables themselves as well as those included in bundles. There may be more to do on the macOS platform.
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -103,7 +103,7 @@ jobs:
|
||||
# Note the current convention is to use the -S and -B options here to specify source
|
||||
# and build directories, but this is only available with CMake 3.13 and higher.
|
||||
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
|
||||
run: cmake $GITHUB_WORKSPACE -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D CMAKE_CXX_STANDARD=11 -D CMAKE_CXX_EXTENSIONS=OFF -D CMAKE_C_FLAGS_INIT="-Wall -Wunused" -D CMAKE_CXX_FLAGS_INIT="-Wall -Wunused -Wsuggest-override"
|
||||
run: cmake $GITHUB_WORKSPACE -D CMAKE_BUILD_TYPE=$BUILD_TYPE -DFLTK_BUILD_SHARED_LIBS:BOOL=ON -D CMAKE_CXX_STANDARD=11 -D CMAKE_CXX_EXTENSIONS=OFF -D CMAKE_C_FLAGS_INIT="-Wall -Wunused" -D CMAKE_CXX_FLAGS_INIT="-Wall -Wunused -Wsuggest-override"
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Installation support for building the FLTK project using CMake (www.cmake.org)
|
||||
# Originally written by Michael Surette
|
||||
#
|
||||
# Copyright 1998-2024 by Bill Spitzak and others.
|
||||
# Copyright 1998-2025 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
|
||||
@@ -103,29 +103,51 @@ install(PROGRAMS
|
||||
DESTINATION ${FLTK_BINDIR}
|
||||
)
|
||||
|
||||
if(UNIX OR MSYS OR MINGW)
|
||||
macro(INSTALL_MAN FILE LEVEL)
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/documentation/src/${FILE}.man
|
||||
DESTINATION ${FLTK_MANDIR}/man${LEVEL}
|
||||
RENAME ${FILE}.${LEVEL}
|
||||
)
|
||||
endmacro(INSTALL_MAN FILE LEVEL)
|
||||
# Install man pages of fluid and fltk-options
|
||||
|
||||
if(FLTK_BUILD_FLUID)
|
||||
INSTALL_MAN (fluid 1)
|
||||
endif(FLTK_BUILD_FLUID)
|
||||
if(FLTK_BUILD_FLTK_OPTIONS)
|
||||
INSTALL_MAN (fltk-options 1)
|
||||
endif(FLTK_BUILD_FLTK_OPTIONS)
|
||||
INSTALL_MAN (fltk-config 1)
|
||||
INSTALL_MAN (fltk 3)
|
||||
macro(INSTALL_MAN FILE LEVEL)
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/documentation/src/${FILE}.man
|
||||
DESTINATION ${FLTK_MANDIR}/man${LEVEL}
|
||||
RENAME ${FILE}.${LEVEL}
|
||||
)
|
||||
endmacro(INSTALL_MAN FILE LEVEL)
|
||||
|
||||
if(FLTK_BUILD_TEST AND FLTK_BUILD_FLUID)
|
||||
# Don't (!) install man pages of games (GitHub issue #23)
|
||||
# INSTALL_MAN (blocks 6)
|
||||
# INSTALL_MAN (checkers 6)
|
||||
# INSTALL_MAN (sudoku 6)
|
||||
if(FLTK_BUILD_FLUID)
|
||||
INSTALL_MAN (fluid 1)
|
||||
endif(FLTK_BUILD_FLUID)
|
||||
if(FLTK_BUILD_FLTK_OPTIONS)
|
||||
INSTALL_MAN (fltk-options 1)
|
||||
endif(FLTK_BUILD_FLTK_OPTIONS)
|
||||
INSTALL_MAN (fltk-config 1)
|
||||
INSTALL_MAN (fltk 3)
|
||||
|
||||
# Install the games
|
||||
|
||||
if(FLTK_BUILD_TEST) # "OR FLTK_BUILD_GAMES" (not yet implemented)
|
||||
|
||||
set(games_ blocks checkers sudoku)
|
||||
if(FLTK_USE_GL)
|
||||
list(APPEND games_ glpuzzle)
|
||||
endif()
|
||||
|
||||
endif(UNIX OR MSYS OR MINGW)
|
||||
foreach(game_ ${games_})
|
||||
if(FLTK_BUILD_SHARED_LIBS)
|
||||
set(tgt_ "${game_}-shared")
|
||||
set_target_properties(${tgt_} PROPERTIES RUNTIME_OUTPUT_NAME ${game_})
|
||||
else()
|
||||
set(tgt_ ${game_})
|
||||
endif()
|
||||
install(TARGETS ${tgt_}
|
||||
EXPORT FLTK-Targets
|
||||
RUNTIME DESTINATION ${FLTK_BINDIR}
|
||||
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
||||
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
||||
BUNDLE DESTINATION ${FLTK_BINDIR} # macOS: bundles
|
||||
)
|
||||
# install man page
|
||||
INSTALL_MAN (${game_} 6)
|
||||
endforeach()
|
||||
unset(game_)
|
||||
unset(games_)
|
||||
endif()
|
||||
|
||||
@@ -163,6 +163,52 @@ unset(debug_build)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
#######################################################################
|
||||
# MSVC only: build a special object library for shared libs
|
||||
#######################################################################
|
||||
|
||||
# When linking programs against the shared FLTK libraries we need to
|
||||
# compile and link with fl_call_main.c, but this must not be compiled
|
||||
# with macro FL_DLL, whereas all the other source file(s) *must* be
|
||||
# compiled with macro FL_DLL to link against the shared libs.
|
||||
# The latter is ensured by CMake properties of the shared libraries.
|
||||
#
|
||||
# Solution: build an extra object library with just this one file and
|
||||
# link all the "shared" executables additionally against this object
|
||||
# library to resolve the symbol 'WinMain()'.
|
||||
#
|
||||
# The object library is called 'call_main' and is available for fluid,
|
||||
# fltk-options, and all test programs that link against shared FLTK
|
||||
# libraries when using MSVC (Microsoft Visual Studio).
|
||||
#
|
||||
# ;-) I *love* Visual Studio ;-)
|
||||
|
||||
if(FLTK_BUILD_SHARED_LIBS AND MSVC)
|
||||
add_library(call_main OBJECT EXCLUDE_FROM_ALL src/fl_call_main.c)
|
||||
endif()
|
||||
|
||||
#######################################################################
|
||||
# set CMAKE_INSTALL_RPATH for shared libraries on macOS before
|
||||
# building executables. This assumes standard install locations like
|
||||
# - prefix/bin executable (path part 2) or bundle (path part 3)
|
||||
# - prefix/lib shared library
|
||||
# These RPATH settings are effective when executables and shared libs
|
||||
# are *installed*, they don't affect executables in the build folder.
|
||||
# Affected executables (when linked against the shared FLTK libs):
|
||||
# - fluid
|
||||
# - fltk-options
|
||||
# - test/* (e.g. games)
|
||||
# Note: Path part 1 ("@loader_path") is used to find shared libraries
|
||||
# in the same folder as the executable file (everywhere).
|
||||
#######################################################################
|
||||
|
||||
if(FLTK_BUILD_SHARED_LIBS AND APPLE AND NOT FLTK_BACKEND_X11)
|
||||
set(CMAKE_INSTALL_RPATH
|
||||
@loader_path
|
||||
@loader_path/../lib
|
||||
@loader_path/../../../../lib)
|
||||
endif()
|
||||
|
||||
#######################################################################
|
||||
# build fluid (optional)
|
||||
#######################################################################
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# CMakeLists.txt to build fltk-options for the FLTK project using CMake (www.cmake.org)
|
||||
#
|
||||
# Copyright 2023-2024 by Bill Spitzak and others.
|
||||
# Copyright 2023-2025 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
|
||||
@@ -15,46 +15,95 @@
|
||||
#
|
||||
|
||||
# Targets that will be built: fltk-options and fltk-options-cmd (Windows)
|
||||
set(TARGETS fltk-options)
|
||||
set(TARGETS "")
|
||||
|
||||
if(APPLE AND NOT FLTK_BACKEND_X11)
|
||||
|
||||
# macOS
|
||||
|
||||
set(BACKEND_APPLE TRUE)
|
||||
set(ICON_NAME fltk-options.icns)
|
||||
set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}")
|
||||
add_executable(fltk-options MACOSX_BUNDLE fltk-options.cxx ${ICON_PATH})
|
||||
|
||||
# create macOS bundle wrapper script
|
||||
|
||||
set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fltk-options")
|
||||
add_custom_command(
|
||||
TARGET fltk-options POST_BUILD
|
||||
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER}
|
||||
COMMAND chmod u+x,g+x,o+x ${WRAPPER}
|
||||
BYPRODUCTS ${WRAPPER}
|
||||
VERBATIM
|
||||
)
|
||||
unset(WRAPPER)
|
||||
|
||||
list(APPEND SOURCES ${ICON_PATH})
|
||||
else()
|
||||
|
||||
# Option WIN32 builds a Windows GUI program, ignored on other platforms
|
||||
add_executable(fltk-options WIN32 fltk-options.cxx)
|
||||
|
||||
set(BACKEND_APPLE FALSE)
|
||||
set(ICON_NAME "")
|
||||
set(ICON_PATH "")
|
||||
endif()
|
||||
|
||||
target_link_libraries(fltk-options PRIVATE fltk::fltk)
|
||||
set_target_properties(fltk-options PROPERTIES EXPORT_NAME options)
|
||||
# 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.
|
||||
|
||||
macro(make_target TARGET GUI SOURCES LIBS EXPORT_NAME)
|
||||
|
||||
if(ICON_PATH)
|
||||
list(APPEND SOURCES ${ICON_PATH}) # macOS only
|
||||
endif()
|
||||
|
||||
# message(STATUS "[fltk-options] make_target ${TARGET} ${GUI} ${SOURCES} ${LIBS} ${EXPORT_NAME}")
|
||||
|
||||
# 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})
|
||||
|
||||
list(APPEND TARGETS ${TARGET})
|
||||
|
||||
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})
|
||||
|
||||
endmacro(make_target TARGET GUI LIBS EXPORT_NAME)
|
||||
|
||||
set(SOURCES fltk-options.cxx)
|
||||
|
||||
make_target(fltk-options TRUE "${SOURCES}" fltk::fltk options)
|
||||
|
||||
# Add the console app (Windows only)
|
||||
# This is done for all Windows targets, even if cross-compiling.
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND TARGETS fltk-options-cmd)
|
||||
add_executable(fltk-options-cmd fltk-options.cxx)
|
||||
target_link_libraries(fltk-options-cmd PRIVATE fltk::fltk)
|
||||
set_target_properties(fltk-options-cmd PROPERTIES EXPORT_NAME options-cmd)
|
||||
make_target(fltk-options-cmd FALSE "${SOURCES}" fltk::fltk options-cmd)
|
||||
endif()
|
||||
|
||||
# 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'.
|
||||
|
||||
if(FLTK_BUILD_SHARED_LIBS)
|
||||
if(MSVC)
|
||||
set(libs fltk::fltk-shared call_main)
|
||||
else()
|
||||
set(libs fltk::fltk-shared)
|
||||
endif()
|
||||
make_target(fltk-options-shared TRUE "${SOURCES}" "${libs}" options-shared)
|
||||
endif()
|
||||
|
||||
# Create aliases for all executables,
|
||||
@@ -68,29 +117,8 @@ endforeach()
|
||||
|
||||
# Install fltk-options GUI and commandline tool
|
||||
|
||||
if(APPLE AND NOT FLTK_BACKEND_X11)
|
||||
|
||||
# On macOS, fltk-options will be installed twice:
|
||||
# - The bundled version goes into the destination folder ${FLTK_BINDIR}.
|
||||
# - The binary without bundle goes into ${FLTK_BINDIR} as well.
|
||||
# These folders are relative to the install prefix, usually 'bin'.
|
||||
# The command line tool is the same executable as the one included in the bundle.
|
||||
# Note:
|
||||
# Both the bundle and the commandline tool are currently installed side by side.
|
||||
# This may be changed in the future.
|
||||
|
||||
# set bundle properties
|
||||
set_target_properties(fltk-options PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/fltk-options.plist")
|
||||
set_target_properties(fltk-options PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
|
||||
set_target_properties(fltk-options PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fltk-options")
|
||||
|
||||
# install command line tool
|
||||
install(PROGRAMS $<TARGET_FILE:fltk-options>
|
||||
DESTINATION ${FLTK_BINDIR})
|
||||
|
||||
endif(APPLE AND NOT FLTK_BACKEND_X11)
|
||||
|
||||
# Install the GUI and (on Windows only) the commandline tool 'fltk-options-cmd'
|
||||
# message(STATUS "fltk-options: INSTALL TARGETS: ${TARGETS}")
|
||||
|
||||
install(TARGETS ${TARGETS}
|
||||
EXPORT FLTK-Targets
|
||||
|
||||
34
fltk-options/fltk-options-shared.plist
Normal file
34
fltk-options/fltk-options-shared.plist
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>fltk-options-shared</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.fltk.fltk-options</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.5.0</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright 2023-2025 by Bill Spitzak and others</string>
|
||||
<key>CFAppleHelpAnchor</key>
|
||||
<string>help</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>fltk-options</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>FLOP</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>fltk-options.icns</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.5.0</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>1.5.0, Copyright 2023-2025 by Bill Spitzak and others</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -15,12 +15,88 @@
|
||||
#
|
||||
|
||||
# Targets that will be built: fluid and fluid-cmd (Windows)
|
||||
set(TARGETS fluid)
|
||||
|
||||
# Source files for 'fluid-lib' = all source files except the main files
|
||||
# (main.cxx and main.h)
|
||||
# Note: macOS (Xcode) needs at least one source file (main.cxx) to link the main
|
||||
# program fluid properly
|
||||
# Targets that will be built: fluid, fluid-shared, and fluid-cmd (Windows only)
|
||||
set(TARGETS "")
|
||||
|
||||
# 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.
|
||||
|
||||
macro(make_target TARGET GUI SOURCES LIBS EXPORT_NAME)
|
||||
|
||||
if(ICON_PATH)
|
||||
list(APPEND SOURCES ${ICON_PATH}) # macOS only
|
||||
endif()
|
||||
|
||||
# message(STATUS "[fluid] make_target ${TARGET} ${GUI} ${SOURCES} ${LIBS} ${EXPORT_NAME}")
|
||||
|
||||
# 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})
|
||||
|
||||
list(APPEND TARGETS ${TARGET})
|
||||
|
||||
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})
|
||||
|
||||
endmacro(make_target TARGET GUI SOURCES LIBS EXPORT_NAME)
|
||||
|
||||
|
||||
# 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}
|
||||
|
||||
set(CPPFILES
|
||||
Fluid.cxx
|
||||
@@ -59,6 +135,7 @@ set(CPPFILES
|
||||
proj/mergeback.cxx
|
||||
proj/undo.cxx
|
||||
rsrcs/pixmaps.cxx
|
||||
tools/ExternalCodeEditor_${SUFFIX}.cxx
|
||||
tools/autodoc.cxx
|
||||
tools/filename.cxx
|
||||
widgets/App_Menu_Bar.cxx
|
||||
@@ -111,6 +188,7 @@ set(HEADERFILES
|
||||
proj/undo.h
|
||||
rsrcs/comments.h
|
||||
rsrcs/pixmaps.h
|
||||
tools/ExternalCodeEditor_${SUFFIX}.h
|
||||
tools/autodoc.h
|
||||
tools/filename.h
|
||||
widgets/App_Menu_Bar.h
|
||||
@@ -123,18 +201,6 @@ set(HEADERFILES
|
||||
widgets/Node_Browser.h
|
||||
)
|
||||
|
||||
set(MAIN_FILES main.cxx main.h)
|
||||
|
||||
# Add ExternalCodeEditor: platform specific files
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND CPPFILES tools/ExternalCodeEditor_WIN32.cxx)
|
||||
list(APPEND HEADERFILES tools/ExternalCodeEditor_WIN32.h)
|
||||
else()
|
||||
list(APPEND CPPFILES tools/ExternalCodeEditor_UNIX.cxx)
|
||||
list(APPEND HEADERFILES tools/ExternalCodeEditor_UNIX.h)
|
||||
endif(WIN32)
|
||||
|
||||
source_group(
|
||||
TREE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
@@ -155,47 +221,49 @@ target_link_libraries(fluid-lib PUBLIC fltk::images)
|
||||
|
||||
# Build targets
|
||||
|
||||
if(APPLE AND NOT FLTK_BACKEND_X11)
|
||||
|
||||
# macOS
|
||||
|
||||
set(ICON_NAME fluid.icns)
|
||||
set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}")
|
||||
add_executable(fluid MACOSX_BUNDLE ${MAIN_FILES} ${ICON_PATH})
|
||||
|
||||
# create macOS bundle wrapper script
|
||||
|
||||
set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fluid")
|
||||
add_custom_command(
|
||||
TARGET fluid POST_BUILD
|
||||
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER}
|
||||
COMMAND chmod u+x,g+x,o+x ${WRAPPER}
|
||||
BYPRODUCTS ${WRAPPER}
|
||||
VERBATIM
|
||||
)
|
||||
unset(WRAPPER)
|
||||
|
||||
else()
|
||||
|
||||
# Option 'WIN32' builds a Windows GUI program, ignored on other platforms
|
||||
add_executable(fluid WIN32 ${MAIN_FILES})
|
||||
|
||||
endif()
|
||||
|
||||
target_link_libraries(fluid PRIVATE fluid-lib)
|
||||
make_target(fluid TRUE "${MAIN_FILES}" fluid-lib fluid)
|
||||
|
||||
# Build the console app on Windows
|
||||
# This is done for all Windows targets, even if cross-compiling.
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND TARGETS fluid-cmd)
|
||||
add_executable(fluid-cmd ${MAIN_FILES})
|
||||
target_link_libraries(fluid-cmd PRIVATE fluid-lib)
|
||||
make_target(fluid-cmd FALSE "${MAIN_FILES}" fluid-lib fluid-cmd)
|
||||
set(FLTK_FLUID_EXECUTABLE fltk::fluid-cmd)
|
||||
else()
|
||||
set(FLTK_FLUID_EXECUTABLE fltk::fluid)
|
||||
endif()
|
||||
|
||||
# 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'.
|
||||
|
||||
if(FLTK_BUILD_SHARED_LIBS)
|
||||
|
||||
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)
|
||||
make_target(fluid-shared TRUE "${MAIN_FILES}" "fluid-lib-shared;call_main" fluid-shared)
|
||||
else()
|
||||
make_target(fluid-shared TRUE "${MAIN_FILES}" fluid-lib-shared fluid-shared)
|
||||
endif()
|
||||
|
||||
# experimental
|
||||
# if(NOT WIN32)
|
||||
# set(FLTK_FLUID_EXECUTABLE fltk::fluid-shared)
|
||||
# message(STATUS "** experimental ** FLTK_FLUID_EXECUTABLE = ${FLTK_FLUID_EXECUTABLE}")
|
||||
# endif()
|
||||
|
||||
endif(FLTK_BUILD_SHARED_LIBS)
|
||||
|
||||
# export the variable FLTK_FLUID_EXECUTABLE to the parent scope
|
||||
|
||||
set(FLTK_FLUID_EXECUTABLE "${FLTK_FLUID_EXECUTABLE}" PARENT_SCOPE)
|
||||
|
||||
# Create aliases for all targets
|
||||
@@ -204,30 +272,8 @@ foreach(tgt ${TARGETS})
|
||||
add_executable(fltk::${tgt} ALIAS ${tgt})
|
||||
endforeach()
|
||||
|
||||
# Install fluid GUI and commandline tool
|
||||
|
||||
if(APPLE AND NOT FLTK_BACKEND_X11)
|
||||
|
||||
# On macOS, fluid will be installed twice:
|
||||
# - The bundled version of Fluid goes into the destination folder ${FLTK_BINDIR}.
|
||||
# - The binary without bundle goes into ${FLTK_BINDIR} as well.
|
||||
# The command line tool is the same executable as the one included in the bundle.
|
||||
# Note:
|
||||
# Both the bundle and the commandline tool are currently installed side by side.
|
||||
# This may be changed in the future.
|
||||
|
||||
# Set bundle properties
|
||||
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})
|
||||
set_target_properties(fluid PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fluid")
|
||||
|
||||
# Install command line tool
|
||||
install(PROGRAMS $<TARGET_FILE:fluid>
|
||||
DESTINATION ${FLTK_BINDIR})
|
||||
|
||||
endif(APPLE AND NOT FLTK_BACKEND_X11)
|
||||
|
||||
# Install the GUI and (on Windows only) the commandline tool 'fluid-cmd'
|
||||
# message(STATUS "Fluid: INSTALL TARGETS: ${TARGETS}")
|
||||
|
||||
install(TARGETS ${TARGETS}
|
||||
EXPORT FLTK-Targets
|
||||
|
||||
53
fluid/fluid-shared.plist
Normal file
53
fluid/fluid-shared.plist
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>fluid-shared</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.fltk.fluid</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.5.0</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright 1998-2025 by Bill Spitzak and others</string>
|
||||
<key>CFAppleHelpAnchor</key>
|
||||
<string>help</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Fluid</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>FLID</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>fluid.icns</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.5.0</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>1.5.0, Copyright 1998-2025 by Bill Spitzak and others</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>fl</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>fluid.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>FLUID Designer File</string>
|
||||
<key>CFBundleTypeOSTypes</key>
|
||||
<array>
|
||||
<string>Flid</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# CMakeLists.txt used to build test and demo apps by the CMake build system
|
||||
#
|
||||
# Copyright 2004-2024 by Bill Spitzak and others.
|
||||
# Copyright 2004-2025 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,14 +84,12 @@ fl_create_example(arc arc.cxx fltk::fltk)
|
||||
fl_create_example(animated animated.cxx fltk::fltk)
|
||||
fl_create_example(ask ask.cxx fltk::fltk)
|
||||
fl_create_example(bitmap bitmap.cxx fltk::fltk)
|
||||
fl_create_example(blocks "blocks.cxx;blocks.plist;blocks.icns" "fltk::fltk;${AUDIOLIBS}")
|
||||
fl_create_example(boxtype boxtype.cxx fltk::fltk)
|
||||
fl_create_example(browser browser.cxx fltk::fltk)
|
||||
fl_create_example(button button.cxx fltk::fltk)
|
||||
fl_create_example(buttons buttons.cxx fltk::fltk)
|
||||
# Cairo demo, built with and w/o Cairo (libcairo is linked implicitly - or not at all)
|
||||
fl_create_example(cairo_test cairo_test.cxx fltk::fltk)
|
||||
fl_create_example(checkers "checkers.cxx;checkers_pieces.fl;checkers.icns" fltk::images)
|
||||
fl_create_example(clipboard clipboard.cxx fltk::images)
|
||||
fl_create_example(clock clock.cxx fltk::fltk)
|
||||
fl_create_example(colbrowser colbrowser.cxx fltk::fltk)
|
||||
@@ -161,7 +159,6 @@ fl_create_example(resize-example5c "resize-example5c.cxx;resize-arrows.cxx" fltk
|
||||
fl_create_example(rotated_text rotated_text.cxx fltk::fltk)
|
||||
fl_create_example(scroll scroll.cxx fltk::fltk)
|
||||
fl_create_example(subwindow subwindow.cxx fltk::fltk)
|
||||
fl_create_example(sudoku "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk::images;${AUDIOLIBS}")
|
||||
fl_create_example(symbols symbols.cxx fltk::fltk)
|
||||
fl_create_example(tabs tabs.fl fltk::fltk)
|
||||
fl_create_example(table table.cxx fltk::fltk)
|
||||
@@ -176,6 +173,14 @@ fl_create_example(valuators valuators.fl fltk::fltk)
|
||||
fl_create_example(windowfocus windowfocus.cxx fltk::fltk)
|
||||
fl_create_example(wizard wizard.cxx fltk::fltk)
|
||||
|
||||
# games
|
||||
|
||||
if(NOT FLTK_BUILD_SHARED_LIBS)
|
||||
fl_create_example(blocks "blocks.cxx;blocks.plist;blocks.icns" "fltk::fltk;${AUDIOLIBS}")
|
||||
fl_create_example(checkers "checkers.cxx;checkers_pieces.fl;checkers.icns" fltk::images)
|
||||
fl_create_example(sudoku "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk::images;${AUDIOLIBS}")
|
||||
endif()
|
||||
|
||||
# unittests uses multiple source files and can be built with or w/o OpenGL and "shared"
|
||||
|
||||
SET (UNITTEST_SRCS
|
||||
@@ -213,7 +218,9 @@ if(OPENGL_FOUND)
|
||||
fl_create_example(cube cube.cxx "${GLDEMO_LIBS}")
|
||||
fl_create_example(fractals "fractals.cxx;fracviewer.cxx" "${GLDEMO_LIBS}")
|
||||
fl_create_example(glut_test glut_test.cxx "${GLDEMO_LIBS}")
|
||||
fl_create_example(glpuzzle glpuzzle.cxx "${GLDEMO_LIBS}")
|
||||
if(NOT FLTK_BUILD_SHARED_LIBS)
|
||||
fl_create_example(glpuzzle glpuzzle.cxx "${GLDEMO_LIBS}")
|
||||
endif()
|
||||
fl_create_example(gl_overlay gl_overlay.cxx "${GLDEMO_LIBS}")
|
||||
fl_create_example(shape shape.cxx "${GLDEMO_LIBS}")
|
||||
endif(OPENGL_FOUND)
|
||||
@@ -268,51 +275,29 @@ if(CMAKE_CXX_COMPILER_ID IN_LIST _compilers)
|
||||
endif() # GNU or Clang (-Wshadow test)
|
||||
unset(_compilers)
|
||||
|
||||
|
||||
# *** EXPERIMENTAL ***
|
||||
# Build some of the demo programs linked against the shared FLTK lib(s).
|
||||
# This is currently pretty complicated and should be improved.
|
||||
# It will be simplified significantly when we use more "modern CMake".
|
||||
|
||||
if(FLTK_BUILD_SHARED_LIBS)
|
||||
|
||||
if(MSVC) # MS Visual C++ aka. Visual Studio
|
||||
|
||||
# We need to link with fl_call_main.c, but this must not be compiled with
|
||||
# macro FL_DLL, whereas the other source file(s) must be compiled with FL_DLL
|
||||
# to link against the shared libs.
|
||||
#
|
||||
# ;-) I *love* Visual Studio (MSVC) ;-)
|
||||
#
|
||||
# Trick: build an object library with just this one file and link the executable
|
||||
# against the shared library plus this object library. Another way would be to
|
||||
# add the extra source file fl_call_main.c to the source files of all targets
|
||||
# and set the FL_DLL compile_definition property only on the main *source* files
|
||||
# but this doesn't work since the same file must be compiled for the "static"
|
||||
# and the "shared" target, for instance hello.cxx for "hello" and "hello-shared".
|
||||
# We need to link with fl_call_main.c which is available as an object
|
||||
# library 'call_main' when built with MSVC (see main CMakeLists.txt).
|
||||
|
||||
add_library (CALL_MAIN OBJECT EXCLUDE_FROM_ALL ../src/fl_call_main.c)
|
||||
fl_create_example(hello-shared hello.cxx "call_main;fltk::fltk-shared")
|
||||
fl_create_example(pixmap_browser-shared pixmap_browser.cxx "call_main;fltk::fltk-shared")
|
||||
fl_create_example(unittests-shared "${UNITTEST_SRCS}" "call_main;${GLDEMO_SHARED}")
|
||||
|
||||
# define a list of shared targets so we can set COMPILE_DEFINITIONS in a loop
|
||||
set(SHARED_TARGETS "")
|
||||
|
||||
fl_create_example(hello-shared hello.cxx "CALL_MAIN;fltk::fltk-shared")
|
||||
fl_create_example(pixmap_browser-shared pixmap_browser.cxx "CALL_MAIN;fltk::fltk-shared")
|
||||
fl_create_example(unittests-shared "${UNITTEST_SRCS}" "CALL_MAIN;${GLDEMO_SHARED}")
|
||||
|
||||
list(APPEND SHARED_TARGETS hello pixmap_browser unittests)
|
||||
# Games
|
||||
fl_create_example(blocks-shared "blocks.cxx;blocks.plist;blocks.icns" "call_main;fltk::fltk-shared;${AUDIOLIBS}")
|
||||
fl_create_example(checkers-shared "checkers.cxx;checkers_pieces.fl;checkers.icns" "call_main;fltk::fltk-shared")
|
||||
fl_create_example(sudoku-shared "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "call_main;fltk::fltk-shared;${AUDIOLIBS}")
|
||||
|
||||
if(OPENGL_FOUND)
|
||||
fl_create_example(glpuzzle-shared glpuzzle.cxx "CALL_MAIN;${GLDEMO_SHARED}")
|
||||
fl_create_example(shape-shared shape.cxx "CALL_MAIN;${GLDEMO_SHARED}")
|
||||
list(APPEND SHARED_TARGETS glpuzzle shape)
|
||||
fl_create_example(glpuzzle-shared glpuzzle.cxx "call_main;${GLDEMO_SHARED}")
|
||||
fl_create_example(shape-shared shape.cxx "call_main;${GLDEMO_SHARED}")
|
||||
endif(OPENGL_FOUND)
|
||||
|
||||
# apply property COMPILE_DEFINITIONS "-D FL_DLL" in a loop for all necessary source files
|
||||
foreach(tgt ${SHARED_TARGETS})
|
||||
target_compile_definitions (${tgt}-shared PRIVATE "FL_DLL")
|
||||
endforeach()
|
||||
|
||||
else() # not MSVC
|
||||
|
||||
fl_create_example(cairo_test-shared cairo_test.cxx fltk::fltk-shared)
|
||||
@@ -320,12 +305,16 @@ if(FLTK_BUILD_SHARED_LIBS)
|
||||
fl_create_example(pixmap_browser-shared pixmap_browser.cxx fltk::images-shared)
|
||||
fl_create_example(unittests-shared "${UNITTEST_SRCS}" "${GLDEMO_SHARED}")
|
||||
|
||||
# Games
|
||||
fl_create_example(blocks-shared "blocks.cxx;blocks.plist;blocks.icns" "fltk::fltk-shared;${AUDIOLIBS}")
|
||||
fl_create_example(checkers-shared "checkers.cxx;checkers_pieces.fl;checkers.icns" fltk::images-shared)
|
||||
fl_create_example(sudoku-shared "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk::images-shared;${AUDIOLIBS}")
|
||||
|
||||
if(OPENGL_FOUND)
|
||||
fl_create_example(glpuzzle-shared glpuzzle.cxx "${GLDEMO_SHARED}")
|
||||
fl_create_example(shape-shared shape.cxx "${GLDEMO_SHARED}")
|
||||
endif(OPENGL_FOUND)
|
||||
|
||||
|
||||
endif(MSVC) # (not MSVC)
|
||||
|
||||
endif(FLTK_BUILD_SHARED_LIBS)
|
||||
|
||||
Reference in New Issue
Block a user