CMake with Microsoft Visual C ++ Build Tools

EDIT: Having posted this on my tracker and stepped over it with some CMake devs, this is not really a CMake issue. Something is broken with the MSBuild installation causing it to return "Operation completed successfully". mistake. There is still no solution to this issue as a whole, but this narrows down the potential causes.


I'm trying to build a CMake project on Windows using MS Visual C ++ Build Tools 2015 (note: not complete Visual Studio). However, CMake seems to be unable to find cl.exe

cmake ..
-- Building for: Visual Studio 14 2015
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (project):
  No CMAKE_C_COMPILER could be found.



CMake Error at CMakeLists.txt:4 (project):
  No CMAKE_CXX_COMPILER could be found.

      

I suspect this is because CMake is expecting to find a compiler with a Visual Studio installation, but perhaps the offline build tools are installing it elsewhere? Can CMake be configured to look elsewhere for the compiler?

EDIT: To disable this in-pass capability, cl.exe is definitely installed. When I open the Visual C ++ shell (add tools to the path) cl.exe exits:

cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

      

And this is the same environment I run in cmake ..

, so cl.exe is definitely in the PATH for CMake detection.

EDIT 2: Looking at the CMakeError.log file I see several options as follows

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
1
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 4/14/2017 11:58:13 AM.
Project "E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "Debug\".
  Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
  Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /nologo /W0 /WX- /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /analyze- /errorReport:queue CMakeCXXCompilerId.cpp
TRACKER : error TRK0002: Failed to execute command: ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe" @C:\Users\<user>\AppData\Local\Temp\tmpa0925a9f05d5426d82afdcee8d722031.rsp". The operation completed successfully. [E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj]


Done Building Project "E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED.

Build FAILED.

"E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj" (default target) (1) ->
(ClCompile target) -> 
  TRACKER : error TRK0002: Failed to execute command: ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe" @C:\Users\<user>\AppData\Local\Temp\tmpa0925a9f05d5426d82afdcee8d722031.rsp". The operation completed successfully. [E:\<project_dir>\build\CMakeFiles\3.8.0-rc4\CompilerIdCXX\CompilerIdCXX.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.21

      

This looks like a compatibility issue with the release, especially with "ERROR: Operation completed successfully". lines. I am using CMake 3.8.0-rc4 and Visual C ++ 2015 Build Tools. Any ideas?

EDIT 3: I thought that upgrading from 3.8.0-rc4 to 3.8.0 might fix this, but to no avail. I also thought I was using 64 bit CMake trying to create a 32 bit program, so I changed that too. No luck yet.

EDIT 4: Also, for the record, this happens with CMake on a PC with VS 2015 installed.

+3


source to share


1 answer


I'm not sure if I will bring a solution to your problem The operation completed successfully

, but I was able to compile a [large] project in real life using cmake 3.8.1 and C ++ 2015 BuildTools.

The trick is simply using the VS2015 x64 command line for native tools (or x86). You either call cmake using this prompt, or call

this prompt from your regular prompt and it will set your path correctly.



REM Set up the include/lib paths of Visual Studio
call "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" amd64

cd to_build_dir

REM Call cmake with the right parameters
"C:\Program Files\CMake\bin\cmake.exe" .......

REM Build the XYZ project
MSBuild.exe SOLUTION_FILE.sln /t:XYZ .......

      

As I wrote, I'm not sure if it will fix your error because I was unable to reproduce it. However, I know that my project only compiles when I use the correct prompt. When I don't use it, I get severalerror MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

0


source







All Articles