mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-30 20:04:53 -04:00
* CPack: Refactor AppImage and Apple DMG Generation * Switch from linuxdeployqt to linuxdelpoy * Add ARM64 AppImage support * Add support for `.run` installers using `makeself`, an alternative to AppImage * Refactor BashCompletion.cmake * Enable CPack debugging via `WANT_DEBUG_CPACK` * Add `download_binary`, `create_symlink` macros * Qt6: Fix @rpath bug on macOS * Detect and bundle LV2 UI Suil modules (Related #7201) * Allow remote plugins to honor `LMMS_PLUGIN_DIR` * Add .github/workflows/deps-ubuntu-24.04-gcc.txt * Fix waveforms FileDialog Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
79 lines
2.8 KiB
CMake
79 lines
2.8 KiB
CMake
# Copyright (c) 2024, Tres Finocchiaro, <tres.finocchiaro@gmail.com>
|
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
|
#
|
|
# Description:
|
|
# Fail-safe bash-completion installation support
|
|
# - Installs to ${CMAKE_INSTALL_PREFIX}/share/bash-completion/completions
|
|
# - Attempts to calculate and install to system-wide location
|
|
# - See also https://github.com/scop/bash-completion
|
|
#
|
|
# Usage:
|
|
# INCLUDE(BashCompletion)
|
|
# BASHCOMP_INSTALL(foo)
|
|
# ... where "foo" is a shell script adjacent to the CMakeLists.txt
|
|
|
|
# Honor manual override if provided
|
|
if(NOT BASHCOMP_PKG_PATH)
|
|
# First, use pkg-config, which is the most reliable
|
|
find_package(PkgConfig QUIET)
|
|
if(PKGCONFIG_FOUND)
|
|
PKG_CHECK_MODULES(BASH_COMPLETION bash-completion)
|
|
PKG_GET_VARIABLE(BASHCOMP_PKG_PATH bash-completion completionsdir)
|
|
else()
|
|
# Second, use cmake (preferred but less common)
|
|
find_package(bash-completion QUIET)
|
|
if(BASH_COMPLETION_FOUND)
|
|
set(BASHCOMP_PKG_PATH "${BASH_COMPLETION_COMPLETIONSDIR}")
|
|
endif()
|
|
endif()
|
|
|
|
# Third, use a hard-coded fallback value
|
|
if("${BASHCOMP_PKG_PATH}" STREQUAL "")
|
|
set(BASHCOMP_PKG_PATH "/usr/share/bash-completion/completions")
|
|
endif()
|
|
endif()
|
|
|
|
# Always provide a fallback for non-root INSTALL()
|
|
# * "lmms" subfolder ensures we don't pollute /usr/local/share/ on default "make install"
|
|
set(BASHCOMP_USER_PATH "share/${PROJECT_NAME}/bash-completion/completions")
|
|
|
|
macro(BASHCOMP_INSTALL SCRIPT_NAME)
|
|
# Note: When running from CPack, message(...) will be supressed unless WARNING
|
|
if(WIN32)
|
|
message(STATUS "Bash completion is not supported on this platform.")
|
|
else()
|
|
# Install a copy of bash completion to the default install prefix
|
|
# See also: https://github.com/LMMS/lmms/pull/7252/files#r1815749125
|
|
install(FILES "${SCRIPT_NAME}" DESTINATION "${BASHCOMP_USER_PATH}")
|
|
|
|
# Next, blindly attempt a system-wide install, ignoring failure
|
|
# See also: https://stackoverflow.com/q/58448332
|
|
# * CPack doesn't use CMAKE_INSTALL_PREFIX, so the original will be missing when packaging
|
|
# and this step will be skipped
|
|
# * For non-root installs (e.g. ../target), this will silently fail
|
|
set(BASHCOMP_ORIG "${CMAKE_INSTALL_PREFIX}/${BASHCOMP_USER_PATH}/${CMAKE_PROJECT_NAME}")
|
|
set(BASHCOMP_LINK "${BASHCOMP_PKG_PATH}/${CMAKE_PROJECT_NAME}")
|
|
|
|
if(BASHCOMP_PKG_PATH)
|
|
# TODO: CMake 3.21 Use "file(COPY_FILE ...)"
|
|
install(CODE "
|
|
if(EXISTS \"${BASHCOMP_ORIG}\")
|
|
file(REMOVE \"${BASHCOMP_LINK}\")
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
\"${BASHCOMP_ORIG}\"
|
|
\"${BASHCOMP_LINK}\"
|
|
ERROR_QUIET
|
|
RESULT_VARIABLE result)
|
|
if(result EQUAL 0)
|
|
message(STATUS \"Bash completion-support has been installed to ${BASHCOMP_LINK}\")
|
|
endif()
|
|
endif()
|
|
")
|
|
endif()
|
|
endif()
|
|
endmacro()
|
|
|
|
|
|
|