NMake fatal error: invalid option 'H'
I'm trying to set up a Visual Studio toolchain and then use that to compile a cmake project.
I'm using the latest available CLion version (2018.1.5), combined with the Visual Studio build tools (2017, with both the 2015 and 2017 msvc versions installed).
CLion seemingly detects it all correctly:

Cmake also seems to cause no problems:
"C:\Program Files\JetBrains\CLion 2018.1.1\bin\cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -Dgtest_disable_pthreads=ON -G "CodeBlocks - NMake Makefiles" "D:\git repos\autoupdate\app"
-- The C compiler identification is MSVC 19.14.26433.0
-- The CXX compiler identification is MSVC 19.14.26433.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
*snipped some project sensitive info here*
-- Configuring done
-- Generating done
-- Build files have been written to: D:/git repos/autoupdate/app/cmake-build-debug
[Finished]
But when I trigger a build, all I get is this:
"C:\Program Files\JetBrains\CLion 2018.1.1\bin\cmake\bin\cmake.exe" --build "D:\git repos\autoupdate\app\cmake-build-debug" --target all --
Microsoft (R) Program Maintenance Utility Version 14.14.26433.0
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1065: invalid option 'H'
Stop.
How can I debug what CLion is sending to nmake?
请先登录再写评论。
Hi! Does the issue happen with a default "Hello, World!" project?
Hi,
Yes, it also happens with the default C++ (that contains a hello world in the main) project that CLion creates.
The CMake project output there is similar to what I have with my own project:
"C:\Program Files\JetBrains\CLion 2018.1.1\bin\cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - NMake Makefiles" C:\Users\name\Desktop\hello_world
-- The C compiler identification is MSVC 19.14.26433.0
-- The CXX compiler identification is MSVC 19.14.26433.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/name/Desktop/hello_world/cmake-build-debug
[Finished]
And the error message is also the same:
"C:\Program Files\JetBrains\CLion 2018.1.1\bin\cmake\bin\cmake.exe" --build C:\Users\name\Desktop\hello_world\cmake-build-debug --target hello_world --
Microsoft (R) Program Maintenance Utility Version 14.14.26433.0
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1065: invalid option 'H'
Stop.
Thanks for the info! Please reproduce the issue with the "Hello, World!" project once again and send the idea.log file (Help | Show Log in...) to clion-support at jetbrains.com right after that.
Hi, I sent the log to the email address.
@Willem, unfortunately, we haven't received the log. Please resend it to clion-support at jetbrains.com or upload using https://uploads.services.jetbrains.com/.
It seems that the mail yesterday didn't get through.This time I got a reply with a ticket number.
For me the issue is now fixed (thanks again for the support in the ticket!).
For those encountering the same issue, here's the root cause that caused it in my case:
I previously used the mingw toolchain, and in order for mingw to work when you have the git folder in your path, I set the 'MAKEFLAGS' environment variable to "SHELL=CMD".
Removing this environment variable solved the issue for me.