mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-26 19:49:01 +08:00
7d2449c346
* [docs] Delete embedded documentation in favor of docs/ Drive-by for the helper ports: 1. "documentation": "https://vcpkg.io/en/docs/README.html" 2. "license": "MIT" 3. Use `include_guard(GLOBAL)` in all script files 4. Make sure any persistent variables are saved to the cache * [docs] Restore empty regenerate.ps1 to satisfy Azure Pipelines * [docs] PR comments
36 lines
1.2 KiB
CMake
36 lines
1.2 KiB
CMake
function(vcpkg_backup_env_variables)
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS")
|
|
if(NOT DEFINED arg_VARS)
|
|
message(FATAL_ERROR "VARS must be defined.")
|
|
endif()
|
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
|
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
|
endif()
|
|
|
|
foreach(envvar IN LISTS arg_VARS)
|
|
if(DEFINED ENV{${envvar}})
|
|
set("z_vcpkg_env_backup_${envvar}" "$ENV{${envvar}}" PARENT_SCOPE)
|
|
else()
|
|
unset("z_vcpkg_env_backup_${envvar}" PARENT_SCOPE)
|
|
endif()
|
|
endforeach()
|
|
endfunction()
|
|
|
|
function(vcpkg_restore_env_variables)
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS")
|
|
if(NOT DEFINED arg_VARS)
|
|
message(FATAL_ERROR "VARS must be defined.")
|
|
endif()
|
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
|
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
|
endif()
|
|
|
|
foreach(envvar IN LISTS arg_VARS)
|
|
if(DEFINED z_vcpkg_env_backup_${envvar})
|
|
set("ENV{${envvar}}" "${z_vcpkg_env_backup_${envvar}}")
|
|
else()
|
|
unset("ENV{${envvar}}")
|
|
endif()
|
|
endforeach()
|
|
endfunction()
|