From f57b469c29bd6f3cde1ea7f7b153b6f5beec583e Mon Sep 17 00:00:00 2001 From: olszomal Date: Thu, 1 Dec 2022 11:42:13 +0100 Subject: [PATCH] Add an option override the autodetected directory for installing bash completions --- README.md | 1 + cmake/SetBashCompletion.cmake | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f7739cd..6658d63 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ You may need to use `cmake3` instead of `cmake` to complete the following steps -DCMAKE_C_COMPILER=clang -DCMAKE_PREFIX_PATH=[openssl directory];[curl directory] -DCMAKE_INSTALL_PREFIX=[installation directory] + -DBASH_COMPLETION_USER_DIR=[bash completion installation directory] ``` * Then call that build system to actually compile/link the osslsigncode project (alias `make`): diff --git a/cmake/SetBashCompletion.cmake b/cmake/SetBashCompletion.cmake index b47cc08..f1ebfee 100644 --- a/cmake/SetBashCompletion.cmake +++ b/cmake/SetBashCompletion.cmake @@ -1,13 +1,19 @@ if(NOT MSVC) find_package(bash-completion QUIET) + + if(BASH_COMPLETION_USER_DIR) + set(BASH_COMPLETION_COMPLETIONSDIR ${BASH_COMPLETION_USER_DIR}/bash-completion/completions) + endif(BASH_COMPLETION_USER_DIR) + if(NOT BASH_COMPLETION_COMPLETIONSDIR) if(BASH_COMPLETION_COMPATDIR) set(BASH_COMPLETION_COMPLETIONSDIR ${BASH_COMPLETION_COMPATDIR}) - else() + else(BASH_COMPLETION_COMPATDIR) set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share") set(BASH_COMPLETION_COMPLETIONSDIR "${SHAREDIR}/bash-completion/completions") - endif() - endif() + endif(BASH_COMPLETION_COMPATDIR) + endif(NOT BASH_COMPLETION_COMPLETIONSDIR) + message(STATUS "Using bash completions dir ${BASH_COMPLETION_COMPLETIONSDIR}") install(FILES "osslsigncode.bash" DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR}) -endif() +endif(NOT MSVC)