summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-03-08 20:14:03 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-03-08 20:14:03 (GMT)
commitf55119e63b4063daf6c8cdce5eb5415d04b0c2bd (patch)
tree5afda3c63fb305d3c646c7046f1ea2694afd9411
parent9f6c38253a29288a7f8479d43e7c87fd3d958e79 (diff)
parentb28e7fa174798717ebf8e18b8d97755d3568b04d (diff)
downloadCMake-f55119e63b4063daf6c8cdce5eb5415d04b0c2bd.zip
CMake-f55119e63b4063daf6c8cdce5eb5415d04b0c2bd.tar.gz
CMake-f55119e63b4063daf6c8cdce5eb5415d04b0c2bd.tar.bz2
Merge topic 'fix-12189-support-SBCS-in-VS'
b28e7fa VS6: Avoid SBCS test on VS6 (#12189) df19b9c VS6: Avoid _MBCS define when _SBCS is defined (#12189) ba89e92 Visual Studio: Allow setting Single Byte Character Set (#12189)
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx8
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx4
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx5
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx14
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h1
-rw-r--r--Tests/CMakeLists.txt4
-rw-r--r--Tests/SBCS/CMakeLists.txt6
-rw-r--r--Tests/SBCS/SBCS.cxx22
8 files changed, 61 insertions, 3 deletions
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index c846d6b..6b31e54 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -1620,11 +1620,13 @@ void cmLocalVisualStudio6Generator
flagsDebugRel = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
}
-
- // if unicode is not found, then add -D_MBCS
+
+ // if _UNICODE and _SBCS are not found, then add -D_MBCS
std::string defs = this->Makefile->GetDefineFlags();
if(flags.find("D_UNICODE") == flags.npos &&
- defs.find("D_UNICODE") == flags.npos)
+ defs.find("D_UNICODE") == flags.npos &&
+ flags.find("D_SBCS") == flags.npos &&
+ defs.find("D_SBCS") == flags.npos)
{
flags += " /D \"_MBCS\"";
}
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 1743517..fdd58f8 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 f9148a1..27b83b9 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 53c59cc..07a6c36 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1338,6 +1338,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
endif()
IF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio")
+ IF(NOT MSVC60)
+ ADD_TEST_MACRO(SBCS SBCS)
+ ENDIF(NOT MSVC60)
+
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..b3c3c2c
--- /dev/null
+++ b/Tests/SBCS/CMakeLists.txt
@@ -0,0 +1,6 @@
+# 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;
+}