c++windowsvisual-studiocmake

How to switch from VS9 to VS10 for NMake with CMake


On my computer I have both VS9 and VS10 for testing purpose. When I configure my project with VS9 or VS10 I have no problem with CMake.

Now I want to generate a project with NMake but during the configuration it takes VS9 as default C compiler and CXX compiler and I want VS10.

Anyone has an idea how I can perform such thing ?

i.e.

I want to switch from

Projects>cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
9.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
9.0/VC/bin/cl.exe -- works
...
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 9.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 9.0/VC/bin/cl.exe -- works

to

Projects>cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
10/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
10/VC/bin/cl.exe -- works
...
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 10/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 10/VC/bin/cl.exe -- works

Thanks :)


Solution

  • The NMake Makefiles generator uses the environment of your shell. In a normal cmd Window it will fail, and you normally open up the Visual Studio shell for the version you are interested in. You can also run the appropriate vcvars. I am not near a Windows machine right now, but I would check the command prompt you are using.