MantisBT - CMake
View Issue Details
0012189CMakepublic2011-05-14 06:362012-07-09 06:52
Strimo 
David Cole 
normalminoralways
closedfixed 
 
CMake 2.8.8CMake 2.8.8 
0012189: It is not possible to generate a Visual Studio project with ASCII/SBCS character set
In Visual Studio 9.0 (and prior, 10.0 i don't know) it is possible specify three different character sets for your project within the project properties:

Not Set = ASCII/SBCS (Single Byte Character Set)
Unicode
Multi-Byte

Depending on the option different preprocessor defines are set (http://msdn.microsoft.com/en-us/library/c426s321(v=vs.80).aspx [^]):

SBCS: neither _UNICODE nor _MBCS defined
Unicode: _UNICODE defined
Multi_Byte: _MBCS defined

The character set settings is stored within the vs proj files as an xml attribute:

SBCS: CharacterSet="0"
Unicode: CharacterSet="1"
Multi-Byte: CharacterSet="2"

However, the cmake visual studio generators do not support generating of projects with CharacterSet="0" (see cmLocalVisualStudio7Generator.cxx line 730). At the moment the generators select unicode if a _UNICODE macro has been set by add_definitions, otherwise multi-byte is selected.

To solve the problem and to keep backwards compatability, i suggest to define the _MBCS macro by default for the visual studio generators and to set CharacterSet="2" only if this macro is still available and otherwise CharacterSet="0". In that case the user can remove the _MBCS macro by remove_definitions and select this way the SBCS. If the user adds _UNICODE by add_definitions CharacterSet="1" should be selected and the conflicting _MBCS macro must be deleted by the code generator.
2005, 2008, 2010, CharacterSet, visual studio, visual studio 2010
patch SBCS.patch (2,522) 2011-06-21 10:43
https://public.kitware.com/Bug/file/3955/SBCS.patch
patch SBCS-revised.patch (2,584) 2011-06-22 19:58
https://public.kitware.com/Bug/file/3958/SBCS-revised.patch
patch SBCS_With_Test.patch (4,371) 2011-09-01 11:24
https://public.kitware.com/Bug/file/4038/SBCS_With_Test.patch
? SBCS_git (4,857) 2012-02-16 16:29
https://public.kitware.com/Bug/file/4225/SBCS_git
Issue History
2011-05-14 06:36StrimoNew Issue
2011-06-21 10:42Aaron C. MeadowsNote Added: 0026938
2011-06-21 10:43Aaron C. MeadowsFile Added: SBCS.patch
2011-06-21 10:43Aaron C. MeadowsTag Attached: visual studio 2010
2011-06-21 10:43Aaron C. MeadowsTag Attached: 2010
2011-06-21 10:43Aaron C. MeadowsTag Attached: visual studio
2011-06-21 10:44Aaron C. MeadowsTag Attached: 2005
2011-06-21 10:44Aaron C. MeadowsTag Attached: 2008
2011-06-21 10:45Aaron C. MeadowsTag Attached: CharacterSet
2011-06-22 19:58Aaron C. MeadowsFile Added: SBCS-revised.patch
2011-06-22 19:59Aaron C. MeadowsNote Added: 0026955
2011-08-31 12:02David ColeAssigned To => David Cole
2011-08-31 12:02David ColeStatusnew => assigned
2011-09-01 11:24Aaron C. MeadowsFile Added: SBCS_With_Test.patch
2011-09-01 11:24Aaron C. MeadowsNote Added: 0027317
2011-11-19 04:38VladislavNote Added: 0027830
2012-02-13 13:25John GrantNote Added: 0028579
2012-02-16 16:29Aaron C. MeadowsFile Added: SBCS_git
2012-02-16 16:30Aaron C. MeadowsNote Added: 0028612
2012-02-17 11:33David ColeTarget Version => CMake 2.8.8
2012-02-17 11:34David ColeNote Added: 0028615
2012-02-17 11:34David ColeStatusassigned => resolved
2012-02-17 11:34David ColeFixed in Version => CMake 2.8.8
2012-02-17 11:34David ColeResolutionopen => fixed
2012-07-09 06:52David ColeNote Added: 0029976
2012-07-09 06:52David ColeStatusresolved => closed

Notes
(0026938)
Aaron C. Meadows   
2011-06-21 10:42   
I dug into this bug and confirmed that there is no way to set the "Not Set" state. In the 2.8.4 source, the lines in question are:
  cmLocalVisualStudio7Generator.cxx line 730
  cmVisualStudio10TargetGenerator.cxx line 287

I've created a patch which allows this behavior by checking for _SBCS to be defined, in which case it writes the correct "Not Set" settings to the files.
(0026955)
Aaron C. Meadows   
2011-06-22 19:59   
I uploaded a revised patch file.
  + Corrected a stale comment
  + Corrected an if statement which caused a bad pointer dereference
(0027317)
Aaron C. Meadows   
2011-09-01 11:24   
Uploaded new patch which includes adding a test

(and it should be in the correct sense now!)
(0027830)
Vladislav   
2011-11-19 04:38   
Tell please, whether it is planned to add this patch in version 2.8.7?
(0028579)
John Grant   
2012-02-13 13:25   
I am suffering from this issue also. Thanks for making the patch. Will it be applied in version 2.8.8?
(0028612)
Aaron C. Meadows   
2012-02-16 16:30   
Attached Git patch to fix this issue.
(0028615)
David Cole   
2012-02-17 11:34   
Fix pushed to stage and merged to 'next':

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ba89e92ba622ed821a6adf31e8a6633d574ff656 [^]
(0029976)
David Cole   
2012-07-09 06:52   
Closing resolved issues that have not been updated in more than 4 months.