]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
cmake: Add macro check_auto_option() as an addition to add_auto_option()
authorRalf Habacker <ralf.habacker@freenet.de>
Mon, 18 May 2020 10:51:03 +0000 (12:51 +0200)
committerSimon McVittie <smcv@collabora.com>
Wed, 10 Jun 2020 18:13:47 +0000 (18:13 +0000)
check_auto_option() checks the values given to an auto-option and prints
a fatal error in case of invalid combinations.

cmake/modules/Macros.cmake
doc/CMakeLists.txt

index 741d0c1c3879234e949a0ba82ea43628778ca89d..9db3bfb0e7b906f5d49c55560a749f5901b4007f 100644 (file)
@@ -212,3 +212,24 @@ macro(add_auto_option _name _text _default)
     endif()
     set_property(CACHE ${_name} PROPERTY STRINGS AUTO ON OFF)
 endmacro()
+
+
+#
+# Ensure that if a tristate ON/OFF/AUTO feature is set to ON,
+# its requirements have been met. Fail with a fatal error if not.
+#
+# _name: name of a variable ENABLE_FOO representing a tristate ON/OFF/AUTO feature
+# _text: human-readable description of the feature enabled by _name, for the
+#        error message
+# _var: name of a variable representing a system property we checked for,
+#       such as an executable that must exist for the feature enabled by _name to work
+# _vartext: what we checked for, for the error message
+#
+macro(check_auto_option _name _text _var _vartext)
+    set(_nameval ${${_name}})
+    set(_varval ${${_var}})
+    #message("debug: _name ${_name} ${_nameval}  _var ${_var} ${_varval}")
+    if(${_nameval} AND NOT ${_nameval} STREQUAL "AUTO" AND NOT ${_varval})
+        message(FATAL_ERROR "${_text} requested but ${_vartext} not found")
+    endif()
+endmacro()
index 4ffe7779e54d88d11b79150fc200ee43a688daa7..8239c8e863c20c976ee4435044a893434b76bf73 100644 (file)
@@ -23,9 +23,7 @@ if(DBUS_ENABLE_DOXYGEN_DOCS)
         set(INSTALL_QCH_DIR ${CMAKE_INSTALL_DATADIR}/doc/dbus)
     endif()
     find_program(QHELPGENERATOR_EXECUTABLE NAMES qhelpgenerator qhelpgenerator-qt5)
-    if(ENABLE_QT_HELP AND NOT ENABLE_QT_HELP STREQUAL "AUTO" AND NOT QHELPGENERATOR_EXECUTABLE)
-        message(FATAL_ERROR "Qt help requested but qhelpgenerator not found")
-    endif()
+    check_auto_option(ENABLE_QT_HELP "Qt help" QHELPGENERATOR_EXECUTABLE "qhelpgenerator")
     if(ENABLE_QT_HELP AND QHELPGENERATOR_EXECUTABLE)
         message(STATUS "${QHELPGENERATOR_EXECUTABLE} found")
         set(DOXYGEN_GENERATE_QHP YES)