Source

ogre / BuildingOgreWindowsPhone.txt

Full commit
To build Ogre for Windows Phone some manual steps are required:

1.	Install Windows Phone 8 SDK.
2.	Get the OGRE WinRT dependencies from here: https://bitbucket.org/assaframan/ogre-dependencies-for-windows-phone/changesets
3.	
4.	Build dependencies in debug and release config.
5.	Download and install this cmake http://www.cmake.org/files/v2.8/cmake-2.8.9-win32-x86.exe
Now we need to fix cmake to support visual studio express.
6.	Run visual studio express for windows phone 8 as admin (right click panel then "run as admin")
7.	open this file in visual studio "C:\Program Files (x86)\CMake 2.8\share\cmake-2.8\Modules\CMakeVS11FindMake.cmake"
8.	Goto line 19 and change it from:
NAMES devenv
To
NAMES devenv VPDExpress
9.	Open cmake, select source path (make sure you are using OGRE 1.9 or above) and create a build project (visual studio 11 project...)
10.	Set the following cmake parameters:
OGRE_DEPENDENCIES_DIR = the path of the dependencies from previous steps 
OGRE_STATIC = ON
OGRE_UNITY_BUILD = ON
OGRE_BUILD_PLATFORM_WINDOWS_PHONE = ON
Press Config button then set:
OGRE_BUILD_PLATFORM_WINRT = ON
OGRE_CONFIG_ALLOCATOR = 1

11.	Generate solution
12.	Open it
13.	Remove  ALL_BUILD, INSTALL and PACKAGE projects from the solution
14.	Select all projects in the solution tree, right click, properties, select all configs and "win32" platform in the combos at the top of the properties window, select "configuration properties" on the tree on the left of that window, then change "platform toolset" on the right of the window to v110_wp80
15.	Select only RenderSystem_Direct3D11 project in the solution tree, right click, properties, select all configs and "win32" platform in the combos at the top of the properties window, select "configuration properties"->"C++"->"Command line" on the tree on the left of that window, add
/ZW /AI "c:\Program Files (x86)\Windows Phone Kits\8.0\Windows Metadata"
To the command line

16.	Delete OgreWin32Resources.rc from Sample_CubeMapping
17.	Open the configuration manager by right clicking the solution in the solution tree, on the right, active solution platform combo, select new, select arm, copy setting from win32
18.	Add dependencies to solution by right clicking the solution, selecting add existing project, select "solution" in the combo next to the file select edit at the bottom then select the dependencies solution, all the dependencies should be now a part of the solution. Remove OIS Project.
19.	Add the following project to the solution - Samples\Browser\WinRT\SampleBrowserWP8.vcxproj
20.	Change to Phone debug or Phone release config.
21.	Select Win32 or arm platform (win32 for emulation, arm for running on the device)
22.	You may need to add the references to all of the solution projects for this project, so check by opening the "common properties"->"configuration properties" - and see that you don't have any error icons in the references.
23. Right click SampleBrowserWP8 -> Properties -> C++ -> General -> Additional Include Directories
24. Select debug config, select all projects, right click any project from the selected ones -> Properties -> C++ -> Code generation -> Multi threaded Debug DLL (then do the same to release ->  Multi threaded DLL) 

25. right click SampleBrowserWP8 -> Properties -> C++ -> General -> Additional Include Directories 
Add the path of
[your build directory]\include ex: c:\ogre\build6\include
[your dependencies dir]\include ex: C:\ogre\dep\include
[your dependencies dir]\include\ois
26. Select only RenderSystem_Direct3D11 project in the solution tree, right click, properties, select all configs and "win32" platform in the combos at the top of the properties window, select "configuration properties"->"C++"->"Command line" on the tree on the left of that window, add 
/ZW /AI "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Blend\WinMD"
To the command line
27.	Compile.
28.	Before you run for the first time make sure you have a shader cache for the project you are running - as you can't compile shader on the phone. (TODO - explain more)  
29. In Windows Phone and (Store versions of WinRT) you don't have the shader compiler, meaning you have to use the shader cache, they tricky part is that you need to create the shader cache, to do that, compile OGRE for WinRT and add ENABLE_SHADERS_CACHE_SAVE to the preprocessor definitions in the config, run the project, act out all the use cases you are going to do in the final version, then go to the home directory of the  WinRT (I find the home directory by putting a breakpoint in FileSystemLayerImpl_WIN32.cpp line 138) and copy the file cache.bin from the OGRE dir there to Samples\Browser\WinRT. 


Note about adding resources - you must right click each resource you want to be copied as part of the release, select "properties", select all configurations and all platforms, set "exclude from build" to "No", "Content" to "Yes", "Item type" to "Does not participate in build" and press the "OK" button. You can also multi select a group of resource and set the properties for all of them together. Note that if the file is under the path of project file - the file will be copied with the relative path to the project file, else it will be at the root of the resources folder of the deployed project. 
Resource related troubleshooting:
1.	When you compile you get shader compiler issues (like "VS_2_0 is doesn't support doing this") - it mean that you didn't set "Item type" to "Does not participate in build".
2.	Missing file exception for some file - you didn't use the relative path, or the file is not in a sub folder in the deployed project because you didn't put it under the project dir, or you didn't set "Content" to "Yes".
3.	A strange compiler\linker error - no message, something about FCX.exe error, this mean that the resource doesn't exist on your drive anymore or that you forgot to set "Item type" to "Does not participate in build". The FCX.exe is a compiler that can compile some resource types - to help with performance, like images and shader. Microsoft idea was that it will help runtime performance - by compiling shaders as part of the compile, this is why they didn't include the shader compiler as part of WinRT. I guess they didn't think of our scenario of runtime shader generation. The way to disable that nice compiler is to "Item type" to "Does not participate in build".  


Note about running using VMware:
We were able to run the emulation and debug without an issue by following the following two steps:
    Under the settings of the VM > CPU, make sure you have the option to pass-through the Intel VT-x/EPT feature.
    Edit the config file .vmx and add the parameter: hypervisor.cpuid.v0 = "FALSE"

All versions of Visual Studio 2012 have a window refresh issue when running in VMware and the window is maximized, the solution is just to change the size of the Visual Studio window to be less the the screen width and height.