forked from awesomeWM/awesome
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: Add "AUTO" state for WITH_DBUS and GENERATE_MANPAGES
Previously, these options had two possible values: ON and OFF. Now, they have three possible values: ON, OFF, and AUTO. OFF still does what it always did: The feature is just disabled. With ON and AUTO, we check for the feature. The difference is what happens when the feature could not be enabled, e.g. because some dependencies is missing: With AUTO, we just disable the feature (this is what happened previously with ON). However, with ON, CMake aborts and prints an error. Implements: Suggestion by Daniel awesomeWM#2665 (review) Signed-off-by: Uli Schlachter <[email protected]>
- Loading branch information
1 parent
0ec2c37
commit 8e0fb89
Showing
2 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Add a new option with default value "auto": | ||
# autoOption(FOOBAR "Support foobar") | ||
# | ||
# To check if FOOBAR support should be enabled, use: | ||
# if(FOOBAR) | ||
# | ||
# If necessary dependencies for FOOBAR are missing, use: | ||
# autoDisable(FOOBAR "Did not find baz") | ||
# | ||
# Example: | ||
# autoOption(FOOBAR "Support foobar") | ||
# if(FOOBAR) | ||
# Check for FOOBAR here. | ||
# if(NOT BAZ_FOUND) | ||
# autoDisable(FOOBAR "Did not find baz") | ||
# endif() | ||
# endif() | ||
|
||
function(autoOption name description) | ||
set(${name} AUTO CACHE STRING "${description}") | ||
set_property(CACHE ${name} PROPERTY STRINGS AUTO ON OFF) | ||
|
||
if((NOT ${name} STREQUAL ON) AND | ||
(NOT ${name} STREQUAL OFF) AND | ||
(NOT ${name} STREQUAL AUTO)) | ||
message(FATAL_ERROR "Value of ${name} must be one of ON/OFF/AUTO, but is ${${name}}") | ||
endif() | ||
endfunction() | ||
|
||
function(autoDisable name reason) | ||
message(STATUS "${reason}") | ||
if(${name} STREQUAL AUTO) | ||
message(STATUS "Disabled.") | ||
SET(${name} OFF PARENT_SCOPE) | ||
elseif(${name} STREQUAL ON) | ||
message(SEND_ERROR "Aborting because ${name} was set to ON.") | ||
else() | ||
message(AUTHOR_WARNING "Unexpected value for ${name}: ${${name}}.") | ||
endif() | ||
endfunction() | ||
|
||
# vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters