Skip to content

Commit

Permalink
Simplify _opendds_env_append to Avoid Pop Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
iguessthislldo committed Dec 7, 2023
1 parent ce7ea3b commit 48cbe66
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions cmake/opendds_testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -98,25 +87,23 @@ 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)
if(NOT DEFINED ACE_SOURCE_DIR)
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)
Expand Down

0 comments on commit 48cbe66

Please sign in to comment.