From 2821345eacb71222ed9acf31f193eda81daeec3f Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 2 Nov 2020 13:06:55 +0100 Subject: cmake: add option ENABLE_WINE to enable support for running cross compiled tests with wine For details about the ENABLE_WINE option, which support three modes AUTO|ON|OFF see the documentation of cmake macro check_auto_option(). A custom path for the wine executable can be specified by adding -DWINE_EXECUTABLE= to the cmake command line. The cmake related macros were copied from https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/cmake/modules/Macros.cmake --- cmake/modules/Macros.cmake | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cmake/modules/Macros.cmake (limited to 'cmake') diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake new file mode 100644 index 0000000..fa0f1fc --- /dev/null +++ b/cmake/modules/Macros.cmake @@ -0,0 +1,32 @@ +# +# provide option with three states AUTO, ON, OFF +# +macro(add_auto_option _name _text _default) + if(NOT DEFINED ${_name}) + set(${_name} ${_default} CACHE STRING "${_text}" FORCE) + else() + set(${_name} ${_default} CACHE STRING "${_text}") + 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() + -- cgit v1.2.3-55-g6feb