# When compiling with MSVC on Windows, you will first need to install the vcpkg tool.
# Check if Visual Studio already provides vcpkg for you. If not, a manual installation
# is possible. For example:
#
# > git clone https://github.com/microsoft/vcpkg.git C:\vcpkg
# > C:\vcpkg\bootstrap-vcpkg.bat -disableMetrics
#
# Then, set the environment variable VCPKG_ROOT=C:\vcpkg and run cmake normally.

# Prevent CMake from adding /W3 to MSVC flags by default; we set /W4 ourselves.
if (POLICY CMP0092)
    cmake_policy (SET CMP0092 NEW)
endif ()

# Auto-configure vcpkg toolchain on Windows if VCPKG_ROOT is set in the environment.
if (DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE AND CMAKE_HOST_WIN32)
    set (CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
        CACHE STRING "vcpkg toolchain (using VCPKG_ROOT env var)")
    set (VCPKG_TARGET_TRIPLET "x64-windows-static-md"
        CACHE STRING "vcpkg triplet")
    message (STATUS "Using vcpkg toolchain: ${CMAKE_TOOLCHAIN_FILE}")
endif ()
