From: Viktor Szakats Date: Wed, 23 Apr 2025 08:26:38 +0000 (+0200) Subject: cmake: install shell completions for cross-builds X-Git-Tag: curl-8_14_0~227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1c99054abcee3887bb7b9c3d0e1857c25276755;p=thirdparty%2Fcurl.git cmake: install shell completions for cross-builds Also: - omit auto-detecting `CURL_COMPLETION_FISH_DIR` via `pkg-config` for cross-builds and when `CMAKE_INSTALL_PREFIX` is set. - flatten nested `if`s. Note: On macOS with Homebrew, `pkg-config --variable completionsdir fish` returns the version-specific Cellar path instead of the permanent path `/opt/homebrew/share/fish/vendor_completions.d/`. This mimics what autotools does, but may need further fixing, possibly upstream. https://github.com/Homebrew/homebrew-core/blob/9c13e62b009b8e814fda180e0fcc5096318daf31/Formula/f/fish.rb https://github.com/fish-shell/fish-shell/blob/ce631fd2fb1f5b63f5f0f1b4041a30dfad823d22/cmake/Install.cmake#L15-L21 Ref: #17147 Ref: 51170b52d15256d4aaf74ed6eea9a9297f5d595c #17159 Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103938 Closes #17145 --- diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index a627184e45..dd590c910f 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -51,33 +51,25 @@ if(CURL_COMPLETION_FISH OR endif() if(NOT CURL_DISABLE_INSTALL) - if(NOT CMAKE_CROSSCOMPILING) - if(CURL_COMPLETION_FISH) - if(NOT CURL_COMPLETION_FISH_DIR) - find_package(PkgConfig QUIET) - pkg_get_variable(CURL_COMPLETION_FISH_DIR "fish" "completionsdir") - if(NOT CURL_COMPLETION_FISH_DIR) - if(CMAKE_INSTALL_DATAROOTDIR) - set(CURL_COMPLETION_FISH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d") - endif() - endif() - endif() - if(CURL_COMPLETION_FISH_DIR) - install(FILES "${_completion_fish}" DESTINATION "${CURL_COMPLETION_FISH_DIR}") - endif() + if(CURL_COMPLETION_FISH) + if(NOT CURL_COMPLETION_FISH_DIR AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_INSTALL_PREFIX) + find_package(PkgConfig QUIET) + pkg_get_variable(CURL_COMPLETION_FISH_DIR "fish" "completionsdir") endif() - if(CURL_COMPLETION_ZSH) - if(NOT CURL_COMPLETION_ZSH_DIR) - if(CMAKE_INSTALL_DATAROOTDIR) - set(CURL_COMPLETION_ZSH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions") - endif() - endif() - if(CURL_COMPLETION_ZSH_DIR) - install(FILES "${_completion_zsh}" DESTINATION "${CURL_COMPLETION_ZSH_DIR}") - endif() + if(NOT CURL_COMPLETION_FISH_DIR AND CMAKE_INSTALL_DATAROOTDIR) + set(CURL_COMPLETION_FISH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d") + endif() + if(CURL_COMPLETION_FISH_DIR) + install(FILES "${_completion_fish}" DESTINATION "${CURL_COMPLETION_FISH_DIR}") + endif() + endif() + if(CURL_COMPLETION_ZSH) + if(NOT CURL_COMPLETION_ZSH_DIR AND CMAKE_INSTALL_DATAROOTDIR) + set(CURL_COMPLETION_ZSH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions") + endif() + if(CURL_COMPLETION_ZSH_DIR) + install(FILES "${_completion_zsh}" DESTINATION "${CURL_COMPLETION_ZSH_DIR}") endif() - else() - message(STATUS "We cannot install completion scripts when cross-compiling") endif() endif() else()