mirror of https://github.com/fltk/fltk
CMake: fix installation on macOS
fluid and fltk-options are now installed correctly as bundles and as stand-alone executables side by side in the 'bin' folder relative to CMAKE_INSTALL_PREFIX. This works but the installation folders may be changed in the future. Targets fltk::fluid is now exported correctly so find_package(FLTK CONFIG ...) works with both the build folder and an installed version.
This commit is contained in:
parent
cd3cb62770
commit
7992b0b9ab
|
@ -70,11 +70,16 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# generate FLTK-Targets.cmake for build directory use
|
# generate FLTK-Targets.cmake for build directory use
|
||||||
|
set(export_targets
|
||||||
|
${FLTK_LIBRARIES}
|
||||||
|
${FLTK_LIBRARIES_SHARED}
|
||||||
|
${FLUID_EXPORT}
|
||||||
|
${FLTK_OPTIONS_EXPORT}
|
||||||
|
)
|
||||||
|
message(STATUS "export.cmake: exporting targets...")
|
||||||
|
fl_debug_var(export_targets)
|
||||||
export(TARGETS
|
export(TARGETS
|
||||||
${FLTK_LIBRARIES}
|
${export_targets}
|
||||||
${FLTK_LIBRARIES_SHARED}
|
|
||||||
${FLUID_EXPORT}
|
|
||||||
${FLTK_OPTIONS_EXPORT}
|
|
||||||
FILE
|
FILE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/FLTK-Targets.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/FLTK-Targets.cmake
|
||||||
NAMESPACE
|
NAMESPACE
|
||||||
|
|
|
@ -70,43 +70,36 @@ endforeach()
|
||||||
|
|
||||||
if(APPLE AND NOT FLTK_BACKEND_X11)
|
if(APPLE AND NOT FLTK_BACKEND_X11)
|
||||||
|
|
||||||
# On macOS, fltk-options must be installed twice. The bundled version of
|
# On macOS, fltk-options will be installed twice:
|
||||||
# fltk-options needs to go into the /Applications folder to make it visible
|
# - The bundled version goes into the destination folder ${FLTK_BINDIR}.
|
||||||
# as a user App with full GUI.
|
# - The binary without bundle goes into ${FLTK_BINDIR} as well.
|
||||||
# The binary without bundle should go into ${FLTK_BINDIR}, usually
|
# These folders are relative to the install prefix, usually 'bin'.
|
||||||
# /usr/local/bin, so it will be picked up as a command line tool by
|
# The command line tool is the same executable as the one included in the bundle.
|
||||||
# the build process of other apps.
|
# Note:
|
||||||
# On macOS the command line tool is the same target ('fltk-options') as the
|
# Both the bundle and the commandline tool are currently installed side by side.
|
||||||
# one included in the bundle.
|
# This may be changed in the future.
|
||||||
|
|
||||||
# create bundle
|
# 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_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 MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
|
||||||
set_target_properties(fltk-options PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fltk-options")
|
set_target_properties(fltk-options PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fltk-options")
|
||||||
|
|
||||||
# The line below would wrongly install /Applications/fltk-options.icns
|
|
||||||
# ## set_target_properties(fltk-options PROPERTIES RESOURCE ${ICON_PATH})
|
|
||||||
|
|
||||||
# install fltk-options GUI and commandline tools
|
|
||||||
# install(TARGETS fltk-options DESTINATION "/Applications")
|
|
||||||
|
|
||||||
# install command line tool
|
# install command line tool
|
||||||
install(PROGRAMS $<TARGET_FILE:fltk-options> DESTINATION ${FLTK_BINDIR})
|
install(PROGRAMS $<TARGET_FILE:fltk-options>
|
||||||
|
DESTINATION ${FLTK_BINDIR})
|
||||||
else()
|
|
||||||
|
|
||||||
# install fltk-options GUI and optional commandline tool 'fltk-options-cmd'
|
|
||||||
# (only on Windows)
|
|
||||||
|
|
||||||
install(TARGETS ${TARGETS}
|
|
||||||
EXPORT FLTK-Targets
|
|
||||||
RUNTIME DESTINATION ${FLTK_BINDIR}
|
|
||||||
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
|
||||||
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
endif(APPLE AND NOT FLTK_BACKEND_X11)
|
endif(APPLE AND NOT FLTK_BACKEND_X11)
|
||||||
|
|
||||||
|
# Install the GUI and (on Windows only) the commandline tool 'fltk-options-cmd'
|
||||||
|
|
||||||
|
install(TARGETS ${TARGETS}
|
||||||
|
EXPORT FLTK-Targets
|
||||||
|
RUNTIME DESTINATION ${FLTK_BINDIR}
|
||||||
|
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
||||||
|
BUNDLE DESTINATION ${FLTK_BINDIR} # macOS: bundles
|
||||||
|
)
|
||||||
|
|
||||||
# Install desktop files
|
# Install desktop files
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
|
|
@ -194,41 +194,35 @@ endforeach()
|
||||||
|
|
||||||
if(APPLE AND NOT FLTK_BACKEND_X11)
|
if(APPLE AND NOT FLTK_BACKEND_X11)
|
||||||
|
|
||||||
# On macOS, Fluid must be installed twice. The bundled version of Fluid needs
|
# On macOS, fluid will be installed twice:
|
||||||
# to go into the /Applications folder to make it visible as a user App with
|
# - The bundled version of Fluid goes into the destination folder ${FLTK_BINDIR}.
|
||||||
# full GUI. The binary without bundle should go into ${FLTK_BINDIR}, usually
|
# - The binary without bundle goes into ${FLTK_BINDIR} as well.
|
||||||
# /usr/local/bin, so it will be picked up as a command line tool by
|
# The command line tool is the same executable as the one included in the bundle.
|
||||||
# the build process of other apps.
|
# Note:
|
||||||
# On macOS the command line tool is the same target ('fluid') as the one
|
# Both the bundle and the commandline tool are currently installed side by side.
|
||||||
# included in the bundle.
|
# This may be changed in the future.
|
||||||
|
|
||||||
# create bundle
|
# 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_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/fluid.plist")
|
||||||
set_target_properties(fluid PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
|
set_target_properties(fluid PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
|
||||||
set_target_properties(fluid PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fluid")
|
set_target_properties(fluid PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fluid")
|
||||||
|
|
||||||
# The line below would wrongly install /Applications/fluid.icns
|
# Install command line tool
|
||||||
# ## set_target_properties(fluid PROPERTIES RESOURCE ${ICON_PATH})
|
install(PROGRAMS $<TARGET_FILE:fluid>
|
||||||
|
DESTINATION ${FLTK_BINDIR})
|
||||||
# install fluid GUI and commandline tools
|
|
||||||
# install(TARGETS fluid DESTINATION "/Applications")
|
|
||||||
|
|
||||||
# install command line tool
|
|
||||||
install(PROGRAMS $<TARGET_FILE:fluid> DESTINATION ${FLTK_BINDIR})
|
|
||||||
|
|
||||||
else()
|
|
||||||
|
|
||||||
# install Fluid GUI and optional commandline tool 'fluid-cmd' (only on Windows)
|
|
||||||
|
|
||||||
install(TARGETS ${TARGETS}
|
|
||||||
EXPORT FLTK-Targets
|
|
||||||
RUNTIME DESTINATION ${FLTK_BINDIR}
|
|
||||||
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
|
||||||
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
endif(APPLE AND NOT FLTK_BACKEND_X11)
|
endif(APPLE AND NOT FLTK_BACKEND_X11)
|
||||||
|
|
||||||
|
# Install the GUI and (on Windows only) the commandline tool 'fluid-cmd'
|
||||||
|
|
||||||
|
install(TARGETS ${TARGETS}
|
||||||
|
EXPORT FLTK-Targets
|
||||||
|
RUNTIME DESTINATION ${FLTK_BINDIR}
|
||||||
|
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
||||||
|
BUNDLE DESTINATION ${FLTK_BINDIR} # macOS: bundles
|
||||||
|
)
|
||||||
|
|
||||||
# Install desktop files
|
# Install desktop files
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
|
Loading…
Reference in New Issue