]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: fix shell completion install when just one flavor is enabled
authorViktor Szakats <commit@vsz.me>
Fri, 18 Apr 2025 07:46:59 +0000 (09:46 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 18 Apr 2025 08:34:11 +0000 (10:34 +0200)
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

scripts/CMakeLists.txt

index 1f93ddc81d8477e23249a10d547e2ae65e985db9..95a01b50683a5aeff2495da7f8c04326e6a6271d 100644 (file)
@@ -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")