From 48cbe66f0d7efa79d53fe7a4521d7cab570ef4ad Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 6 Dec 2023 18:15:27 -0600 Subject: [PATCH] Simplify _opendds_env_append to Avoid Pop Issue --- cmake/opendds_testing.cmake | 41 +++++++++++++------------------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/cmake/opendds_testing.cmake b/cmake/opendds_testing.cmake index 5017eece9f1..8feec28c810 100644 --- a/cmake/opendds_testing.cmake +++ b/cmake/opendds_testing.cmake @@ -31,27 +31,15 @@ function(opendds_add_test) endif() endfunction() -function(_opendds_env_append setenv) - set(orig_argn "${ARGN}") - list(LENGTH ARGN len) - while(len GREATER 1) - list(GET ARGN 0 name) - list(GET ARGN 1 value) - if(setenv) - if(WIN32) - set(env "${env}set \"${name}=${value}\"\n") - else() - set(env "${env}export ${name}=\"${value}\"\n") - endif() +function(_opendds_env_append name value) + if(arg_SETENV) + if(WIN32) + set(env "${env}set \"${name}=${value}\"\n") else() - list(APPEND env "${name}=${value}") + set(env "${env}export ${name}=\"${value}\"\n") endif() - list(REMOVE_AT ARGN 0) - list(REMOVE_AT ARGN 0) - list(LENGTH ARGN len) - endwhile() - if(len GREATER 0) - message(FATAL_ERROR "Arguments must be in name value pairs: ${orig_argn}") + else() + list(APPEND env "${name}=${value}") endif() set(env "${env}" PARENT_SCOPE) endfunction() @@ -64,7 +52,8 @@ function(_opendds_env) "${no_value_options}" "${single_value_options}" "${multi_value_options}" ${ARGN}) set(env "") - _opendds_env_append("${arg_SETENV}" ACE_ROOT "${ACE_ROOT}" TAO_ROOT "${TAO_ROOT}") + _opendds_env_append(ACE_ROOT "${ACE_ROOT}") + _opendds_env_append(TAO_ROOT "${TAO_ROOT}") if(WIN32) set(env_var_name PATH) @@ -98,14 +87,14 @@ function(_opendds_env) string(REPLACE "/" "\\" lib_dir_list "${lib_dir_list}") string(REPLACE ";" "\;" lib_dir_list "${lib_dir_list}") endif() - _opendds_env_append("${arg_SETENV}" ${env_var_name} "${lib_dir_list}") + _opendds_env_append(${env_var_name} "${lib_dir_list}") if(DEFINED OPENDDS_BUILD_DIR) - _opendds_env_append("${arg_SETENV}" OPENDDS_BUILD_DIR "${OPENDDS_BUILD_DIR}") + _opendds_env_append(OPENDDS_BUILD_DIR "${OPENDDS_BUILD_DIR}") endif() if(DEFINED OPENDDS_CONFIG_DIR) - _opendds_env_append("${arg_SETENV}" OPENDDS_CONFIG_DIR "${OPENDDS_CONFIG_DIR}") + _opendds_env_append(OPENDDS_CONFIG_DIR "${OPENDDS_CONFIG_DIR}") endif() if(DEFINED OPENDDS_SOURCE_DIR) @@ -113,10 +102,8 @@ function(_opendds_env) set(ACE_SOURCE_DIR "${ACE_ROOT}") endif() _opendds_path_list(perl5lib "${OPENDDS_SOURCE_DIR}/bin" "${ACE_SOURCE_DIR}/bin") - _opendds_env_append("${arg_SETENV}" - OPENDDS_SOURCE_DIR "${OPENDDS_SOURCE_DIR}" - PERL5LIB "${perl5lib}" - ) + _opendds_env_append(OPENDDS_SOURCE_DIR "${OPENDDS_SOURCE_DIR}") + _opendds_env_append(PERL5LIB "${perl5lib}") endif() set("${arg_OUT}" ${env} PARENT_SCOPE)