From 64e246e7346c27418866f430250a726de4cc075f Mon Sep 17 00:00:00 2001
From: patrick96
Date: Thu, 24 Dec 2020 01:09:39 +0100
Subject: [PATCH] cmake: Add option to enable/disable shell files
---
CHANGELOG.md | 3 ++-
CMakeLists.txt | 6 ++++--
cmake/01-core.cmake | 1 +
cmake/05-summary.cmake | 1 +
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f902b2ed..c3393127 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,10 +28,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `BUILD_POLYBAR=ON` - Builds the `polybar` executable
- `BUILD_POLYBAR_MSG=ON` - Builds the `polybar-msg` executable
- `BUILD_TESTS=OFF` - Builds the test suite
- - `BUILD_CONFIG=ON` - Generate sample config
- `BUILD_DOC=ON` - Builds the documentation
- `BUILD_DOC_HTML=BUILD_DOC` - Builds the html documentation (depends on `BUILD_DOC`)
- `BUILD_DOC_MAN=BUILD_DOC` - Builds the manpages (depends on `BUILD_DOC`)
+ - `BUILD_CONFIG=ON` - Generate sample config
+ - `BUILD_SHELL=ON` - Generate shell completion files
- `DISABLE_ALL=OFF` - Disables all above targets by default. Individual
targets can still be enabled explicitly.
- The documentation can no longer be built by directly configuring the `doc`
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 816d9f66..3823d5ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,8 +38,10 @@ if(BUILD_DOC)
add_subdirectory(doc)
endif()
-add_subdirectory(contrib/bash)
-add_subdirectory(contrib/zsh)
+if (BUILD_SHELL)
+ add_subdirectory(contrib/bash)
+ add_subdirectory(contrib/zsh)
+endif()
# Setup everything that uses a C++ compile (polybar, polybar-msg, tests)
if(HAS_CXX_COMPILATION)
diff --git a/cmake/01-core.cmake b/cmake/01-core.cmake
index e52acd9e..fe0032e5 100644
--- a/cmake/01-core.cmake
+++ b/cmake/01-core.cmake
@@ -16,6 +16,7 @@ option(BUILD_POLYBAR_MSG "Build polybar-msg" ${DEFAULT_ON})
option(BUILD_TESTS "Build testsuite" OFF)
option(BUILD_DOC "Build documentation" ${DEFAULT_ON})
option(BUILD_CONFIG "Generate sample configuration" ${DEFAULT_ON})
+option(BUILD_SHELL "Generate shell completion files" ${DEFAULT_ON})
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(BUILD_DOC_HTML "Build HTML documentation" ON "BUILD_DOC" OFF)
diff --git a/cmake/05-summary.cmake b/cmake/05-summary.cmake
index 2144b702..9c3504eb 100644
--- a/cmake/05-summary.cmake
+++ b/cmake/05-summary.cmake
@@ -28,6 +28,7 @@ colored_option(" documentation" BUILD_DOC)
colored_option(" html" BUILD_DOC_HTML)
colored_option(" man" BUILD_DOC_MAN)
colored_option(" sample config" BUILD_CONFIG)
+colored_option(" shell files" BUILD_SHELL)
if (BUILD_LIBPOLY)
message(STATUS " Module support:")