see attached patches

This considers most of the patches in mantis. It still has some issues, but it's easier to post follow up patches to improve an existing code base, than starting with nothing.

-- Patrick
From 67bd522e90cdef9f857f57ecb1f41148c518476e Mon Sep 17 00:00:00 2001
From: Patrick Gansterer <par...@paroga.com>
Date: Sat, 14 Jul 2012 11:23:34 +0200
Subject: [PATCH 1/4] VS: Support setting correct subsystem and entry point
 for WinCE

WinCE has only one SubSystem. So the WIN32_EXECUTABLE property
must be handled via the EntryPointSymbol in the vcproj files.
---
 Source/cmGlobalVisualStudioGenerator.h   |    3 +++
 Source/cmLocalVisualStudio7Generator.cxx |   20 +++++++++++++++++---
 Source/cmLocalVisualStudio7Generator.h   |    1 +
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/Source/cmGlobalVisualStudioGenerator.h 
b/Source/cmGlobalVisualStudioGenerator.h
index f2fbefd..5c8228a 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -69,6 +69,9 @@ public:
       i.e. "Can I build Debug and Release in the same tree?" */
   virtual bool IsMultiConfig() { return true; }
 
+  /** Return true if building for Windows CE */
+  virtual bool TargetsWindowsCE() const { return false; }
+
   class TargetSet: public std::set<cmTarget*> {};
   struct TargetCompare
   {
diff --git a/Source/cmLocalVisualStudio7Generator.cxx 
b/Source/cmLocalVisualStudio7Generator.cxx
index f2ab79d..5d0d4d6 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -229,6 +229,9 @@ void cmLocalVisualStudio7Generator
   this->FortranProject =
     static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
     ->TargetIsFortranOnly(target);
+  this->WindowsCEProject =
+    static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
+    ->TargetsWindowsCE();
 
   // Intel Fortran for VS10 uses VS9 format ".vfproj" files.
   VSVersion realVersion = this->Version;
@@ -1172,6 +1175,8 @@ void 
cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
     cmComputeLinkInformation& cli = *pcli;
     const char* linkLanguage = cli.GetLinkLanguage();
 
+    bool isWin32Executable = target.GetPropertyAsBool("WIN32_EXECUTABLE");
+
     // Compute the variable name to lookup standard libraries for this
     // language.
     std::string standardLibsVar = "CMAKE_";
@@ -1219,15 +1224,24 @@ void 
cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
       {
       fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
       }
-    if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") )
+    if ( this->WindowsCEProject )
+      {
+      fout << "\t\t\t\tSubSystem=\"9\"\n"
+           << "\t\t\t\tEntryPointSymbol=\""
+           << (isWin32Executable ? "WinMainCRTStartup" : "mainACRTStartup")
+           << "\"\n";
+      }
+    else if ( this->FortranProject )
       {
       fout << "\t\t\t\tSubSystem=\""
-           << (this->FortranProject? "subSystemWindows" : "2") << "\"\n";
+           << (isWin32Executable ? "subSystemWindows" : "subSystemConsole")
+           << "\"\n";
       }
     else
       {
       fout << "\t\t\t\tSubSystem=\""
-           << (this->FortranProject? "subSystemConsole" : "1") << "\"\n";
+           << (isWin32Executable ? "2" : "1")
+           << "\"\n";
       }
     std::string stackVar = "CMAKE_";
     stackVar += linkLanguage;
diff --git a/Source/cmLocalVisualStudio7Generator.h 
b/Source/cmLocalVisualStudio7Generator.h
index 9aa408e..9ce25df 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -122,6 +122,7 @@ private:
   cmVS7FlagTable const* ExtraFlagTable;
   std::string ModuleDefinitionFile;
   bool FortranProject;
+  bool WindowsCEProject;
   std::string PlatformName; // Win32 or x64 
   cmLocalVisualStudio7GeneratorInternals* Internal;
 };
-- 
1.7.10.msysgit.1

From 910b9b6feec9a48fda5751d84f238005fee8db79 Mon Sep 17 00:00:00 2001
From: Patrick Gansterer <par...@paroga.com>
Date: Sat, 14 Jul 2012 11:49:12 +0200
Subject: [PATCH 2/4] VS: Added cmGlobalGenerator::AddTryCompileCacheEntries()

---
 Source/cmGlobalGenerator.h |    3 +++
 Source/cmMakefile.cxx      |    1 +
 2 files changed, 4 insertions(+)

diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index ce91793..ebf3d80 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -50,6 +50,9 @@ public:
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry) const;
 
+  ///! Add inital cache entries for TryCompile.
+  virtual void AddTryCompileCacheEntries(cmake& cm) { };
+
   /**
    * Create LocalGenerators and process the CMakeLists files. This does not
    * actually produce any makefiles, DSPs, etc.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 7b6c450..0c13534 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2948,6 +2948,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
   cm.SetStartOutputDirectory(bindir);
   cm.SetCMakeCommand(cmakeCommand.c_str());
   cm.LoadCache();
+  this->LocalGenerator->GetGlobalGenerator()->AddTryCompileCacheEntries(cm);
   if(!gg->IsMultiConfig())
     {
     if(const char* config =
-- 
1.7.10.msysgit.1

From 0ac14cf55aca6cf63aad9828ef56fad20f5209cb Mon Sep 17 00:00:00 2001
From: Patrick Gansterer <par...@paroga.com>
Date: Sat, 14 Jul 2012 12:03:23 +0200
Subject: [PATCH 3/4] VS: Add support for CMAKE_WINCE_SDK varibale

If set CMake will look up the SDK in the WCE.VCPlatform.config
and if successful, the CMake variables for cross compiling will
be set to the corresponding values.
---
 Source/cmGlobalVisualStudio8Generator.cxx |  238 +++++++++++++++++++++++++++++
 Source/cmGlobalVisualStudio8Generator.h   |   19 ++-
 2 files changed, 255 insertions(+), 2 deletions(-)

diff --git a/Source/cmGlobalVisualStudio8Generator.cxx 
b/Source/cmGlobalVisualStudio8Generator.cxx
index 1c6385d..a010f20 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -15,6 +15,169 @@
 #include "cmMakefile.h"
 #include "cmake.h"
 #include "cmGeneratedFileStream.h"
+#include "cmXMLParser.h"
+
+
+// This class is used to parse XML with configuration
+// of installed SDKs in system
+class cmGlobalVisualStudio8Generator::cmWCEConfigParser : public cmXMLParser
+{
+public:
+  cmWCEConfigParser(const char* name)
+      : RequiredName(name)
+      , FoundRequiredName(false)
+    {
+    }
+
+  bool Found() const {return this->FoundRequiredName;}
+
+  std::string GetOSVersion() const
+    {
+    if (this->OSMinorVersion.empty())
+      {
+      return OSMajorVersion;
+      }
+
+    return OSMajorVersion + "." + OSMinorVersion;
+    }
+
+  const char* GetInstructionset() const
+    {
+    std::map<std::string, std::string>::const_iterator it =
+      this->Macros.find("INSTRUCTIONSET");
+    if (it != this->Macros.end())
+      {
+      return it->second.c_str();
+      }
+
+    return 0;
+    }
+
+  const char* GetArchitectureId() const
+    {
+    struct Instructionset2ArchitectureId
+      {
+        const char* Instructionset;
+        const char* ArchitectureId;
+      };
+
+    static const Instructionset2ArchitectureId convertInfo[] =
+      {
+        {"ARMV4",     "ARM" },
+        {"ARMV4I",    "THUMB"},
+        {"MIPSII",    "MIPS"},
+        {"MIPSII_FP", "MIPSFPU"},
+        {"MIPSIV",    "MIPS16"},
+        {"MIPSIV_FP", "MIPSFPU16"},
+        {"SH4",       "SH4"},
+        {"x86",       "X86"}
+      };
+
+    const char* instructionset = this->GetInstructionset();
+
+    if (!instructionset)
+      {
+      return 0;
+      }
+
+    // find corresponding flag value for obtained architecture
+    for(int i = 0; i < sizeof(convertInfo) / sizeof(convertInfo[0]); ++i)
+      {
+      if(strcmp(instructionset, convertInfo[i].Instructionset) == 0)
+        {
+        return convertInfo[i].ArchitectureId;
+        }
+      }
+
+    return 0;
+    }
+
+  virtual void StartElement(const char* name, const char** attributes)
+    {
+    if(this->FoundRequiredName)
+      {
+      return;
+      }
+
+    this->CharacterData.clear();
+
+    if(strcmp(name, "PlatformData") == 0)
+      {
+      this->PlatformName.clear();
+      this->OSMajorVersion.clear();
+      this->OSMinorVersion.clear();
+      this->Macros.clear();
+      }
+
+    if(strcmp(name, "Macro") == 0)
+      {
+      std::string name;
+      std::string value;
+
+      for(const char** attr = attributes; *attr; attr += 2)
+        {
+        if(strcmp(attr[0], "Name") == 0)
+          {
+          name = attr[1];
+          }
+        else if(strcmp(attr[0], "Value") == 0)
+          {
+          value = attr[1];
+          }
+        }
+
+      if(!name.empty())
+        {
+        this->Macros[name] = value;
+        }
+      }
+    }
+
+  void EndElement(const char* name)
+    {
+    if(this->FoundRequiredName)
+      {
+      return;
+      }
+
+    if(strcmp(name, "PlatformName") == 0)
+      {
+      this->PlatformName = this->CharacterData;
+      }
+    else if(strcmp(name, "OSMajorVersion") == 0)
+      {
+      this->OSMajorVersion = this->CharacterData;
+      }
+    else if(strcmp(name, "OSMinorVersion") == 0)
+      {
+      this->OSMinorVersion = this->CharacterData;
+      }
+    else if(strcmp(name, "Platform") == 0)
+      {
+      if(this->PlatformName == this->RequiredName)
+        {
+        this->FoundRequiredName = true;
+        }
+      }
+    }
+
+   void CharacterDataHandler(const char* data, int length)
+   {
+     this->CharacterData.append(data, length);
+   }
+
+private:
+  std::string CharacterData;
+
+  std::string PlatformName;
+  std::string OSMajorVersion;
+  std::string OSMinorVersion;
+  std::map<std::string, std::string> Macros;
+
+  bool FoundRequiredName;
+  const char* RequiredName;
+};
+
 
 //----------------------------------------------------------------------------
 cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
@@ -22,6 +185,7 @@ 
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
   this->VersionId = "MSVC80";
   this->FindMakeProgramFile = "CMakeVS8FindMake.cmake";
   this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
+  this->WindowsCE = false;
 }
 
 //----------------------------------------------------------------------------
@@ -54,13 +218,87 @@ void cmGlobalVisualStudio8Generator
 }
 
 //----------------------------------------------------------------------------
+void cmGlobalVisualStudio8Generator::AddTryCompileCacheEntries(cmake& cm)
+{
+  const char* sdk =
+    this->GetCMakeInstance()->GetCacheDefinition("CMAKE_WINCE_SDK");
+  if(sdk)
+    {
+    cm.AddCacheEntry("CMAKE_WINCE_SDK", sdk, "", cmCacheManager::INTERNAL);
+    }
+}
+
+//----------------------------------------------------------------------------
 void cmGlobalVisualStudio8Generator::Configure()
 {
+  this->ConfigurePlatform();
   this->cmGlobalVisualStudio7Generator::Configure();
   this->CreateGUID(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
 }
 
 //----------------------------------------------------------------------------
+void cmGlobalVisualStudio8Generator::ConfigurePlatform()
+{
+  const char* sdk =
+    this->GetCMakeInstance()->GetCacheDefinition("CMAKE_WINCE_SDK");
+  if(!sdk)
+    {
+    this->PlatformName = "Win32";
+    return;
+    }
+
+  if(!this->ConfigurePlatformSDK(sdk))
+    {
+    cmSystemTools::Error(
+      "CMAKE_WINCE_SDK must be a valid Windows CE platform SDK!");
+    cmSystemTools::SetFatalErrorOccured();
+    }
+}
+
+//----------------------------------------------------------------------------
+bool cmGlobalVisualStudio8Generator::ConfigurePlatformSDK(const char* name)
+{
+  std::string vskey = this->GetRegistryBase();
+  vskey += "\\Setup\\VS;ProductDir";
+
+  std::string vsInstallPath;
+  if(!cmSystemTools::ReadRegistryValue(vskey.c_str(), vsInstallPath))
+    {
+    return false;
+    }
+  cmSystemTools::ConvertToUnixSlashes(vsInstallPath);
+
+  const std::string configFilename =
+    vsInstallPath + "/VC/vcpackages/WCE.VCPlatform.config";
+
+  // parse XML containing all information that we need
+  cmWCEConfigParser parser(name);
+  parser.ParseFile(configFilename.c_str());
+
+  if(!parser.Found())
+    {
+    return false;
+    }
+
+  this->ArchitectureId = parser.GetArchitectureId();
+  this->PlatformName = name;
+  this->WindowsCE = true;
+
+  this->GetCMakeInstance()->AddCacheEntry("CMAKE_SYSTEM_NAME",
+    "WindowsCE", "", cmCacheManager::INTERNAL);
+  this->GetCMakeInstance()->AddCacheEntry("CMAKE_SYSTEM_VERSION",
+    parser.GetOSVersion().c_str(), "", cmCacheManager::INTERNAL);
+  this->GetCMakeInstance()->AddCacheEntry("CMAKE_SYSTEM_PROCESSOR",
+    parser.GetArchitectureId(), "", cmCacheManager::INTERNAL);
+  this->GetCMakeInstance()->AddCacheEntry("CMAKE_C_COMPILER",
+    "cl", "", cmCacheManager::INTERNAL);
+  this->GetCMakeInstance()->AddCacheEntry("CMAKE_CXX_COMPILER",
+    "cl", "", cmCacheManager::INTERNAL);
+
+  return this->ArchitectureId && !this->PlatformName.empty();
+}
+
+//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio8Generator::GetUserMacrosDirectory()
 {
   // Some VS8 sp0 versions cannot run macros.
diff --git a/Source/cmGlobalVisualStudio8Generator.h 
b/Source/cmGlobalVisualStudio8Generator.h
index 6982896..ffb66a4 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -32,11 +32,15 @@ public:
     return cmGlobalVisualStudio8Generator::GetActualName();}
   static const char* GetActualName() {return "Visual Studio 8 2005";}
 
-  virtual const char* GetPlatformName() const {return "Win32";}
+  virtual const char* GetPlatformName() const {
+    return this->PlatformName.c_str();}
 
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry) const;
-  
+
+  ///! Add inital cache entries for TryCompile.
+  virtual void AddTryCompileCacheEntries(cmake& cm);
+
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
@@ -64,6 +68,9 @@ public:
       LinkLibraryDependencies and link to .sln dependencies. */
   virtual bool NeedLinkLibraryDependencies(cmTarget& target);
 
+  /** Return true if building for Windows CE */
+  virtual bool TargetsWindowsCE() const { return this->WindowsCE; }
+
 protected:
   virtual const char* GetIDEVersion() { return "8.0"; }
 
@@ -81,5 +88,13 @@ protected:
   virtual bool ComputeTargetDepends();
   virtual void WriteProjectDepends(std::ostream& fout, const char* name,
                                    const char* path, cmTarget &t);
+
+private:
+  class cmWCEConfigParser;
+
+  void ConfigurePlatform();
+  bool ConfigurePlatformSDK(const char* name);
+  std::string PlatformName;
+  bool WindowsCE;
 };
 #endif
-- 
1.7.10.msysgit.1

From da098c1dbdaa2c5843bf1160c6ed9301af508574 Mon Sep 17 00:00:00 2001
From: Patrick Gansterer <par...@paroga.com>
Date: Sat, 14 Jul 2012 12:04:45 +0200
Subject: [PATCH 4/4] VS: Added "Deploy" at project configuration for
 WindowsCE targets

---
 Source/cmGlobalVisualStudio71Generator.cxx |    2 +-
 Source/cmGlobalVisualStudio71Generator.h   |    1 +
 Source/cmGlobalVisualStudio7Generator.cxx  |    6 +++---
 Source/cmGlobalVisualStudio7Generator.h    |    1 +
 Source/cmGlobalVisualStudio8Generator.cxx  |   10 ++++++++++
 Source/cmGlobalVisualStudio8Generator.h    |    1 +
 6 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index d6b653c..9073798 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -282,7 +282,7 @@ void cmGlobalVisualStudio71Generator
 // executables to the libraries it uses are also done here
 void cmGlobalVisualStudio71Generator
 ::WriteProjectConfigurations(std::ostream& fout, const char* name,
-                             bool partOfDefaultBuild,
+                             cmTarget::TargetType, bool partOfDefaultBuild,
                              const char* platformMapping)
 {
   std::string guid = this->GetGUID(name);
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 503b708..13af723 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -64,6 +64,7 @@ protected:
                            const char* name, const char* path, cmTarget &t);
   virtual void WriteProjectConfigurations(std::ostream& fout,
                                           const char* name,
+                                          cmTarget::TargetType type,
                                           bool partOfDefaultBuild,
                                           const char* platformMapping = NULL);
   virtual void WriteExternalProject(std::ostream& fout,
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 5380e23..ed79b17 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -245,7 +245,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
     if(expath)
       {
       this->WriteProjectConfigurations(
-        fout, target->GetName(),
+        fout, target->GetName(), target->GetType(),
         true, target->GetProperty("VS_PLATFORM_MAPPING"));
       }
     else
@@ -256,7 +256,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
         target->GetProperty("GENERATOR_FILE_NAME");
       if (vcprojName)
         {
-        this->WriteProjectConfigurations(fout, vcprojName,
+        this->WriteProjectConfigurations(fout, vcprojName, target->GetType(),
                                          partOfDefaultBuild);
         }
       }
@@ -579,7 +579,7 @@ cmGlobalVisualStudio7Generator
 // executables to the libraries it uses are also done here
 void cmGlobalVisualStudio7Generator
 ::WriteProjectConfigurations(std::ostream& fout, const char* name,
-                             bool partOfDefaultBuild,
+                             cmTarget::TargetType, bool partOfDefaultBuild,
                              const char* platformMapping)
 {
   std::string guid = this->GetGUID(name);
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 1df58f9..099cf8c 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -107,6 +107,7 @@ protected:
                            const char* name, const char* path, cmTarget &t);
   virtual void WriteProjectConfigurations(std::ostream& fout,
                                           const char* name,
+                                          cmTarget::TargetType type,
                                           bool partOfDefaultBuild,
                                           const char* platformMapping = NULL);
   virtual void WriteSLNFooter(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index a010f20..4a9fc70 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -498,6 +498,7 @@ cmGlobalVisualStudio8Generator
 void
 cmGlobalVisualStudio8Generator
 ::WriteProjectConfigurations(std::ostream& fout, const char* name,
+                             cmTarget::TargetType type,
                              bool partOfDefaultBuild,
                              const char* platformMapping)
 {
@@ -516,6 +517,15 @@ cmGlobalVisualStudio8Generator
            << (platformMapping ? platformMapping : this->GetPlatformName())
            << "\n";
       }
+    bool needsDeploy = (type == cmTarget::EXECUTABLE ||
+                        type == cmTarget::SHARED_LIBRARY);
+    if(this->WindowsCE && needsDeploy)
+      {
+      fout << "\t\t{" << guid << "}." << *i
+           << "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|"
+           << (platformMapping ? platformMapping : this->GetPlatformName())
+           << "\n";
+      }
     }
 }
 
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index ffb66a4..589c48c 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -83,6 +83,7 @@ protected:
   virtual void WriteSolutionConfigurations(std::ostream& fout);
   virtual void WriteProjectConfigurations(std::ostream& fout,
                                           const char* name,
+                                          cmTarget::TargetType type,
                                           bool partOfDefaultBuild,
                                           const char* platformMapping = NULL);
   virtual bool ComputeTargetDepends();
-- 
1.7.10.msysgit.1

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to