Skip to content

Commit

Permalink
Merge pull request Andersbakken#500 from cslux/bash-completion-refactor
Browse files Browse the repository at this point in the history
Refactor BashCompletion.cmake
  • Loading branch information
Andersbakken committed Oct 30, 2015
2 parents e15a954 + f4abc36 commit b0db023
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmake/BashCompletion.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(FORCE_BASH_COMPLETION_INSTALLATION FALSE CACHE BOOL "Always install bash completion files (default installation path /usr/share/bash-completion/completions)")
set(FORCE_BASH_COMPLETION_INSTALLATION FALSE CACHE BOOL "Force bash completion installation")

if(FORCE_BASH_COMPLETION_INSTALLATION AND "${BASH_COMPLETION_COMPLETIONSDIR}" STREQUAL "")
set(BASH_COMPLETION_COMPLETIONSDIR "/usr/share/bash-completion/completions")
set(BASH_COMPLETION_COMPLETIONSDIR "/share/bash-completion/completions")
endif()

find_package(PkgConfig QUIET)
Expand All @@ -12,13 +12,16 @@ if(PKG_CONFIG_FOUND OR FORCE_BASH_COMPLETION_INSTALLATION)
OUTPUT_VARIABLE BASH_COMPLETION_COMPLETIONSDIR
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT BASH_COMPLETION_UNAVAILABLE)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=prefix bash-completion
OUTPUT_VARIABLE BASH_COMPLETION_COMPLETIONSDIR_PREFIX
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "${BASH_COMPLETION_COMPLETIONSDIR_PREFIX}" "" BASH_COMPLETION_COMPLETIONSDIR ${BASH_COMPLETION_COMPLETIONSDIR})
endif()
endif()
if(NOT BASH_COMPLETION_UNAVAILABLE OR FORCE_BASH_COMPLETION_INSTALLATION)
set(BASH_COMPLETION_COMPLETIONSDIR ${BASH_COMPLETION_COMPLETIONSDIR} CACHE PATH "Bash completion installation directory")
if(${CMAKE_INSTALL_PREFIX} MATCHES "^/usr")
string(REGEX REPLACE "^/usr" "" BASH_COMPLETION_COMPLETIONSDIR ${BASH_COMPLETION_COMPLETIONSDIR})
endif()
set(BASH_COMPLETION_COMPLETIONSDIR "${CMAKE_INSTALL_PREFIX}${BASH_COMPLETION_COMPLETIONSDIR}")
set(BASH_COMPLETION_COMPLETIONSDIR "${CMAKE_INSTALL_PREFIX}${BASH_COMPLETION_COMPLETIONSDIR}" CACHE PATH "Bash completion installation directory" FORCE)
mark_as_advanced(BASH_COMPLETION_COMPLETIONSDIR)
set(BASH_COMPLETION_FOUND TRUE)
endif()
Expand Down

0 comments on commit b0db023

Please sign in to comment.