[cmake-developers] [PATCH] VS, WINCE: Fix entry point for Unicode builds

Pascal Bach pascal.bach at siemens.com
Tue Dec 2 07:33:42 EST 2014


When _UNICODE is defined VS uses wmain instead of main as the entry function.
To make this correctly work on WindowsCE EntryPointSymbol needs to be set to
mainWCRTStartup instead of mainWCRTStartup for console applications and to
wWinMainCRTStartup instead of WinMainCRTStartup for GUI applications.

Signed-off-by: Pascal Bach <pascal.bach at siemens.com>
---
 Source/cmVisualStudio10TargetGenerator.cxx |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index f591fc8..f969b91 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2268,7 +2268,14 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
         linkOptions.AddFlag("SubSystem", "WindowsCE");
         if (this->Target->GetType() == cmTarget::EXECUTABLE)
           {
-          linkOptions.AddFlag("EntryPointSymbol", "WinMainCRTStartup");
+            if (this->ClOptions[config]->UsingUnicode())
+            {
+              linkOptions.AddFlag("EntryPointSymbol", "wWinMainCRTStartup");
+            }
+            else
+            {
+              linkOptions.AddFlag("EntryPointSymbol", "WinMainCRTStartup");
+            }
           }
         }
       else
@@ -2283,7 +2290,14 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
         linkOptions.AddFlag("SubSystem", "WindowsCE");
         if (this->Target->GetType() == cmTarget::EXECUTABLE)
           {
-          linkOptions.AddFlag("EntryPointSymbol", "mainACRTStartup");
+          if (this->ClOptions[config]->UsingUnicode())
+            {
+              linkOptions.AddFlag("EntryPointSymbol", "mainWCRTStartup");
+            }
+            else
+            {
+              linkOptions.AddFlag("EntryPointSymbol", "mainACRTStartup");
+            }
           }
         }
       else
-- 
1.7.10.4



More information about the cmake-developers mailing list