@@ -404,6 +404,11 @@ function(_otelcpp_get_option_default __OPTION_NAME __DEFAULT_VALUE
404404 # The namespaced option takes precedence when both names are provided.
405405 if (NOT DEFINED ${__OPTION_NAME} )
406406 set (__RESOLVED_DEFAULT "${__LEGACY_VALUE} " )
407+ elseif (NOT "${${__OPTION_NAME} }" EQUAL "${__LEGACY_VALUE} " )
408+ message (
409+ WARNING
410+ "CMake option ${__LEGACY_OPTION_NAME} is deprecated. Use ${__OPTION_NAME} instead. The values of these options differ: ${__LEGACY_OPTION_NAME} =${__LEGACY_VALUE} , ${__OPTION_NAME} =${${__OPTION_NAME} }"
411+ )
407412 endif ()
408413 endif ()
409414 endif ()
@@ -414,6 +419,47 @@ function(_otelcpp_get_option_default __OPTION_NAME __DEFAULT_VALUE
414419endfunction ()
415420
416421function (otelcpp_option_flag __OPTION_NAME __HELP_TEXT __DEFAULT_VALUE )
422+ set (optionArgs)
423+ set (oneValueArgs AVAILABLE_CONDITION UNAVAILABLE_MESSAGE)
424+ set (multiValueArgs)
425+ cmake_parse_arguments (_otelcpp_option_flag "${optionArgs} " "${oneValueArgs} "
426+ "${multiValueArgs} " "${ARGN} " )
427+
428+ if (_otelcpp_option_flag_AVAILABLE_CONDITION)
429+ set (_option_available 0)
430+ foreach (__cond ${_otelcpp_option_flag_AVAILABLE_CONDITION} )
431+ string (REGEX REPLACE " +" ";" __cond_dep "${__cond} " )
432+ if (${__cond_dep} )
433+ set (_option_available 1)
434+ break ()
435+ endif ()
436+ endforeach ()
437+ if (_option_available EQUAL 0)
438+ _otelcpp_get_legacy_option_name ("${__OPTION_NAME} " __LEGACY_OPTION_NAME )
439+ unset (_option_fatal_error_message)
440+ if (NOT __LEGACY_OPTION_NAME STREQUAL "" AND DEFINED
441+ ${__LEGACY_OPTION_NAME} )
442+ set (_option_fatal_error_message
443+ "${__LEGACY_OPTION_NAME} is unavailable." )
444+ endif ()
445+ if (DEFINED ${__OPTION_NAME} )
446+ if (_option_fatal_error_message)
447+ set (_option_fatal_error_message
448+ "${_option_fatal_error_message} ${__OPTION_NAME} is unavailable." )
449+ else ()
450+ set (_option_fatal_error_message "${__OPTION_NAME} is unavailable." )
451+ endif ()
452+ endif ()
453+ if (_option_fatal_error_message)
454+ message (
455+ FATAL_ERROR
456+ "${_option_fatal_error_message}${_otelcpp_option_flag_UNAVAILABLE_MESSAGE} "
457+ )
458+ endif ()
459+ return ()
460+ endif ()
461+ endif ()
462+
417463 _otelcpp_get_option_default ("${__OPTION_NAME} " "${__DEFAULT_VALUE} "
418464 __RESOLVED_DEFAULT )
419465 option (${__OPTION_NAME} "${__HELP_TEXT} " "${__RESOLVED_DEFAULT} " )
0 commit comments