1
votes

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?

1
Unsure that many readers can undestand hieroglyphs in the error message. Is it The parameter is incorrectRC Pass 1 failed to run.? Like in that question: stackoverflow.com/questions/33816778/….Tsyvarev
You SHOULD run cmake FROM the target environment, which is setup all required environment variables not only PATH and LIB. This question is related to stackoverflow.com/questions/20887849/… The only difference in your question that you've set some incomplete environment manually.Sergei Nikulov
thank you,@Tsyvarev,@Sergei Nikulov, I solved this problem by flowing: 1.before run cmake, I delete SET PATH=...and SET LIB=... 2.then instead of "%comspec% /k ""D:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86", 3.finally,run cmake, it does work!!xu_wei_jiang

1 Answers

0
votes

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.