cmake error when generate NMake Makefiles

1

my system is windows, installed Visual Studio 2010 and cmake-3.4.1. I want to use follow commands to generate NMake Makefiles:

SET PATH=D:\Program Files\CMake\bin;D:\Program Files\Microsoft Visual Studio 10.0\VC\bin;D:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
SET LIB=D:\Program Files\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
cmake -G"NMake Makefiles" ..

then, error appears:

-- The C compiler identification is MSVC 16.0.30319.1
-- The CXX compiler identification is MSVC 16.0.30319.1
-- Check for working C compiler: D:/Program Files/Microsoft Visual Studio 10.0/VC/bin/cl.exe
-- Check for working C compiler: D:/Program Files/Microsoft Visual Studio 10.0/VC/bin/cl.exe -- broken
CMake Error at D:/Program Files/CMake/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "D:/Program Files/Microsoft Visual Studio
  10.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: F:/codeing/ng/code/eclipse/CMakeFiles/CMakeTmp



  Run Build Command:"nmake" "/NOLOGO" "cmTC_380fe\fast"

        "D:\Program Files\Microsoft Visual Studio 10.0\VC\bin\nmake.exe" -f
  CMakeFiles\cmTC_380fe.dir\build.make /nologo -L
  CMakeFiles\cmTC_380fe.dir\build

  Building C object CMakeFiles/cmTC_380fe.dir/testCCompiler.c.obj

        D:\PROGRA~1\MICROS~1.0\VC\bin\cl.exe
  @C:\Users\ADMINI~1\AppData\Local\Temp\nm7733.tmp

  testCCompiler.c

  Linking C executable cmTC_380fe.exe

        "D:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe
  --intdir=CMakeFiles\cmTC_380fe.dir --manifests --
  D:\PROGRA~1\MICROS~1.0\VC\bin\link.exe /nologo
  @CMakeFiles\cmTC_380fe.dir\objects1.rsp
  @C:\Users\ADMINI~1\AppData\Local\Temp\nm787C.tmp

  鍙傛暟閿欒銆俁C Pass 1 failed to run.

  NMAKE : fatal error U1077: “"D:\Program Files\CMake\bin\cmake.exe"”:
  返回代码“0xffffffff”

  Stop.

  NMAKE : fatal error U1077: “"D:\Program Files\Microsoft Visual Studio
  10.0\VC\bin\nmake.exe"”: 返回代码“0x2”

  Stop.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (PROJECT)


-- Configuring incomplete, errors occurred!
See also "F:/codeing/ng/code/eclipse/CMakeFiles/CMakeOutput.log".
See also "F:/codeing/ng/code/eclipse/CMakeFiles/CMakeError.log".

I check file CMakeError.log , contents as follow:

Determining if the C compiler works failed with the following output:
Change Dir: F:/codeing/ng/code/eclipse/CMakeFiles/CMakeTmp

Run Build Command:"nmake" "/NOLOGO" "cmTC_380fe\fast"
    "D:\Program Files\Microsoft Visual Studio 10.0\VC\bin\nmake.exe" -f CMakeFiles\cmTC_380fe.dir\build.make /nologo -L                  CMakeFiles\cmTC_380fe.dir\build

Building C object CMakeFiles/cmTC_380fe.dir/testCCompiler.c.obj

    D:\PROGRA~1\MICROS~1.0\VC\bin\cl.exe  @C:\Users\ADMINI~1\AppData\Local\Temp\nm7733.tmp

testCCompiler.c

Linking C executable cmTC_380fe.exe

    "D:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_380fe.dir --manifests  -- D:\PROGRA~1\MICROS~1.0\VC\bin\link.exe /nologo @CMakeFiles\cmTC_380fe.dir\objects1.rsp @C:\Users\ADMINI~1\AppData\Local\Temp\nm787C.tmp

鍙傛暟閿欒銆俁C Pass 1 failed to run.

NMAKE : fatal error U1077: “"D:\Program Files\CMake\bin\cmake.exe"”: 返回代码“0xffffffff”

Stop.

NMAKE : fatal error U1077: “"D:\Program Files\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"”: 返回代码“0x2”

Stop.

infact, I found that CMakeCCompilerId.exe and CMakeCXXCompilerId.exe were already generated(in..\CMakeFiles\3.4.1\CompilerIdC\ and ..\CMakeFiles\3.4.1\CompilerIdCXX\ directories), why cmake still fail? how to solve this problem?

visual-studio-2010
cmake
nmake
asked on Stack Overflow Feb 1, 2016 by xu_wei_jiang • edited Feb 21, 2017 by greatwolf

1 Answer

0

config vcvarsall.bat in system path,like below:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build

config nmake.exe in system path,like below:

C:\Program Files (x86)\Microsoft Visual

Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\Hostx64\x64\

then cmd in the project directory,

vcvarsall x64,

cmake . -G "NMake Makefiles",

have a try,good luck.

answered on Stack Overflow Sep 27, 2019 by Van Son • edited Sep 27, 2019 by Android

User contributions licensed under CC BY-SA 3.0