function(GetCommandPrefix VAR)
  if(NOT WIN32 OR NOT MC_RTC_SUPERBUILD_SET_ENVIRONMENT)
    set(${VAR} ${CMAKE_COMMAND} -E env PATH=$ENV{PATH} CMAKE_PREFIX_PATH=$ENV{CMAKE_PREFIX_PATH} PKG_CONFIG_PATH=$ENV{PKG_CONFIG_PATH})
  endif()
  if(APPLE)
    list(APPEND ${VAR} DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH})
  elseif(UNIX)
    list(APPEND ${VAR} LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH})
  endif()
  if(WITH_ROS_SUPPORT)
    list(APPEND ${VAR} ROS_PACKAGE_PATH=$ENV{ROS_PACKAGE_PATH} ROS_DISTRO=$ENV{ROS_DISTRO} PYTHONPATH=$ENV{PYTHONPATH} ROS_ROOT=$ENV{ROS_ROOT} ROS_ETC_DIR=$ENV{ROS_ETC_DIR})
  endif()
  if(EMSCRIPTEN)
    list(PREPEND ${VAR} ${CMAKE_COMMAND} -E env "CXXFLAGS=-matomics -s USE_PTHREADS=1 -s DISABLE_EXCEPTION_CATCHING=0" "LDFLAGS=-s USE_PTHREADS=1 -s DISABLE_EXCEPTION_CATCHING=0")
  endif()
  set(${VAR} "${${VAR}}" PARENT_SCOPE)
endfunction()
