Attached Files | SBCS.patch [^] (2,522 bytes) 2011-06-21 10:43 [Show Content] [Hide Content]diff -Naur ./cmLocalVisualStudio7Generator.cxx ../../../cmake-2.8.4/Source/cmLocalVisualStudio7Generator.cxx
--- ./cmLocalVisualStudio7Generator.cxx 2011-02-15 14:51:43.000000000 -0600
+++ ../../../cmake-2.8.4/Source/cmLocalVisualStudio7Generator.cxx 2011-06-20 16:44:33.494000000 -0500
@@ -703,6 +703,10 @@
{
fout << "\t\t\tCharacterSet=\"1\">\n";
}
+ else if(targetOptions.UsingSBCS())
+ {
+ fout << "\t\t\tCharacterSet=\"0\">\n";
+ }
else
{
fout << "\t\t\tCharacterSet=\"2\">\n";
diff -Naur ./cmVisualStudio10TargetGenerator.cxx ../../../cmake-2.8.4/Source/cmVisualStudio10TargetGenerator.cxx
--- ./cmVisualStudio10TargetGenerator.cxx 2011-02-15 14:51:43.000000000 -0600
+++ ../../../cmake-2.8.4/Source/cmVisualStudio10TargetGenerator.cxx 2011-06-20 16:43:45.239000000 -0500
@@ -289,6 +289,10 @@
{
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
}
+ else if (this->ClOptions[*i]->UsingSBCS())
+ {
+ this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
+ }
else
{
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
diff -Naur ./cmVisualStudioGeneratorOptions.cxx ../../../cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.cxx
--- ./cmVisualStudioGeneratorOptions.cxx 2011-02-15 14:51:43.000000000 -0600
+++ ../../../cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.cxx 2011-06-20 16:42:41.526000000 -0500
@@ -116,6 +116,20 @@
}
return false;
}
+//----------------------------------------------------------------------------
+bool cmVisualStudioGeneratorOptions::UsingSBCS()
+{
+ // Look for the a _UNICODE definition.
+ for(std::vector<std::string>::const_iterator di = this->Defines.begin();
+ di != this->Defines.end(); ++di)
+ {
+ if(*di == "_SBCS")
+ {
+ return true;
+ }
+ }
+ return false;
+}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::Parse(const char* flags)
diff -Naur ./cmVisualStudioGeneratorOptions.h ../../../cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.h
--- ./cmVisualStudioGeneratorOptions.h 2011-02-15 14:51:43.000000000 -0600
+++ ../../../cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.h 2011-06-20 16:42:40.538000000 -0500
@@ -49,6 +49,7 @@
// Check for specific options.
bool UsingUnicode();
+ bool UsingSBCS();
bool IsDebug();
// Write options to output.
SBCS-revised.patch [^] (2,584 bytes) 2011-06-22 19:58 [Show Content] [Hide Content]diff -Naur ../../../cmake-2.8.4/Source/cmLocalVisualStudio7Generator.cxx ./cmLocalVisualStudio7Generator.cxx
--- ../../../cmake-2.8.4/Source/cmLocalVisualStudio7Generator.cxx 2011-06-20 16:44:33.494000000 -0500
+++ ./cmLocalVisualStudio7Generator.cxx 2011-02-15 14:51:43.000000000 -0600
@@ -703,10 +703,6 @@
{
fout << "\t\t\tCharacterSet=\"1\">\n";
}
- else if(targetOptions.UsingSBCS())
- {
- fout << "\t\t\tCharacterSet=\"0\">\n";
- }
else
{
fout << "\t\t\tCharacterSet=\"2\">\n";
diff -Naur ../../../cmake-2.8.4/Source/cmVisualStudio10TargetGenerator.cxx ./cmVisualStudio10TargetGenerator.cxx
--- ../../../cmake-2.8.4/Source/cmVisualStudio10TargetGenerator.cxx 2011-06-22 18:55:01.803800000 -0500
+++ ./cmVisualStudio10TargetGenerator.cxx 2011-02-15 14:51:43.000000000 -0600
@@ -289,11 +289,6 @@
{
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
}
- else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
- this->ClOptions[*i]->UsingSBCS())
- {
- this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
- }
else
{
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
diff -Naur ../../../cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.cxx ./cmVisualStudioGeneratorOptions.cxx
--- ../../../cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.cxx 2011-06-21 15:52:32.619000000 -0500
+++ ./cmVisualStudioGeneratorOptions.cxx 2011-02-15 14:51:43.000000000 -0600
@@ -116,20 +116,6 @@
}
return false;
}
-//----------------------------------------------------------------------------
-bool cmVisualStudioGeneratorOptions::UsingSBCS()
-{
- // Look for the a _SBCS definition.
- for(std::vector<std::string>::const_iterator di = this->Defines.begin();
- di != this->Defines.end(); ++di)
- {
- if(*di == "_SBCS")
- {
- return true;
- }
- }
- return false;
-}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::Parse(const char* flags)
diff -Naur ../../../cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.h ./cmVisualStudioGeneratorOptions.h
--- ../../../cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.h 2011-06-20 16:42:40.538000000 -0500
+++ ./cmVisualStudioGeneratorOptions.h 2011-02-15 14:51:43.000000000 -0600
@@ -49,7 +49,6 @@
// Check for specific options.
bool UsingUnicode();
- bool UsingSBCS();
bool IsDebug();
// Write options to output.
SBCS_With_Test.patch [^] (4,371 bytes) 2011-09-01 11:24 [Show Content] [Hide Content]diff -Naur cmake-2.8.4.orig/Source/cmLocalVisualStudio7Generator.cxx cmake-2.8.4/Source/cmLocalVisualStudio7Generator.cxx
--- cmake-2.8.4.orig/Source/cmLocalVisualStudio7Generator.cxx 2011-02-15 14:51:43.000000000 -0600
+++ cmake-2.8.4/Source/cmLocalVisualStudio7Generator.cxx 2011-06-20 16:44:33.494000000 -0500
@@ -703,6 +703,10 @@
{
fout << "\t\t\tCharacterSet=\"1\">\n";
}
+ else if(targetOptions.UsingSBCS())
+ {
+ fout << "\t\t\tCharacterSet=\"0\">\n";
+ }
else
{
fout << "\t\t\tCharacterSet=\"2\">\n";
diff -Naur cmake-2.8.4.orig/Source/cmVisualStudio10TargetGenerator.cxx cmake-2.8.4/Source/cmVisualStudio10TargetGenerator.cxx
--- cmake-2.8.4.orig/Source/cmVisualStudio10TargetGenerator.cxx 2011-02-15 14:51:43.000000000 -0600
+++ cmake-2.8.4/Source/cmVisualStudio10TargetGenerator.cxx 2011-06-22 18:55:01.803800000 -0500
@@ -289,6 +289,11 @@
{
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
}
+ else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
+ this->ClOptions[*i]->UsingSBCS())
+ {
+ this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
+ }
else
{
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
diff -Naur cmake-2.8.4.orig/Source/cmVisualStudioGeneratorOptions.cxx cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.cxx
--- cmake-2.8.4.orig/Source/cmVisualStudioGeneratorOptions.cxx 2011-02-15 14:51:43.000000000 -0600
+++ cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.cxx 2011-06-21 15:52:32.619000000 -0500
@@ -116,6 +116,20 @@
}
return false;
}
+//----------------------------------------------------------------------------
+bool cmVisualStudioGeneratorOptions::UsingSBCS()
+{
+ // Look for the a _SBCS definition.
+ for(std::vector<std::string>::const_iterator di = this->Defines.begin();
+ di != this->Defines.end(); ++di)
+ {
+ if(*di == "_SBCS")
+ {
+ return true;
+ }
+ }
+ return false;
+}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::Parse(const char* flags)
diff -Naur cmake-2.8.4.orig/Source/cmVisualStudioGeneratorOptions.h cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.h
--- cmake-2.8.4.orig/Source/cmVisualStudioGeneratorOptions.h 2011-02-15 14:51:43.000000000 -0600
+++ cmake-2.8.4/Source/cmVisualStudioGeneratorOptions.h 2011-06-20 16:42:40.538000000 -0500
@@ -49,6 +49,7 @@
// Check for specific options.
bool UsingUnicode();
+ bool UsingSBCS();
bool IsDebug();
// Write options to output.
diff -Naur cmake-2.8.4.orig/Tests/CMakeLists.txt cmake-2.8.4/Tests/CMakeLists.txt
--- cmake-2.8.4.orig/Tests/CMakeLists.txt 2011-02-15 14:51:44.000000000 -0600
+++ cmake-2.8.4/Tests/CMakeLists.txt 2011-08-31 14:14:26.792400000 -0500
@@ -1102,6 +1102,8 @@
ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile")
IF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio")
+ ADD_TEST_MACRO(SBCS SBCS)
+
ADD_TEST(VSExternalInclude ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/VSExternalInclude"
diff -Naur cmake-2.8.4.orig/Tests/SBCS/CMakeLists.txt cmake-2.8.4/Tests/SBCS/CMakeLists.txt
--- cmake-2.8.4.orig/Tests/SBCS/CMakeLists.txt 1969-12-31 18:00:00.000000000 -0600
+++ cmake-2.8.4/Tests/SBCS/CMakeLists.txt 2011-09-01 10:17:28.421000000 -0500
@@ -0,0 +1,7 @@
+# a SBCS test case
+project (SBCS)
+
+add_definitions(-D_SBCS)
+
+add_executable (SBCS SBCS.cxx)
+
diff -Naur cmake-2.8.4.orig/Tests/SBCS/SBCS.cxx cmake-2.8.4/Tests/SBCS/SBCS.cxx
--- cmake-2.8.4.orig/Tests/SBCS/SBCS.cxx 1969-12-31 18:00:00.000000000 -0600
+++ cmake-2.8.4/Tests/SBCS/SBCS.cxx 2011-09-01 10:17:04.691400000 -0500
@@ -0,0 +1,22 @@
+// Test to verify that _SBCS being defined causes CharacterSet to be set to 0 (Single Byte Character Set)
+
+int main ()
+{
+#ifdef _UNICODE
+ bool UnicodeSet=true;
+#else
+ bool UnicodeSet=false;
+#endif
+
+#ifdef _MBCS
+ bool MBCSSet=true;
+#else
+ bool MBCSSet=false;
+#endif
+
+ // if neither _UNICODE nor _MBCS is set, CharacterSet must be set to SBCS.
+ bool SBCSSet=(!UnicodeSet && !MBCSSet);
+
+ // Reverse boolean to indicate error case correctly
+ return !SBCSSet;
+}
SBCS_git [^] (4,857 bytes) 2012-02-16 16:29 [Show Content] [Hide Content]From 4822cd2013703f528453eef02e043a773fad6901 Mon Sep 17 00:00:00 2001
From: "Aaron C. Meadows" <corwin@shadowguarddev.com>
Date: Thu, 16 Feb 2012 15:27:05 -0600
Subject: [PATCH] + Mantis Bug 12189: Patch to allow setting Single Byte
Character Set for Visual Studio using the
Preprocessor Define _SBCS. This behavior is similar to
the way that _UNICODE and _MBCS work already.
- Added tests to confirm this behavior.
---
Source/cmLocalVisualStudio7Generator.cxx | 4 ++++
Source/cmVisualStudio10TargetGenerator.cxx | 5 +++++
Source/cmVisualStudioGeneratorOptions.cxx | 14 ++++++++++++++
Source/cmVisualStudioGeneratorOptions.h | 1 +
Tests/CMakeLists.txt | 2 ++
Tests/SBCS/CMakeLists.txt | 7 +++++++
Tests/SBCS/SBCS.cxx | 22 ++++++++++++++++++++++
7 files changed, 55 insertions(+), 0 deletions(-)
create mode 100644 Tests/SBCS/CMakeLists.txt
create mode 100644 Tests/SBCS/SBCS.cxx
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 11a0387..a23d6a1 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -774,6 +774,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
{
fout << "\t\t\tCharacterSet=\"1\">\n";
}
+ else if(targetOptions.UsingSBCS())
+ {
+ fout << "\t\t\tCharacterSet=\"0\">\n";
+ }
else
{
fout << "\t\t\tCharacterSet=\"2\">\n";
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9418761..4fd6f97 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -394,6 +394,11 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
{
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
}
+ else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
+ this->ClOptions[*i]->UsingSBCS())
+ {
+ this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
+ }
else
{
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 41230e7..9369af6 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -117,6 +117,20 @@ bool cmVisualStudioGeneratorOptions::UsingUnicode()
}
return false;
}
+//----------------------------------------------------------------------------
+bool cmVisualStudioGeneratorOptions::UsingSBCS()
+{
+ // Look for the a _SBCS definition.
+ for(std::vector<std::string>::const_iterator di = this->Defines.begin();
+ di != this->Defines.end(); ++di)
+ {
+ if(*di == "_SBCS")
+ {
+ return true;
+ }
+ }
+ return false;
+}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::Parse(const char* flags)
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 51a1362..a1a55da 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -48,6 +48,7 @@ public:
// Check for specific options.
bool UsingUnicode();
+ bool UsingSBCS();
bool IsDebug();
// Write options to output.
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 9c97828..da656d4 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1306,6 +1306,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
endif()
IF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio")
+ ADD_TEST_MACRO(SBCS SBCS)
+
ADD_TEST(VSExternalInclude ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/VSExternalInclude"
diff --git a/Tests/SBCS/CMakeLists.txt b/Tests/SBCS/CMakeLists.txt
new file mode 100644
index 0000000..d663e48
--- /dev/null
+++ b/Tests/SBCS/CMakeLists.txt
@@ -0,0 +1,7 @@
+# a SBCS test case
+project (SBCS)
+
+add_definitions(-D_SBCS)
+
+add_executable (SBCS SBCS.cxx)
+
diff --git a/Tests/SBCS/SBCS.cxx b/Tests/SBCS/SBCS.cxx
new file mode 100644
index 0000000..6ce2c9f
--- /dev/null
+++ b/Tests/SBCS/SBCS.cxx
@@ -0,0 +1,22 @@
+// Test to verify that _SBCS being defined causes CharacterSet to be set to 0 (Single Byte Character Set)
+
+int main ()
+{
+#ifdef _UNICODE
+ bool UnicodeSet=true;
+#else
+ bool UnicodeSet=false;
+#endif
+
+#ifdef _MBCS
+ bool MBCSSet=true;
+#else
+ bool MBCSSet=false;
+#endif
+
+ // if neither _UNICODE nor _MBCS is set, CharacterSet must be set to SBCS.
+ bool SBCSSet=(!UnicodeSet && !MBCSSet);
+
+ // Reverse boolean to indicate error case correctly
+ return !SBCSSet;
+}
--
1.7.5.4
|