|
1 | | -# How to Build |
| 1 | +# How to Build and Run |
2 | 2 |
|
3 | 3 | <!-- |
4 | 4 | Copyright (c) 2014-2021, The Khronos Group Inc. |
5 | 5 |
|
6 | 6 | SPDX-License-Identifier: CC-BY-4.0 |
7 | 7 | --> |
8 | 8 |
|
9 | | -## Python v3.6+ required |
| 9 | +## Building |
10 | 10 |
|
11 | | -Certain source files are generated at build time from the `xr.xml` file, utilizing |
12 | | -python scripts. The scripts make use of the python `pathlib` module, which is |
13 | | -fully supported in python version 3.6 or later. |
| 11 | +### Python v3.6+ may be required |
14 | 12 |
|
15 | | -You will also need the python `jinja2` package, available from your package |
16 | | -manager or with something like `pip3 install jinja2`. |
| 13 | +**If you are building from most repostories:** (specifically, the |
| 14 | +OpenXR-SDK-Source repository, the OpenXR-CTS repository, or the internal Khronos |
| 15 | +GitLab OpenXR repository) Certain source files are generated at build time from |
| 16 | +the `xr.xml` file, utilizing Python scripts. The scripts make use of the Python |
| 17 | +`pathlib` module, which is fully supported in Python version 3.6 or later. |
17 | 18 |
|
18 | | -## Windows |
| 19 | +You will also need the Python `jinja2` package, available from your package |
| 20 | +manager or with something like `pip3 install jinja2`. Most OpenXR repositories |
| 21 | +include a bundled copy of this, but if you see errors about Jinja, this would be |
| 22 | +one approach to try. |
19 | 23 |
|
20 | | -Building the OpenXR components in this tree on Windows is supported using |
21 | | -Visual Studio 2013 and newer. Before beginning, make sure the appropriate |
22 | | -"msbuild.exe" is in your PATH. Also, when generating the solutions/projects |
23 | | -using CMake, be sure to use the correct compiler version number. The |
24 | | -following table is provided to help you: |
| 24 | +**If you are building the `OpenXR-SDK` repository:** all source files have been |
| 25 | +pre-generated for you, and only the OpenXR headers and loader are included. |
| 26 | + |
| 27 | +### CMake |
| 28 | + |
| 29 | +The project is a relatively standard CMake-based project. You |
| 30 | +might consider |
| 31 | +[the official CMake User Interaction Guide][cmake-user-interaction] if you're |
| 32 | +new to building CMake-based projects. The instructions below can mostly be skimmed to find the dependencies |
| 33 | + |
| 34 | +[cmake-user-interaction]:https://cmake.org/cmake/help/latest/guide/user-interaction/ |
| 35 | + |
| 36 | +### Windows |
| 37 | + |
| 38 | +Building the OpenXR components in this tree on Windows is supported using Visual |
| 39 | +Studio 2013 and newer. If you are using Visual Studio 2019, you can simply "Open |
| 40 | +folder" and use the built-in CMake support. Other environments, such as VS Code, |
| 41 | +that can have CMake support installed and use the Visual Studio toolchains, |
| 42 | +should also work: |
| 43 | + |
| 44 | +When generating the |
| 45 | +solutions/projects using CMake, be sure to use the correct compiler version |
| 46 | +number. The following table is provided to help you: |
25 | 47 |
|
26 | 48 | | Visual Studio | Version Number | |
27 | 49 | | -------------------- |:--------------:| |
28 | 50 | | Visual Studio 2013 | 12 | |
29 | 51 | | Visual Studio 2015 | 14 | |
30 | 52 | | Visual Studio 2017 | 15 | |
| 53 | +| Visual Studio 2019 | 16 | |
31 | 54 |
|
32 | | -### Windows 64-bit |
| 55 | +#### Windows 64-bit |
33 | 56 |
|
34 | 57 | First, generate the 64-bit solution and project files using CMake: |
35 | 58 |
|
36 | | -``` |
| 59 | +```cmd |
37 | 60 | mkdir build\win64 |
38 | 61 | cd build\win64 |
39 | 62 | cmake -G "Visual Studio [Version Number] Win64" ../.. |
40 | 63 | ``` |
41 | 64 |
|
42 | 65 | Finally, open the build\win64\OPENXR.sln in the Visual Studio to build the samples. |
43 | 66 |
|
44 | | -### Windows 32-bit |
| 67 | +#### VS2019 |
45 | 68 |
|
46 | | -First, generate the 32-bit solution and project files using CMake: |
| 69 | +For VS2019 the above may complain and say to split out the arch into `-A '[arch]'`. This `-A` parameter must be set to `x64`, *not* `Win64`: |
47 | 70 |
|
| 71 | +```cmd |
| 72 | +mkdir build\win64 |
| 73 | +cd build\win64 |
| 74 | +cmake -G "Visual Studio [Version Number]" -A x64 ../.. |
48 | 75 | ``` |
| 76 | + |
| 77 | +VS2019 includes CMake tools, which can be installed through the Visual Studio |
| 78 | +Installer -> Modify -> Individual Components -> C++ CMake tools for Windows. To |
| 79 | +get the right paths for `msbuild.exe` and `cmake.exe`, you can launch through |
| 80 | +`Start -> Visual Studio 2019 -> x64 Native Tools Command Prompt For VS 2019`. |
| 81 | + |
| 82 | +#### Windows 32-bit |
| 83 | + |
| 84 | +First, generate the 32-bit solution and project files using CMake: |
| 85 | + |
| 86 | +```cmd |
49 | 87 | mkdir build\win32 |
50 | 88 | cd build\win32 |
51 | 89 | cmake -G "Visual Studio [Version Number]" ../.. |
52 | 90 | ``` |
53 | 91 |
|
54 | 92 | Open the build\win32\OPENXR.sln in the Visual Studio to build the samples. |
55 | 93 |
|
56 | | -## Linux |
57 | | - |
58 | | -The following set of packages provides all required libs for building for xlib or xcb with OpenGL and Vulkan support. |
59 | | - - build-essential |
60 | | - - cmake (of _somewhat_ recent vintage, 3.10+ known working) |
61 | | - - libgl1-mesa-dev |
62 | | - - libvulkan-dev |
63 | | - - libx11-xcb-dev |
64 | | - - libxcb-dri2-0-dev |
65 | | - - libxcb-glx0-dev |
66 | | - - libxcb-icccm4-dev |
67 | | - - libxcb-keysyms1-dev |
68 | | - - libxcb-randr0-dev |
69 | | - - libxrandr-dev |
70 | | - - libxxf86vm-dev |
71 | | - - mesa-common-dev |
72 | | - |
73 | | -### Linux Debug |
| 94 | +#### (Optional) Building the OpenXR Loader as a DLL |
74 | 95 |
|
| 96 | +The OpenXR loader is built as a static library by default on Windows. To instead |
| 97 | +build as a dynamic link library, define the cmake option `DYNAMIC_LOADER=ON`. |
| 98 | +e.g. for Win64, replace the CMake line shown above with: |
| 99 | + |
| 100 | +```cmd |
| 101 | +cmake -DDYNAMIC_LOADER=ON -G "Visual Studio [Version Number] Win64" ../.. |
75 | 102 | ``` |
| 103 | + |
| 104 | +Note that even if built as a dynamic library, the loader **should not** be |
| 105 | +installed system-wide on Windows or Android. |
| 106 | + |
| 107 | +### Linux |
| 108 | + |
| 109 | +The following set of packages provides all required libs for building for xlib |
| 110 | +or xcb with OpenGL and Vulkan support. |
| 111 | + |
| 112 | +- build-essential |
| 113 | +- cmake |
| 114 | +- libgl1-mesa-dev |
| 115 | +- libvulkan-dev |
| 116 | +- libx11-xcb-dev |
| 117 | +- libxcb-dri2-0-dev |
| 118 | +- libxcb-glx0-dev |
| 119 | +- libxcb-icccm4-dev |
| 120 | +- libxcb-keysyms1-dev |
| 121 | +- libxcb-randr0-dev |
| 122 | +- libxrandr-dev |
| 123 | +- libxxf86vm-dev |
| 124 | +- mesa-common-dev |
| 125 | + |
| 126 | +#### Linux Debug |
| 127 | + |
| 128 | +```sh |
76 | 129 | mkdir -p build/linux_debug |
77 | 130 | cd build/linux_debug |
78 | 131 | cmake -DCMAKE_BUILD_TYPE=Debug ../.. |
79 | 132 | make |
80 | 133 | ``` |
81 | 134 |
|
82 | | -### Linux Release |
| 135 | +#### Linux Release (with debug symbols) |
83 | 136 |
|
84 | | -``` |
| 137 | +```sh |
85 | 138 | mkdir -p build/linux_release |
86 | 139 | cd build/linux_release |
87 | | -cmake -DCMAKE_BUILD_TYPE=Release ../.. |
| 140 | +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../.. |
88 | 141 | make |
89 | 142 | ``` |
90 | 143 |
|
91 | | -## (Optional) Building the OpenXR Loader as a DLL |
92 | | - |
93 | | -The OpenXR loader is built as a static library by default. To instead build as a dynamic link library, define |
94 | | -the cmake option `DYNAMIC_LOADER=ON`. e.g. for Win64, replace the cmake line shown above with: |
95 | | - |
96 | | -``` |
97 | | -cmake -DDYNAMIC_LOADER=ON -G "Visual Studio [Version Number] Win64" ../.. |
98 | | -``` |
| 144 | +## Running the HELLO_XR sample |
99 | 145 |
|
100 | | -# Running the HELLO_XR sample |
| 146 | +### OpenXR runtime installation |
101 | 147 |
|
102 | | -## OpenXR runtime installation |
| 148 | +An OpenXR _runtime_ must first be installed before running the `hello_xr` |
| 149 | +sample. The runtime is an implementation of the OpenXR API, typically tailed to |
| 150 | +a specific device and distributed by the device manufacturer. Publicly-available |
| 151 | +runtimes are listed on the main OpenXR landing page at |
| 152 | +<https://www.khronos.org/openxr> |
103 | 153 |
|
104 | | -An OpenXR _runtime_ must first be installed before running the hello_xr sample. The runtime is an |
105 | | -implementation of the OpenXR API, typically tailed to a specific device and distributed by the |
106 | | -device manufacturer. To allow experimentation with the API in the absence of a specific device runtime, |
107 | | -several organizations have made available prototype OpenXR runtimes, linked from the main OpenXR landing |
108 | | -page at https://www.khronos.org/openxr |
| 154 | +### Configuring the OpenXR Loader |
109 | 155 |
|
110 | | -## Configuring the OpenXR Loader |
111 | | -### XR\_RUNTIME\_JSON environment variable |
| 156 | +On Windows and Android, the OpenXR loader is distributed with the application, |
| 157 | +not installed to the system. On Linux, the loader is available from many |
| 158 | +distributions already, and may be installed system-wide. |
112 | 159 |
|
113 | | -The OpenXR loader looks in system-specific locations for the JSON file `active_runtime.json`, which describes the |
114 | | -default installed OpenXR runtime. To override the default selection, you may define an environment variable |
115 | | -`XR_RUNTIME_JSON` to select a different runtime, or a runtime which has not been installed in the default |
116 | | -location. |
| 160 | +#### `XR_RUNTIME_JSON` environment variable |
117 | 161 |
|
118 | | -For example, you might set XR\_RUNTIME\_JSON to `<build_dir>/test/runtime/my_custom_runtime.json` to select |
119 | | -an OpenXR runtime described by JSON file `my_custom_runtime.json`. |
| 162 | +The OpenXR loader looks in system-specific locations for the JSON file |
| 163 | +`active_runtime.json`, which describes the default installed OpenXR runtime. To |
| 164 | +override the default selection, you may define an environment variable |
| 165 | +`XR_RUNTIME_JSON` to select a different runtime, or a runtime which has not been |
| 166 | +installed in the default location. |
120 | 167 |
|
121 | | -## Running the Hello_XR Test |
| 168 | +For example, you might set `XR_RUNTIME_JSON` to |
| 169 | +`<build_dir>/test/runtime/my_custom_runtime.json` to select an OpenXR runtime |
| 170 | +described by JSON file `my_custom_runtime.json`. |
122 | 171 |
|
123 | | -The binary for the hello_xr application is written to the `<build_dir>/src/tests/hello_xr` directory. |
124 | | -Set your working directory to this directory and execute the hello_xr binary. |
| 172 | +### Running the hello_xr Test |
125 | 173 |
|
126 | | -### Hello_XR with a dynamic loader (Windows) |
| 174 | +The binary for the hello_xr application is written to the |
| 175 | +`<build_dir>/src/tests/hello_xr` directory. Set your working directory to this |
| 176 | +directory and execute the `hello_xr` binary. |
127 | 177 |
|
128 | | -When building a DLL version of the loader, the Visual Studio projects generated by CMake will copy the loader |
129 | | -DLLs to the test application's (hello_xr) binary directory. This makes it unnecessary to copy these files to someplace like `Windows\System32`. |
| 178 | +### hello_xr with a dynamic loader (Windows) |
130 | 179 |
|
| 180 | +When building a DLL version of the loader, the Visual Studio projects generated |
| 181 | +by CMake will copy the loader DLLs to the test application's (hello_xr) binary |
| 182 | +directory. |
0 commit comments