2023-01-21 19:14:41 +03:00
|
|
|
#
|
|
|
|
# CMakeLists.txt to build fltk-options for the FLTK project using CMake (www.cmake.org)
|
|
|
|
#
|
2024-02-07 20:30:11 +03:00
|
|
|
# Copyright 2023-2024 by Bill Spitzak and others.
|
2023-01-21 19:14:41 +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
|
|
|
# Targets that will be built: fltk-options and fltk-options-cmd (Windows)
|
|
|
|
set(TARGETS fltk-options)
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
if(APPLE AND NOT FLTK_BACKEND_X11)
|
2023-01-21 19:14:41 +03:00
|
|
|
|
|
|
|
# macOS
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
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})
|
2023-01-21 19:14:41 +03:00
|
|
|
|
|
|
|
# create macOS bundle wrapper script
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fltk-options")
|
|
|
|
add_custom_command(
|
2023-01-21 19:14:41 +03:00
|
|
|
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
|
|
|
|
)
|
2024-02-07 20:30:11 +03:00
|
|
|
unset(WRAPPER)
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
else()
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
# Option WIN32 builds a Windows GUI program, ignored on other platforms
|
|
|
|
add_executable(fltk-options WIN32 fltk-options.cxx)
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
endif()
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
target_link_libraries(fltk-options PRIVATE fltk::fltk)
|
2024-02-10 16:19:09 +03:00
|
|
|
set_target_properties(fltk-options PROPERTIES EXPORT_NAME options)
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
# Add the console app (Windows only)
|
2023-01-21 19:14:41 +03:00
|
|
|
# This is done for all Windows targets, even if cross-compiling.
|
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
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)
|
2024-02-10 16:19:09 +03:00
|
|
|
set_target_properties(fltk-options-cmd PROPERTIES EXPORT_NAME options-cmd)
|
2024-02-07 20:30:11 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Create aliases for all executables,
|
|
|
|
# replacing 'fltk-options' with 'fltk::options'
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
foreach(tgt ${TARGETS})
|
|
|
|
string(REPLACE "fltk-options" "fltk::options" alias ${tgt})
|
|
|
|
add_executable(${alias} ALIAS ${tgt})
|
|
|
|
unset(alias)
|
|
|
|
endforeach()
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
# Install fltk-options GUI and commandline tool
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
if(APPLE AND NOT FLTK_BACKEND_X11)
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-14 19:06:10 +03:00
|
|
|
# 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
|
2024-02-07 20:30:11 +03:00
|
|
|
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")
|
2023-01-21 19:14:41 +03:00
|
|
|
|
|
|
|
# install command line tool
|
2024-02-14 19:06:10 +03:00
|
|
|
install(PROGRAMS $<TARGET_FILE:fltk-options>
|
|
|
|
DESTINATION ${FLTK_BINDIR})
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-14 19:06:10 +03:00
|
|
|
endif(APPLE AND NOT FLTK_BACKEND_X11)
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-14 19:06:10 +03:00
|
|
|
# Install the GUI and (on Windows only) the commandline tool 'fltk-options-cmd'
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-14 19:06:10 +03:00
|
|
|
install(TARGETS ${TARGETS}
|
|
|
|
EXPORT FLTK-Targets
|
|
|
|
RUNTIME DESTINATION ${FLTK_BINDIR}
|
|
|
|
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
|
|
|
BUNDLE DESTINATION ${FLTK_BINDIR} # macOS: bundles
|
|
|
|
)
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
# Install desktop files
|
2023-01-21 19:14:41 +03:00
|
|
|
|
2024-02-07 20:30:11 +03:00
|
|
|
if(UNIX)
|
|
|
|
install(FILES fltk-options.desktop
|
2023-01-21 19:14:41 +03:00
|
|
|
DESTINATION ${FLTK_DATADIR}/applications
|
|
|
|
)
|
2024-02-07 20:30:11 +03:00
|
|
|
# Install mime-type file(x-fltk-options.desktop method is deprecated)
|
|
|
|
install(FILES fltk-options.xml
|
2023-01-21 19:14:41 +03:00
|
|
|
DESTINATION ${FLTK_DATADIR}/mime/packages
|
|
|
|
)
|
|
|
|
|
|
|
|
# Install desktop icons
|
2024-02-07 20:30:11 +03:00
|
|
|
foreach(icon 32 48 64 128)
|
|
|
|
install(FILES icons/fltk-options-${icon}.png
|
2023-01-21 19:14:41 +03:00
|
|
|
DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps
|
|
|
|
RENAME fltk-options.png
|
|
|
|
)
|
|
|
|
endforeach()
|
2024-02-07 20:30:11 +03:00
|
|
|
endif(UNIX)
|