Merge pull request #2671 from psychon/auto_option
CMake: Add "AUTO" state for WITH_DBUS and GENERATE_MANPAGES
This commit is contained in:
commit
799650d887
|
@ -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
|
|
@ -6,8 +6,10 @@ set(VERSION devel)
|
|||
|
||||
set(CODENAME "Too long")
|
||||
|
||||
option(WITH_DBUS "build with D-BUS" ON)
|
||||
option(GENERATE_MANPAGES "generate manpages" ON)
|
||||
include(AutoOption.cmake)
|
||||
|
||||
autoOption(WITH_DBUS "build with D-BUS")
|
||||
autoOption(GENERATE_MANPAGES "generate manpages")
|
||||
option(COMPRESS_MANPAGES "compress manpages" ON)
|
||||
option(GENERATE_DOC "generate API documentation" ON)
|
||||
option(DO_COVERAGE "build with coverage" OFF)
|
||||
|
@ -79,8 +81,7 @@ if(GENERATE_MANPAGES)
|
|||
SET(missing ${missing} " gzip")
|
||||
endif()
|
||||
|
||||
message(STATUS "Not generating manpages. Missing: " ${missing})
|
||||
set(GENERATE_MANPAGES OFF)
|
||||
autoDisable(GENERATE_MANPAGES "Not generating manpages. Missing: " ${missing})
|
||||
endif()
|
||||
endif()
|
||||
# }}}
|
||||
|
@ -209,8 +210,7 @@ if(WITH_DBUS)
|
|||
set(AWESOME_OPTIONAL_LDFLAGS ${AWESOME_OPTIONAL_LDFLAGS} ${DBUS_LDFLAGS})
|
||||
set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS})
|
||||
else()
|
||||
set(WITH_DBUS OFF)
|
||||
message(STATUS "DBUS not found. Disabled.")
|
||||
autoDisable(WITH_DBUS "DBus not found.")
|
||||
endif()
|
||||
endif()
|
||||
# }}}
|
||||
|
|
Loading…
Reference in New Issue