CLion with NMake gives me C2220, C4530, U1077 errors

CMakeLists.txt (Part)

```
SET(CMAKE_CXX_FLAGS "/std:c++17 /permissive- /W4 /WX")
SET(CMAKE_VERBOSE_MAKEFILE TRUE)
```

 

Source code

```
#include <iostream>

int main() {
    std::cout << "Hello, C++!\n";

    int num1 = 20;
    int num2 = 30;
    int num3 = num1 + num2;

    std::cout << num3 << '\n';

    return 0;
}

```

 

Error message

```
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\ostream(257): error C2220: warning treated as error - no 'object' file generated
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\ostream(248): note: while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(int)'
C:\Users\black\Workspace\Files\C_CPP\CPP\NMake_Test\main.cpp(10): note: see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(int)' being compiled
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\ostream(601): note: see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being compiled
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\ostream(257): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc

NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1422~1.279\bin\Hostx64\x64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
```

 

I've written a simple C++ code and tried to build it with NMake(Visual Studio 2019) in CLion, but the compiler gives me above errors.

This error disappears if I remove `/WX`, but there was no issue like this when I use Visual Studio MSBuild project with same compile option.

How do I fix this with keeping `/WX` option?

 

4 comments
Comment actions Permalink

Hi! Could you please try to build a default newly created project? Does it work?

0
Comment actions Permalink

Yes, I tried to build newly created project but still it doesn't work.

0
Comment actions Permalink

>I tried to build newly created project but still it doesn't work.

Please provide the error you get in this case and a screenshot of File | Settings | Build, Execution, Deployment | Toolchains (please capture the screenshot after the compiler detection is completed).

0
Comment actions Permalink

https://imgur.com/BN6ogcd

I already added error message to the original post.

0

Please sign in to leave a comment.