title: CLion EWDK MSVC Toolchain doesn't find kernel32.Lib
body: <p>Morning,</p>
  <p>I am currently moving my whole dev environment from VS2019 to CLion and can't get the Enterprise Windows Driver Kit (WDK) build environment working. After setting up the toolchain I get the following error message:</p>
  <pre><code>-- The C compiler identification is MSVC 19.28.29913.0
  -- The CXX compiler identification is MSVC 19.28.29913.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: E:/Program Files/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe
  -- Check for working C compiler: E:/Program Files/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - broken
  CMake Error at C:/Program Files/JetBrains/CLion 2021.3.2/bin/cmake/win/share/cmake-3.21/Modules/CMakeTestCCompiler.cmake:69 (message):
    The C compiler
  
      &quot;E:/Program Files/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe&quot;
  
    is not able to compile a simple test program.
  
    It fails with the following output:
  
      Change Dir: A:/Git/School/Driver/cmake-build-debug/CMakeFiles/CMakeTmp
      
      Run Build Command(s):C:/Program Files/JetBrains/CLion 2021.3.2/bin/ninja/win/ninja.exe cmTC_02d23 &amp;&amp; [1/2] Building C object CMakeFiles\cmTC_02d23.dir\testCCompiler.c.obj
      [2/2] Linking C executable cmTC_02d23.exe
      FAILED: cmTC_02d23.exe 
      cmd.exe /C &quot;cd . &amp;&amp; &quot;C:\Program Files\JetBrains\CLion 2021.3.2\bin\cmake\win\bin\cmake.exe&quot; -E vs_link_exe --intdir=CMakeFiles\cmTC_02d23.dir --rc=&quot;E:\PROG#OLC\WIND#B-J\10\bin\1002#1AM.0\x86\rc.exe&quot; --mt=&quot;E:\PROG#OLC\WIND#B-J\10\bin\1002#1AM.0\x86\mt.exe&quot; --manifests  -- &quot;E:\PROG#OLC\MICR#M1~\2019\BUIL#ZPH\VC\Tools\MSVC\1428#Y8D.299\bin\Hostx64\x64\link.exe&quot; /nologo CMakeFiles\cmTC_02d23.dir\testCCompiler.c.obj  /out:cmTC_02d23.exe /implib:cmTC_02d23.lib /pdb:cmTC_02d23.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib &amp;&amp; cmd.exe /C &quot;cd /D A:\Git\School\Driver\cmake-build-debug\CMakeFiles\CMakeTmp &amp;&amp; C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file A:/Git/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary A:/Git/School/Driver/cmake-build-debug/CMakeFiles/CMakeTmp/cmTC_02d23.exe -installedDir A:/Git/vcpkg/installed/x64-windows-static/debug/bin -OutVariable out&quot;&quot;
      LINK Pass 1: command &quot;E:\PROG#OLC\MICR#M1~\2019\BUIL#ZPH\VC\Tools\MSVC\1428#Y8D.299\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_02d23.dir\testCCompiler.c.obj /out:cmTC_02d23.exe /implib:cmTC_02d23.lib /pdb:cmTC_02d23.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_02d23.dir/intermediate.manifest CMakeFiles\cmTC_02d23.dir/manifest.res&quot; failed (exit code 1104) with the following output:
      LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
      ninja: build stopped: subcommand failed.
      
      
  
    
  
    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:8 (project)
  </code></pre>
  <p>So my guess would be that CLion isn't able to find the correct Windows Kit that includes the missing static linked libs.</p>
  <p>When working with VS2019 this issues is not existing as <code>LaunchBuildEnv.cmd</code> will take care of setting all paths.</p>
  <p>Basically you just start <code>LaunchBuildEnv.cmd</code> then type <code>SetupVSEnv</code> and start VS2019 from the cmd and all paths etc. are fixed automatically.
  Unfortunately this doesn't work for CLion. When pointing CLion to the <code>Build Tools</code> folder it is able to detect everything correctly but seems to no be able to get the Windows Kits from <code>E:\Program Files\Windows Kits\10</code>.</p>
  <p>I already tried to supply CLion with <code>SetupBuildEnv.cmd</code> as the Environment File without any success.</p>
  <p>So I wanted to ask if somebody know how I need to supply this path to CLion so it is correctly forwarded to cl.exe.</p>
  <p>Regards Artur</p>