2019-02-06 17:30:52 +01:00
|
|
|
if (NOT BASIC_PROJECT_CONFIG_DONE)
|
2017-02-11 02:30:46 +01:00
|
|
|
message(FATAL_ERROR "Before including the ShellCompletion module, the BasicConfig module must be included.")
|
2019-02-06 17:30:52 +01:00
|
|
|
endif ()
|
2017-02-11 02:30:46 +01:00
|
|
|
|
2016-07-10 00:16:24 +02:00
|
|
|
option(SHELL_COMPLETION_ENABLED "controls whether shell completion is enabled in general" ON)
|
|
|
|
option(BASH_COMPLETION_ENABLED "controls whether shell completion for bash is enabled" ON)
|
2019-02-06 17:30:52 +01:00
|
|
|
if (NOT SHELL_COMPLETION_ENABLED)
|
2018-02-21 23:00:32 +01:00
|
|
|
return()
|
2019-02-06 17:30:52 +01:00
|
|
|
endif ()
|
2016-07-03 22:36:48 +02:00
|
|
|
|
2018-02-21 23:00:32 +01:00
|
|
|
# add bash completion (currently the only supported shell completion)
|
2019-02-06 17:30:52 +01:00
|
|
|
if (BASH_COMPLETION_ENABLED)
|
2018-02-21 23:00:32 +01:00
|
|
|
# find bash-completion.sh template
|
|
|
|
include(TemplateFinder)
|
|
|
|
find_template_file("bash-completion.sh" CPP_UTILITIES BASH_COMPLETION_TEMPLATE_FILE)
|
2016-07-03 22:36:48 +02:00
|
|
|
|
2018-02-21 23:00:32 +01:00
|
|
|
# generate wrapper script for bash completion
|
2019-02-06 17:30:52 +01:00
|
|
|
configure_file("${BASH_COMPLETION_TEMPLATE_FILE}"
|
2019-04-23 00:26:19 +02:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/bash-completion/completions/${META_PROJECT_NAME}${META_CONFIG_SUFFIX}" @ONLY)
|
2016-07-03 22:36:48 +02:00
|
|
|
|
2018-02-21 23:00:32 +01:00
|
|
|
# add install target bash completion
|
2019-02-06 17:30:52 +01:00
|
|
|
if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
|
2018-02-21 23:00:32 +01:00
|
|
|
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bash-completion/completions"
|
|
|
|
DESTINATION "share/bash-completion"
|
2019-02-06 17:30:52 +01:00
|
|
|
COMPONENT bash-completion)
|
|
|
|
if (NOT TARGET install-bash-completion)
|
2018-02-21 23:00:32 +01:00
|
|
|
add_custom_target(install-bash-completion
|
2019-06-01 12:14:30 +02:00
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=bash-completion -P
|
2019-02-06 17:30:52 +01:00
|
|
|
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
2018-02-21 23:00:32 +01:00
|
|
|
|
|
|
|
message(STATUS "Generating files for bash completion.")
|
2019-02-06 17:30:52 +01:00
|
|
|
endif ()
|