<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56845>56845</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [feature] Provide a batch/script file to initialize the environment.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          hwhsu1231
      </td>
    </tr>
</table>

<pre>
    Take MSVC for example. There is a `vcvarsall.bat` so that we can set/unset the environment, dynamically.

<details><summary>Click to expand the DEMO</summary>

```cmd
C:\Users\hwhsu1231>where cl
資訊: 找不到提供模式的檔案。

C:\Users\hwhsu1231>vcvarsall x64
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.16
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Users\hwhsu1231>where cl
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe

C:\Users\hwhsu1231>vcvarsall /clean_env
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.16
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************

C:\Users\hwhsu1231>where cl
資訊: 找不到提供模式的檔案。
```

</details>

If it is feasible or possible, then we may tell **CMake+Ninja** to use `clang`/`clang++` as C/C++ compiler, more conveniently.

Besides, I think the batch/script file need to set/unset the env `CC`/`CXX` additionally. According the the documentation, [`CC`](https://cmake.org/cmake/help/latest/envvar/CC.html) and [`CXX`](https://cmake.org/cmake/help/latest/envvar/CXX.html) envs will initialize Cache Varaibles [`CMAKE_C_COMPILER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html#variable:CMAKE_%3CLANG%3E_COMPILER) and [`CMAKE_CXX_COMPILER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html#variable:CMAKE_%3CLANG%3E_COMPILER) on the **FIRST** configuration, respectively.

The following is the DEMO that I tell CMake+Ninja to use `clang++` as compiler, where LLVM is install in Visual Studio SDK. Therefore, I can load the **bin** path of `clang++.exe` by calling `vcvarsall.bat`.

<details><summary>Click to expand the DEMO</summary>

```cmd
D:\.ccxxpkgs\source\fmt-8.1.1>md build-clang12-x64

D:\.ccxxpkgs\source\fmt-8.1.1>cd build-clang12-x64

D:\.ccxxpkgs\source\fmt-8.1.1\build-clang12-x64>vcvarsall x64
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.16
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

D:\.ccxxpkgs\source\fmt-8.1.1\build-clang12-x64>where clang++
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\x64\bin\clang++.exe

D:\.ccxxpkgs\source\fmt-8.1.1\build-clang12-x64>set CC=clang

D:\.ccxxpkgs\source\fmt-8.1.1\build-clang12-x64>set CXX=clang++

D:\.ccxxpkgs\source\fmt-8.1.1\build-clang12-x64>cmake .. -G"Ninja Multi-Config"
-- CMake version: 3.21.2
-- The CXX compiler identification is Clang 12.0.0 with GNU-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Module support is disabled.
-- Version: 8.1.1
-- Build type: Release
-- CXX_STANDARD: 11
-- Performing Test has_std_11_flag
-- Performing Test has_std_11_flag - Success
-- Performing Test has_std_0x_flag
-- Performing Test has_std_0x_flag - Success
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS - Success
-- Performing Test FMT_HAS_VARIANT
-- Performing Test FMT_HAS_VARIANT - Success
-- Required features: cxx_variadic_templates
-- Performing Test HAS_NULLPTR_WARNING
-- Performing Test HAS_NULLPTR_WARNING - Success
-- Looking for _strtod_l
-- Looking for _strtod_l - found
-- Target 'doc' disabled (requires doxygen)
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS
-- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS - Success
-- FMT_PEDANTIC: OFF
-- Configuring done
-- Generating done
-- Build files have been written to: D:/.ccxxpkgs/source/fmt-8.1.1/build-clang12-x64
```

</details>

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWVtz4rgS_jXmRYXLFyDwwIMx9gw1QFJAOHlzCVuANsbyWjIJ--u3W-a-yRxmkz11dmqqiC9Sq9WSvu7-2lmIZNed0WdGRtO5T5aiIOyVbvKUmWS2ZgUjXBJKjJa1jbe0kDRNzQVV8E6kIGpNFXlhJKYZkUwZTlhmcId2Rli25YXINiyDdp8ku4xueAzjd6Zh9Q3L219dP2GK8lQabgAvstxsaLGDFz_l8TNRAgzKaZZopf1gdA9CMNFJ7kJby6p-8SapWnzD9Yym_yhZIeG-flnL0nZcGwa-6PXF6X5o0DZ6rtG-wwevbbTBNI8YQctod4xeYAQNowetfSNoGm0QtXRXaHQs3RUYnR62wEjPRpmej73BndHxjHZDd3lGp3qwUUMAk1lG2zm3_zvWHvefvLYa-zHOT_c7WxeZc1nSlExVmXBBHMvukD7bslTkrCC-gPMHVDwUYpMrsrVbpm2bdutCgy_yXcFXa0UMpx0bTge0ODYZ8bgQUiwVCBS5KKjiIvvJt7TZu3TgZp8EJw8lPOOK05T_wRIMAhr6zh0izbm7EaCX7rQXhONZFXRDQp4yiafw2m7BOUDP6RAuzhl68KThhidcglk7eJ77cJkJkeKkGKngZjdMp2O6lu268LbgGVy_CqnQ6KZfXePUZK_shz0M4kucMppFEMR-clzo51-u9plb-u_KO4eMeZWUwQXO8vJZ32BJuEJWsGRU8kXKCHCGXEj9jJke8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