Here is an update version of my patchset: It also works with older versions of Windows CE but it tells the user that he might to manually se the CMAKE_PLATFORM_TOOLSET
(I hope the resubmission is OK like this) >From 145c3189abf84aca046f555c5452396f0e5936eb Mon Sep 17 00:00:00 2001 From: Pascal Bach <pascal.b...@siemens.com> Date: Thu, 4 Sep 2014 13:32:30 +0200 Subject: [PATCH] WINCE, VS: Allow selecting an SDK for Windows CE on Visual Studio - Allow setting CMAKE_VS_WINCE_SDK to specify the SDK. - The user is warned if he uses a version different Windows CE different from 8.0 and not CMAKE_PLATFORM_TOOLSET is specified. - Docuentation for WINCE and CMAKE_VS_WINCE_SDK added. --- Help/variable/CMAKE_VS_WINCE_SDK.rst | 13 +++++++ Help/variable/WINCE.rst | 5 +++ Source/cmGlobalVisualStudio10Generator.cxx | 55 ++++++++++++++++++++++++++++ Source/cmGlobalVisualStudio10Generator.h | 7 ++++ Source/cmGlobalVisualStudio11Generator.cxx | 12 ++++++ Source/cmGlobalVisualStudio11Generator.h | 2 + Source/cmGlobalVisualStudio12Generator.cxx | 12 ++++++ Source/cmGlobalVisualStudio12Generator.h | 2 + 8 files changed, 108 insertions(+) create mode 100644 Help/variable/CMAKE_VS_WINCE_SDK.rst create mode 100644 Help/variable/WINCE.rst diff --git a/Help/variable/CMAKE_VS_WINCE_SDK.rst b/Help/variable/CMAKE_VS_WINCE_SDK.rst new file mode 100644 index 0000000..ef39b84 --- /dev/null +++ b/Help/variable/CMAKE_VS_WINCE_SDK.rst @@ -0,0 +1,13 @@ +CMAKE_VS_WINCE_SDK +------------------ + +Windows CE SDK to use together with the Visual Studio 10+ generators. + +If :variable:`CMAKE_SYSTEM_NAME` is set to Windows CE, this variable +allows to specify the SDK name that should be used to build the application. + +The value of this variable should never be modified by project code. +A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE` +variable may initialize ``CMAKE_VS_WINCE_SDK``. Once a given +build tree has been initialized with a particular value for this +variable, changing the value has undefined behavior. diff --git a/Help/variable/WINCE.rst b/Help/variable/WINCE.rst new file mode 100644 index 0000000..54ff7de --- /dev/null +++ b/Help/variable/WINCE.rst @@ -0,0 +1,5 @@ +WINCE +----- + +True when the :variable:`CMAKE_SYSTEM_NAME` variable is set +to ``WindowsCE``. diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 19aa52c..81a9723 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -165,6 +165,14 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) return false; } } + else if (this->SystemName == "WindowsCE") + { + this->SystemIsWindowsCE = true; + if (!this->InitializeWindowsCE(mf)) + { + return false; + } + } return true; } @@ -187,6 +195,53 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf) } //---------------------------------------------------------------------------- +bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf) +{ + // To preserve the old behaviour just return the DefaultPlatformToolset + // for unknown Windows CE versions, in the worst case the user has to set + // CMAKE_GENERATOR_TOOLSET manually. In that case warn the user. + std::string platformToolset = this->SelectWindowsCEToolset(); + if (!platformToolset.empty()) + { + this->DefaultPlatformToolset = platformToolset; + } + else + { + cmOStringStream e; + e << this->GetName() << " Windows CE version '" << this->SystemVersion + << "' might require CMAKE_GENERATOR_TOOLSET to be set."; + mf->IssueMessage(cmake::WARNING, e.str()); + } + + if (const char* platformName = mf->GetDefinition("CMAKE_VS_WINCE_SDK")) + { + this->PlatformName = platformName; + } + else { + cmOStringStream e; + e << this->GetName() << " for " << this->GetSystemName() << " requires an " + << "SDK. Please set CMAKE_VS_WINCE_SDK to the name of your SDK."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + + return true; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::SelectWindowsCEToolset() const +{ + if (this->SystemVersion == "8.0") + { + return "CE800"; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator ::AddVSPlatformToolsetDefinition(cmMakefile* mf) const { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 11fa954..9bceb2c 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -75,6 +75,10 @@ public: bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; } + /** Return true if building for WindowsCE */ + bool TargetsWindowsCE() const + { return this->SystemIsWindowsCE; } + /** * Where does this version of Visual Studio look for macros for the * current user? Returns the empty string if this version of Visual @@ -106,8 +110,10 @@ protected: virtual bool InitializeSystem(cmMakefile* mf); virtual bool InitializeWindowsPhone(cmMakefile* mf); virtual bool InitializeWindowsStore(cmMakefile* mf); + virtual bool InitializeWindowsCE(cmMakefile* mf); virtual std::string SelectWindowsPhoneToolset() const { return ""; } virtual std::string SelectWindowsStoreToolset() const { return ""; } + virtual std::string SelectWindowsCEToolset() const; virtual const char* GetIDEVersion() { return "10.0"; } @@ -119,6 +125,7 @@ protected: std::string SystemVersion; bool SystemIsWindowsPhone; bool SystemIsWindowsStore; + bool SystemIsWindowsCE; bool ExpressEdition; bool UseFolderProperty(); diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 39bbdc0..a71c42e 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -159,6 +159,12 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf) } //---------------------------------------------------------------------------- +bool cmGlobalVisualStudio11Generator::InitializeWindowsCE(cmMakefile* mf) +{ + return cmGlobalVisualStudio10Generator::InitializeWindowsCE(mf); +} + +//---------------------------------------------------------------------------- std::string cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset() const { if(this->SystemVersion == "8.0") @@ -179,6 +185,12 @@ std::string cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset() const } //---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio11Generator::SelectWindowsCEToolset() const +{ + return this->cmGlobalVisualStudio10Generator::SelectWindowsCEToolset(); +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index bbd935c..9dd3271 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -36,8 +36,10 @@ public: protected: virtual bool InitializeWindowsPhone(cmMakefile* mf); virtual bool InitializeWindowsStore(cmMakefile* mf); + virtual bool InitializeWindowsCE(cmMakefile* mf); virtual std::string SelectWindowsPhoneToolset() const; virtual std::string SelectWindowsStoreToolset() const; + virtual std::string SelectWindowsCEToolset() const; virtual const char* GetIDEVersion() { return "11.0"; } bool UseFolderProperty(); static std::set<std::string> GetInstalledWindowsCESDKs(); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 29ecfe0..c784cae 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -139,6 +139,12 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf) } //---------------------------------------------------------------------------- +bool cmGlobalVisualStudio12Generator::InitializeWindowsCE(cmMakefile* mf) +{ + return cmGlobalVisualStudio11Generator::InitializeWindowsCE(mf); +} + +//---------------------------------------------------------------------------- std::string cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset() const { if(this->SystemVersion == "8.1") @@ -159,6 +165,12 @@ std::string cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset() const } //---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio12Generator::SelectWindowsCEToolset() const +{ + return this->cmGlobalVisualStudio11Generator::SelectWindowsCEToolset(); +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index ec85f10..5d8c125 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -41,8 +41,10 @@ public: protected: virtual bool InitializeWindowsPhone(cmMakefile* mf); virtual bool InitializeWindowsStore(cmMakefile* mf); + virtual bool InitializeWindowsCE(cmMakefile* mf); virtual std::string SelectWindowsPhoneToolset() const; virtual std::string SelectWindowsStoreToolset() const; + virtual std::string SelectWindowsCEToolset() const; virtual const char* GetIDEVersion() { return "12.0"; } private: class Factory; -- 1.7.10.4 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers