MantisBT - CMake
View Issue Details
0015603CMakeCMakepublic2015-06-03 13:462016-01-04 11:51
Jan Ciger 
 
normalminoralways
closedno change required 
Windows 7Windows 7 64bitFamily ed
CMake 3.2.2 
 
0015603: CMake ignores the configured Visual C/C++ compiler
CMake Visual Studio 2013 generators (probably other versions too, but not tested) will select incorrect architecture, regardless whether or not "vcvarsall.bat amd64" was executed beforehand.

cmake . (with no generator specified) will configure 32bit build
cmake -G "Visual Studio 12 2013" will still configure only a 32bit build (the only VS 2013 generator listed in the --help output)

On the other hand
cmake-gui offers 3 (!) generators:
"Visual Studio 12 2013" (probably 32bit build?)
"Visual Studio 12 2013 Win32" (32bit build)
"Visual Studio 12 2013 Win64" (64bit build)

with the 64bit build being the default.

This behaviour is rather inconsistent:

* Both tools should be offering the same generators
* The tools should offer the correct, currently configured toolchain because otherwise all kinds of issues happen due to the Microsoft's tools being misconfigured.

The Microsoft batch files set the following env variables that can be used to identify the current setup:

64bit tools targetting 64bit native build
@set Platform=X64
@set CommandPromptType=Native

64bit tools cross-compiling for 32bit
@set Platform=X86
@set CommandPromptType=Cross
@set PreferredToolArchitecture=x64

64bit tools cross-compiling for ARM
@set Platform=ARM
@set CommandPromptType=Cross
@set PreferredToolArchitecture=x64

etc.


No tags attached.
Issue History
2015-06-03 13:46Jan CigerNew Issue
2015-06-03 14:34Brad KingNote Added: 0038879
2015-06-03 14:34Brad KingStatusnew => resolved
2015-06-03 14:34Brad KingResolutionopen => no change required
2015-06-03 16:45Jan CigerNote Added: 0038880
2016-01-04 11:51Robert MaynardNote Added: 0040058
2016-01-04 11:51Robert MaynardStatusresolved => closed

Notes
(0038879)
Brad King   
2015-06-03 14:34   
The command line environment is not meaningful to the VS generators. You can specify the generator name on the command line with

 -G "Visual Studio 12 2013 Win64"

See 0015422 for addition of documentation of this.

(0038880)
Jan Ciger   
2015-06-03 16:45   
Is documenting this actually a sufficient solution?

Running Microsoft's compilers with options that are not appropriate/in conflict to whatever was configured using their batch file results in undefined behaviour - typically libraries that cause odd crashes or refuse to link - hard to trace issues.

A more sensible thing to do would be to either warn the user or to disable the irrelevant generators.
(0040058)
Robert Maynard   
2016-01-04 11:51   
Closing resolved issues that have not been updated in more than 4 months.