microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.8k stars 6.3k forks source link

[vcpkg/scripts] Teach vcpkg_add_to_path to only add the path if it is not already there #38296

Open Neumann-A opened 4 months ago

Neumann-A commented 4 months ago

vcpkg_add_to_path should only add a path to PATH if it is not already present on PATH. Furthermore there should be some special treatment of the PREPEND/APPEND in the case if the path is already in PATH.

dg0yt commented 4 months ago

Related: https://github.com/microsoft/vcpkg/pull/30396. vcpkg_host_path_list(REMOVE_DUPLICATES listvar) would remove duplicate regardless of whether they were created by vcpkg_add_to_path or by user script code.