diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 9c885ff224..4aa327043f 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -129,6 +129,8 @@ function(vcpkg_build_make) if(LINK_ENV_${cmake_buildtype}) set(config_link_backup "$ENV{_LINK_}") set(ENV{_LINK_} "${LINK_ENV_${cmake_buildtype}}") + else() + unset(config_link_backup) endif() if(arg_ADD_BIN_TO_PATH) @@ -171,9 +173,8 @@ function(vcpkg_build_make) ) endif() - if(config_link_backup) + if(DEFINED config_link_backup) set(ENV{_LINK_} "${config_link_backup}") - unset(config_link_backup) endif() if(arg_ADD_BIN_TO_PATH) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 6a83ae8319..4ebecbf5c8 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -787,6 +787,8 @@ function(vcpkg_configure_make) if(LINK_ENV_${current_buildtype}) set(link_config_backup "$ENV{_LINK_}") set(ENV{_LINK_} "${LINK_ENV_${current_buildtype}}") + else() + unset(link_config_backup) endif() vcpkg_list(APPEND lib_env_vars LIB LIBPATH LIBRARY_PATH) # LD_LIBRARY_PATH) @@ -826,9 +828,8 @@ function(vcpkg_configure_make) endif() z_vcpkg_restore_pkgconfig_path() - if(link_config_backup) + if(DEFINED link_config_backup) set(ENV{_LINK_} "${link_config_backup}") - unset(link_config_backup) endif() if(arg_ADD_BIN_TO_PATH)