MantisBT - CMake
View Issue Details
0014562CMakeCMakepublic2013-11-12 03:332014-06-02 08:37
Kiron 
Brad King 
normalminoralways
closedfixed 
Windows6.1
CMake 2.8.12 
CMake 3.0CMake 3.0 
0014562: not able to compile a simple test program with -G "Visual Studio 11 2012" -Tv90
CMake 2.8.12 (and 2.8.11) is unable to generate a VS 11 2012 project with toolset v90 and Visual Studio 11 2012 generator. CMake produces the following error:

> cmake -H. -Bbuild-vs11Tv90 -G "Visual Studio 11 2012" -Tv90
-- The C compiler identification is MSVC 15.0.30729.1
-- The CXX compiler identification is MSVC 15.0.30729.1
-- Check for working C compiler using: Visual Studio 11 2012
-- Check for working C compiler using: Visual Studio 11 2012 -- broken
CMake Error at C:/xxx/cmake/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "C:/Program Files (x86)/Microsoft Visual Studio
  9.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/xxx/build-vs11Tv90/CMakeFiles/CMakeTmp

  Run Build Command:C:\PROGRA~2\MICROS~3.0\Common7\IDE\devenv.com
  CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec3158555336

  Microsoft (R) Microsoft Visual Studio 2012 Version 11.0.60610.1.
  Copyright (C) Microsoft Corp. All rights reserved.

  The operation could not be completed. Wrong Parameter.

  Use:

  devenv [solutionfile | projectfile | anyfile.ext] [switches]

  The first argument for devenv is usually a solution file or project file.
  ...

BUT it works when using the Visual Studio 10 2010 generator:

> cmake -H. -Bbuild-vs10Tv90 -G "Visual Studio 10 2010" -Tv90
-- The C compiler identification is MSVC 15.0.30729.1
-- The CXX compiler identification is MSVC 15.0.30729.1
-- Check for working C compiler using: Visual Studio 10 2010
-- Check for working C compiler using: Visual Studio 10 2010 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10 2010
-- Check for working CXX compiler using: Visual Studio 10 2010 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/xxx/build-vs10Tv90
Run following command with an empty CMakeLists.txt in the current directory:

> cmake -H. -Bbuild-vs11Tv90 -G "Visual Studio 11 2012" -Tv90

This fails, but following commands works:

> cmake -H. -Bbuild-vs10Tv90 -G "Visual Studio 10 2010" -Tv90
No tags attached.
Issue History
2013-11-12 03:33KironNew Issue
2013-11-12 10:08Brad KingNote Added: 0034436
2013-11-13 05:04KironNote Added: 0034441
2013-11-19 11:33Brad KingNote Added: 0034485
2013-11-19 11:41Brad KingAssigned To => Brad King
2013-11-19 11:41Brad KingStatusnew => assigned
2013-11-19 11:41Brad KingTarget Version => CMake 3.0
2013-11-19 11:44Brad KingNote Added: 0034486
2013-11-19 11:44Brad KingStatusassigned => resolved
2013-11-19 11:44Brad KingResolutionopen => fixed
2013-11-19 11:44Brad KingFixed in Version => CMake 3.0
2014-06-02 08:37Robert MaynardNote Added: 0036015
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0034436)
Brad King   
2013-11-12 10:08   
Try adding

 -DCMAKE_MAKE_PROGRAM=C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

to the command-line too. Set the path to wherever you have msbuild.
(0034441)
Kiron   
2013-11-13 05:04   
I tried it with setting CMAKE_MAKE_PROGRAM and it worked. Will this be fixed in CMake, so that it works like with VS2010 generator?
(0034485)
Brad King   
2013-11-19 11:33   
This problem, in aggregate with related problems I've seen in the past, motivated me to finally perform a sweeping overhaul of how CMake selects a tool to launch the generated native build system (commit range e650225d..4cce44b6). The main commit that may relate to this issue is:

 VS: Switch to internal CMAKE_MAKE_PROGRAM lookup by generators
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=558c74d0 [^]

For VS we now pick the default build tool as late as possible, even after generation of the project is completed. For VS >= 10 we pick MSBuild unless the user sets CMAKE_MAKE_PROGRAM manually or the .sln references Intel Fortran .vfproj files.
(0034486)
Brad King   
2013-11-19 11:44   
With the changes mentioned in 0014562:0034485 I can now run

 cmake ../src -G "Visual Studio 11 2012" -Tv90

to use the VS 9 toolset with the VS 11 generator.
(0036015)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.