From: Viktor Szakats Date: Fri, 18 Apr 2025 07:46:59 +0000 (+0200) Subject: cmake: fix shell completion install when just one flavor is enabled X-Git-Tag: curl-8_14_0~271 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6167049805fb40fe4b153eac972cce87a4084d2;p=thirdparty%2Fcurl.git cmake: fix shell completion install when just one flavor is enabled Also: - tidy up the `if` tree. - drop `include(GNUInstallDirs)` in favor of the upper-level one. Reported-by: Daniel Engberg Bug: https://github.com/curl/curl/issues/16946#issuecomment-2814663246 Follow-up to c8b0f0c9ad78eafc6c8f0005113de346ee797c21 #16833 Closes #17094 --- diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 1f93ddc81d..95a01b5068 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -52,27 +52,29 @@ if(CURL_COMPLETION_FISH OR if(NOT CURL_DISABLE_INSTALL) if(NOT CMAKE_CROSSCOMPILING) - if(NOT CURL_COMPLETION_FISH_DIR) - find_package(PkgConfig QUIET) - pkg_get_variable(CURL_COMPLETION_FISH_DIR "fish" "completionsdir") - if(NOT _pkg_fish_completionsdir) - include(GNUInstallDirs) - if(CMAKE_INSTALL_DATAROOTDIR) - set(CURL_COMPLETION_FISH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d") + 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 _pkg_fish_completionsdir) + if(CMAKE_INSTALL_DATAROOTDIR) + set(CURL_COMPLETION_FISH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d") + endif() endif() endif() - endif() - if(NOT CURL_COMPLETION_ZSH_DIR) - include(GNUInstallDirs) - if(CMAKE_INSTALL_DATAROOTDIR) - set(CURL_COMPLETION_ZSH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions") + if(CURL_COMPLETION_FISH_DIR) + install(FILES "${_completion_fish}" DESTINATION "${CURL_COMPLETION_FISH_DIR}") endif() endif() - if(CURL_COMPLETION_FISH_DIR) - install(FILES "${_completion_fish}" DESTINATION "${CURL_COMPLETION_FISH_DIR}") - endif() - if(CURL_COMPLETION_ZSH_DIR) - install(FILES "${_completion_zsh}" DESTINATION "${CURL_COMPLETION_ZSH_DIR}") + 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() endif() else() message(STATUS "We cannot install completion scripts when cross-compiling")