MantisBT - CMake
View Issue Details
0012930CMakeCMakepublic2012-02-03 07:162014-08-21 15:46
Eugene Golushkov 
Brad King 
normalfeaturehave not tried
closedfixed 
CMake 2.8.8 
CMake 2.8.10CMake 2.8.10 
0012930: [patch] CMake does not support Visual Studio 11 WinRT project type
CMake currently does not support setting project type as needed to develop WinRT applications for Windows 8 with the Visual Studio 10 generator.
 
Patch is based on a similar patch for .NET project types from here: http://public.kitware.com/Bug/view.php?id=12586 [^]

The attached patch adds support for two new project properties:
 
VS_WINRT_EXTENSIONS: Boolean property that correspond to "Enable Tailored Features" in Visual Studio 11 IDE.
 
VS_WINRT_REFERENCES: Semicolon-delimited list of *.winmd references to add to the project, which creates a new <ItemGroup>.
No tags attached.
related to 0012586closed Brad King [patch] CMake does not support Visual Studio projects types or dotnet references with managed C++ 
related to 0013498closed  CMake does not fully support Visual Studio 11 WinRT project type 
related to 0013511closed Brad King Add support for WinRT platforms and "metro" apps 
related to 0013749closed  Cannot target Windows 8 RT from CMake without workarounds. 
txt cmake_winrt.patch.txt (3,796) 2012-02-03 07:17
https://public.kitware.com/Bug/file/4201/cmake_winrt.patch.txt
patch 0001-VS11-Rename-Immersive-to-WindowsAppContainer-12930.patch (1,425) 2012-08-21 12:10
https://public.kitware.com/Bug/file/4430/0001-VS11-Rename-Immersive-to-WindowsAppContainer-12930.patch
Issue History
2012-02-03 07:16Eugene GolushkovNew Issue
2012-02-03 07:17Eugene GolushkovFile Added: cmake_winrt.patch.txt
2012-02-03 09:04Brad KingRelationship addedrelated to 0012586
2012-02-03 10:23Brad KingNote Added: 0028459
2012-02-03 11:04Eugene GolushkovNote Added: 0028463
2012-02-03 11:09Eugene GolushkovNote Added: 0028464
2012-02-03 14:30Brad KingNote Added: 0028467
2012-02-03 14:30Brad KingAssigned To => Brad King
2012-02-03 14:30Brad KingStatusnew => assigned
2012-02-03 14:46Brad KingNote Added: 0028468
2012-02-03 14:46Brad KingStatusassigned => resolved
2012-02-03 14:46Brad KingResolutionopen => fixed
2012-04-19 15:48David ColeFixed in Version => CMake 2.8.8
2012-04-19 15:48David ColeTarget Version => CMake 2.8.8
2012-08-21 11:36Eugene GolushkovNote Added: 0030717
2012-08-21 11:36Eugene GolushkovStatusresolved => feedback
2012-08-21 11:36Eugene GolushkovResolutionfixed => reopened
2012-08-21 11:42Brad KingNote Added: 0030718
2012-08-21 11:46Eugene GolushkovNote Added: 0030719
2012-08-21 11:46Eugene GolushkovStatusfeedback => assigned
2012-08-21 12:10Brad KingFile Added: 0001-VS11-Rename-Immersive-to-WindowsAppContainer-12930.patch
2012-08-21 12:11Brad KingNote Added: 0030720
2012-08-21 12:11Brad KingProduct VersionCMake 2.8.7 => CMake 2.8.8
2012-08-21 12:11Brad KingFixed in VersionCMake 2.8.8 =>
2012-08-21 12:11Brad KingTarget VersionCMake 2.8.8 => CMake 2.8.10
2012-08-21 12:15Eugene GolushkovNote Added: 0030721
2012-08-21 12:17Eugene GolushkovNote Added: 0030722
2012-08-21 12:24Eugene GolushkovNote Added: 0030723
2012-08-21 12:24Eugene GolushkovNote Edited: 0030723bug_revision_view_page.php?bugnote_id=30723#r776
2012-08-21 12:48Brad KingNote Added: 0030724
2012-08-21 12:55Eugene GolushkovNote Added: 0030725
2012-08-21 12:55Eugene GolushkovNote Edited: 0030725bug_revision_view_page.php?bugnote_id=30725#r778
2012-08-21 13:03Brad KingNote Edited: 0030724bug_revision_view_page.php?bugnote_id=30724#r780
2012-08-21 13:07Brad KingNote Added: 0030726
2012-08-22 06:38Eugene GolushkovNote Added: 0030732
2012-08-22 06:39Eugene GolushkovNote Edited: 0030732bug_revision_view_page.php?bugnote_id=30732#r782
2012-08-22 06:46Eugene GolushkovNote Added: 0030733
2012-08-22 06:53Eugene GolushkovNote Edited: 0030733bug_revision_view_page.php?bugnote_id=30733#r784
2012-08-22 09:19Brad KingNote Added: 0030734
2012-08-22 15:42Brad KingNote Added: 0030735
2012-08-29 09:55Brad KingNote Added: 0030794
2012-08-29 09:55Brad KingStatusassigned => resolved
2012-08-29 09:55Brad KingResolutionreopened => fixed
2012-08-29 09:55Brad KingFixed in Version => CMake 2.8.10
2012-08-30 13:03Brad KingRelationship addedrelated to 0013498
2012-09-03 10:21Brad KingRelationship addedrelated to 0013511
2012-09-03 10:22Brad KingRelationship deletedrelated to 0013511
2012-09-03 10:25Brad KingRelationship addedrelated to 0013511
2012-11-28 08:33Brad KingRelationship addedrelated to 0013749
2013-04-17 08:54Robert MaynardNote Added: 0032886
2013-04-17 08:54Robert MaynardStatusresolved => closed

Notes
(0028459)
Brad King   
2012-02-03 10:23   
The patch looks pretty good but needs a few tweaks. First, a compilation error:

- this->WriteString("<Immersive>true</Immersive>");
+ this->WriteString("<Immersive>true</Immersive>\n", 2);

Second, the WriteWinRTReferences method parses ;-separated lists on its own. CMake makes broad use of ;-separated lists and has a standard internal method called cmSystemTools::ExpandListArgument. Please convert the implementation to use that.
(0028463)
Eugene Golushkov   
2012-02-03 11:04   
I will try to fix this, but I can not test my changes, as CMake can not bootstrap itself on Win8+VS11, and as primarily Mac developer I have no access to other Windows machines.
(0028464)
Eugene Golushkov   
2012-02-03 11:09   
BTW, on Win8+VS11 it decide that
>//Does the compiler support headers like iostream.
>CMAKE_NO_ANSI_STREAM_HEADERS:INTERNAL=1
(0028467)
Brad King   
2012-02-03 14:30   
Re 0012930:0028463: I just noticed that your pattern was taken from the change in 0012586 where I missed this ;-parsing issue. I'll take your patch as-is and then add a commit to fix up the list handling.
(0028468)
Brad King   
2012-02-03 14:46   
Applied patch with compilation fix:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9e01aefd [^]

and fixed the ;-separated value parsing:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a03447b3 [^]

Thanks for your contribution!

Re 0012930:0028464: While interesting, the problem is not in the scope of this issue.
(0030717)
Eugene Golushkov   
2012-08-21 11:36   
In VS 2012 RTM things changed.

VS_WINRT_EXTENSIONS should create "<WindowsAppContainer>true</WindowsAppContainer>" tag instead of "<Immersive>true</Immersive>". Also ability to specify set_target_properties(X PROPERTIES COMPILE_FLAGS "/ZW") is crucial.
(0030718)
Brad King   
2012-08-21 11:42   
Re 0012930:0030717: VS 2012 is the official VS version 11 release. The VS 11 preview has expired so no one should be using it anymore. So we need "Immersive" for VS 10 and "WindowsAppContainer" for VS 11?
(0030719)
Eugene Golushkov   
2012-08-21 11:46   
No, we don`t need Immersive at all - it was prerelease name of what is now known as WindowsAppContainer, and it always was VS11 aka VS2012 feature - no VS10 aka VS2010 involved.
(0030720)
Brad King   
2012-08-21 12:11   
How does "0001-VS11-Rename-Immersive-to-WindowsAppContainer-12930.patch" look?
(0030721)
Eugene Golushkov   
2012-08-21 12:15   
"<WindowsAppContainer>true</WindowsAppContainer>" causes MSBuild to use another set of rules to build the project, another defaults, defines, API subset and so on. This setting is called "Windows Store App Support" in the VS2012 RTM.

In VS11 beta it also causes flag "/ZW" ("Consume Windows Runtime Extension") to be passed to the C++ compiler automatically. But in RTM this flag is not longer passed automatically, as there can be dependencies that are compatible with WinRT but not depended on it, like zlib and other. Therefore for projects that are actually depended on WinRT such flag should be passed manually, via set_target_properties(X PROPERTIES COMPILE_FLAGS "/ZW") for example, but now this flag is unrecognized and lost, despite that for example set_target_properties(X PROPERTIES COMPILE_FLAGS "/bigobj") flag is passed.

And last issue - if "<WindowsAppContainer>true</WindowsAppContainer>" is specified and no "Create/Use/Don`t use Precompiled Headers" ("/Yc", "/Yu", "/Y-") flag is specified explicitly - than MSBuild uses implicit default of "Use Precompiled Header" instead of usual "Don`t use" default. This behavior can not be suppressed via set_target_properties(X PROPERTIES COMPILE_FLAGS "/Y-"), so it would be nice if CMake generated files would always explicitly disable precompiled headers if they was not enabled by the user via "/Yc" or "/Yu' option. This can be done via default "<PrecompiledHeader>NotUsing</PrecompiledHeader>" subtag of <ClCompile> tag
(0030722)
Eugene Golushkov   
2012-08-21 12:17   
Yeah, patch solves first of the three problems
(0030723)
Eugene Golushkov   
2012-08-21 12:24   
BTW, I`m author of the Ogre`s WinRT port, and want to simplify bootstrapping process, as https://bitbucket.org/sinbad/ogre/src/2aea1c30ffa5/BuildingOgreWinRT.txt [^] is already too big.

(0030724)
Brad King   
2012-08-21 12:48   
(edited on: 2012-08-21 13:03)
Re 0012930:0030722: Patch for that problem applied:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4c9ae472 [^]

Re 0012930:0030721: The /ZW flag does not appear in our table of compiler flags:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmVS10CLFlagTable.h;hb=v2.8.9 [^]

probably because it hasn't been updated for VS 11. We may need to generate a new one.

Try this patch for the precompiled header problem:
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx

index 53b6a9b..45bb948 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1492,6 +1492,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&

   
linkOptions.AddFlag("ImportLibrary", imLib.c_str());
   linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
+  linkOptions.AddFlag("PrecompiledHeader", "NotUsing");
   linkOptions.Parse(flags.c_str());
   if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
     {


(0030725)
Eugene Golushkov   
2012-08-21 12:55   
No no no, it should be inside cmVisualStudio10TargetGenerator::WriteClOptions(), not inside cmVisualStudio10TargetGenerator::WriteLinkOptions()

(0030726)
Brad King   
2012-08-21 13:07   
Re 0012930:0030725: Oops! How about this:

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx

index 53b6a9b..b8b57e6 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1204,6 +1204,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
   // Get preprocessor definitions for this directory.
   std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
   clOptions.FixExceptionHandlingDefault();
+  clOptions.AddFlag("PrecompiledHeader", "NotUsing");
   clOptions.Parse(flags.c_str());
   clOptions.Parse(defineFlags.c_str());
   clOptions.AddDefines
(0030732)
Eugene Golushkov   
2012-08-22 06:38   
(edited on: 2012-08-22 06:39)
> + clOptions.AddFlag("PrecompiledHeader", "NotUsing");

Works like a charm, in both cases, when user ask to use pch, and when say nothing about it.

How about the last issue, "/ZW" flag? Can I help you somehow with it?

(0030733)
Eugene Golushkov   
2012-08-22 06:46   
(edited on: 2012-08-22 06:53)
BTW, as "<WindowsAppContainer>true</WindowsAppContainer>" corresponds to the UI setting "Windows Store App Support", and "/ZW" flag corresponds to the "Consume Windows Runtime Extension" - may be rename VS_WINRT_EXTENSIONS that influence first but not the second setting to the VS_WINRT_STORE_APP or similar, to remove confusion?

BTW2: In VS2012 RTM all system API metadata was consolidated into the implicitly referenced Platfrom.winmd and Windows.winmd files, that makes VS_WINRT_REFERENCES unnecessary in many cases, when you need only system metadata. But to use such metadata (even those that are implicitly referenced) you need "/ZW" flag, so may be generate it implicitly if VS_WINRT_REFERENCES is set, even if it is empty ?

(0030734)
Brad King   
2012-08-22 09:19   
Re 0012930:0030732: Thanks for testing. Patch applied:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0ae381c [^]

The /ZW flag problem is more general in that we haven't generated flag tables for the VS 11 tools. It's now a work in progress.
(0030735)
Brad King   
2012-08-22 15:42   
Re 0012930:0030734: This commit should add the ZW flag support:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b2dda5d [^]

One may use this command:

  $ git show -C -C 9b2dda5d

in a CMake Git work tree to see the differences from the VS 10 flag table. ZW is among them.
(0030794)
Brad King   
2012-08-29 09:55   
Resolving as fixed for now because the main fixes have been merged to CMake's Git master branch.

Re 0012930:0030733: If you want to do this please base work off master as of commit 78b30939 or later.
(0032886)
Robert Maynard   
2013-04-17 08:54   
Closing resolved issues that have not been updated in more than 4 months.