[CMake] Visual Studio 12 C++ Compiler Detection

Allen Barnett Allen.Barnett at varian.com
Fri Dec 5 09:06:18 EST 2014


Hi Jakub: Thanks for the tip. What is the proper way to execute the compiler during the initial configure step? try_compile?

Thanks,
Allen

> So, it appears to find the compiler OK since it emits the correct compiler identification. But, the actual value of CMAKE_CXX_COMPILER is not usable. If you try to execute 
> C:/Program…./x86_amd64/cl.exe from within a CMake script or even from the command line, it will fail and produce the well-known “0xc000007b” dialog (missing DLL). Unless you’ve sourced > vcvarsx86_amd64.bat, the correct environment variables are not set for this version of the compiler.

> On the other hand, if I do “cmake –G NMake Makefiles”, I get what I expect:

> Namely, it finds C:/Program…./amd64/cl.exe.

> I would like to see how it is coming up with this version of the compiler which isn’t even in the PATH.

Hi Allen,

CMake does not pay attention to the PATH when you ask for VisualStudio generator. It simply finds it using it's internal logic. The generated projects are suitable for opening in the IDE.
The NMake generator behaves much more like Unix Makefiles generator, so it is sensitive to the environment variables and remembers all variables it needs.




More information about the CMake mailing list