@@ -387,10 +387,9 @@ function(_otelcpp_get_legacy_option_name __OPTION_NAME __OUTPUT_VARIABLE)
387387 PARENT_SCOPE )
388388endfunction ()
389389
390- function (_otelcpp_get_option_default __OPTION_NAME __DEFAULT_VALUE
391- __OUTPUT_VARIABLE )
390+ function (_otelcpp_get_option_default __OPTION_NAME __LEGACY_OPTION_NAME
391+ __DEFAULT_VALUE __OUTPUT_VARIABLE )
392392 set (__RESOLVED_DEFAULT "${__DEFAULT_VALUE} " )
393- _otelcpp_get_legacy_option_name ("${__OPTION_NAME} " __LEGACY_OPTION_NAME )
394393
395394 if (NOT __LEGACY_OPTION_NAME STREQUAL "" )
396395 if (DEFINED ${__LEGACY_OPTION_NAME} )
@@ -425,6 +424,8 @@ function(otelcpp_option_flag __OPTION_NAME __HELP_TEXT __DEFAULT_VALUE)
425424 cmake_parse_arguments (_otelcpp_option_flag "${optionArgs} " "${oneValueArgs} "
426425 "${multiValueArgs} " "${ARGN} " )
427426
427+ _otelcpp_get_legacy_option_name ("${__OPTION_NAME} " __LEGACY_OPTION_NAME )
428+
428429 if (_otelcpp_option_flag_AVAILABLE_CONDITION)
429430 set (_option_available 0)
430431 foreach (__cond ${_otelcpp_option_flag_AVAILABLE_CONDITION} )
@@ -435,7 +436,6 @@ function(otelcpp_option_flag __OPTION_NAME __HELP_TEXT __DEFAULT_VALUE)
435436 endif ()
436437 endforeach ()
437438 if (_option_available EQUAL 0)
438- _otelcpp_get_legacy_option_name ("${__OPTION_NAME} " __LEGACY_OPTION_NAME )
439439 unset (_option_fatal_error_message)
440440 if (NOT __LEGACY_OPTION_NAME STREQUAL "" AND DEFINED
441441 ${__LEGACY_OPTION_NAME} )
@@ -460,26 +460,44 @@ function(otelcpp_option_flag __OPTION_NAME __HELP_TEXT __DEFAULT_VALUE)
460460 endif ()
461461 endif ()
462462
463- _otelcpp_get_option_default ("${__OPTION_NAME} " "${__DEFAULT_VALUE } "
464- __RESOLVED_DEFAULT )
463+ _otelcpp_get_option_default ("${__OPTION_NAME} " "${__LEGACY_OPTION_NAME } "
464+ " ${__DEFAULT_VALUE} " __RESOLVED_DEFAULT )
465465 option (${__OPTION_NAME} "${__HELP_TEXT} " "${__RESOLVED_DEFAULT} " )
466+
467+ # Set the legacy option variable to the same value as the new option, so that
468+ # user can use the legacy option name to access the same value.
469+ if (NOT __LEGACY_OPTION_NAME STREQUAL "" )
470+ set (${__LEGACY_OPTION_NAME}
471+ "${${__OPTION_NAME} }"
472+ PARENT_SCOPE )
473+ endif ()
466474endfunction ()
467475
468476function (otelcpp_option_variable __OPTION_NAME __DEFAULT_VALUE __CACHE_TYPE
469477 __DOC_STRING )
470- _otelcpp_get_option_default ("${__OPTION_NAME} " "${__DEFAULT_VALUE} "
471- __RESOLVED_DEFAULT )
478+ _otelcpp_get_legacy_option_name ("${__OPTION_NAME} " __LEGACY_OPTION_NAME )
479+ _otelcpp_get_option_default ("${__OPTION_NAME} " "${__LEGACY_OPTION_NAME} "
480+ "${__DEFAULT_VALUE} " __RESOLVED_DEFAULT )
472481 set (${__OPTION_NAME}
473482 "${__RESOLVED_DEFAULT} "
474483 CACHE "${__CACHE_TYPE} " "${__DOC_STRING} " ${ARGN} )
484+
485+ # Set the legacy option variable to the same value as the new option, so that
486+ # user can use the legacy option name to access the same value.
487+ if (NOT __LEGACY_OPTION_NAME STREQUAL "" )
488+ set (${__LEGACY_OPTION_NAME}
489+ "${${__OPTION_NAME} }"
490+ PARENT_SCOPE )
491+ endif ()
475492endfunction ()
476493
477494include (CMakeDependentOption )
478495
479496function (otelcpp_dependent_option __OPTION_NAME __HELP_TEXT
480497 __CONDITION_TRUE_VALUE __CONDITION_RULE __CONDITION_FALSE_VALUE )
481- _otelcpp_get_option_default ("${__OPTION_NAME} " "${__CONDITION_TRUE_VALUE} "
482- __RESOLVED_DEFAULT )
498+ _otelcpp_get_legacy_option_name ("${__OPTION_NAME} " __LEGACY_OPTION_NAME )
499+ _otelcpp_get_option_default ("${__OPTION_NAME} " "${__LEGACY_OPTION_NAME} "
500+ "${__CONDITION_TRUE_VALUE} " __RESOLVED_DEFAULT )
483501 cmake_dependent_option (
484502 ${__OPTION_NAME} "${__HELP_TEXT} " "${__RESOLVED_DEFAULT} "
485503 "${__CONDITION_RULE} " "${__CONDITION_FALSE_VALUE} " )
@@ -488,4 +506,12 @@ function(otelcpp_dependent_option __OPTION_NAME __HELP_TEXT
488506 set (${__OPTION_NAME}
489507 "${${__OPTION_NAME} }"
490508 PARENT_SCOPE )
509+
510+ # Set the legacy option variable to the same value as the new option, so that
511+ # user can use the legacy option name to access the same value.
512+ if (NOT __LEGACY_OPTION_NAME STREQUAL "" )
513+ set (${__LEGACY_OPTION_NAME}
514+ "${${__OPTION_NAME} }"
515+ PARENT_SCOPE )
516+ endif ()
491517endfunction ()
0 commit comments