[cmake-developers] Windows Store generated solution also containing win32 console app?

Robert Goulet Robert.Goulet at autodesk.com
Tue Jan 27 14:58:07 EST 2015

Ok, make sense. However, the generator is essentially the same for both Win32 and WinRT except for a very few properties. Turns out I was able to make a patch, however I don't know if that's going to be rejected because of the way I did it, but it works really well so far.

This allow me to set the target property VS_WINRT_DISABLE on the projects I want, while still targeting Windows Store in the toolchain file. I personally find it cleaner to do that in my CMakeLists.txt files rather than using multiple CMake root projects. It also works for the add_custom_command rule with COMMAND as stated in the documentation: "If COMMAND specifies an executable target (created by the add_executable() command) it will automatically be replaced by the location of the executable created at build time." I can share the same add_custom_command between all platforms instead of having a different one just for Windows Store build.

Let me know your thoughts about it.

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com] 
Sent: Tuesday, January 27, 2015 12:43 PM
To: Robert Goulet
Cc: cmake-developers at cmake.org
Subject: Re: [cmake-developers] Windows Store generated solution also containing win32 console app?

On 01/27/2015 12:03 PM, Robert Goulet wrote:
> CMake uses a global variable that essentially means that the generator 
> targets a Windows Store app. This makes it difficult to hack it to 
> control this per project rather than globally.

This is a fundamental limitation of the design of CMake, not just of the VS generator.  We only support one target arch/platform at a time.
The entire configuration process runs with one platform in mind, and one toolchain per language.  This is the same reason one cannot build host binaries while cross compiling.  Even if one were to hack the VS generator to set the type of one .vcxproj file, it still would not have proper information to generate the other properties in the file.

You could try running CMake with execute_process to generate a second nested build tree, and then include_external_msproject to make one of its .vcxproj files available in the outer .sln.  I've not tried this though.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: vs-winrt-disable.patch
Type: application/octet-stream
Size: 5943 bytes
Desc: vs-winrt-disable.patch
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150127/314b94f2/attachment.obj>

More information about the cmake-developers mailing list