Skip to content

Commit 74358e9

Browse files
authored
Merge pull request #245 from muchcharles/patch-1
Update BUILDING.md
2 parents b75c226 + 73bc06c commit 74358e9

File tree

2 files changed

+120
-67
lines changed

2 files changed

+120
-67
lines changed

BUILDING.md

Lines changed: 119 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,182 @@
1-
# How to Build
1+
# How to Build and Run
22

33
<!--
44
Copyright (c) 2014-2021, The Khronos Group Inc.
55
66
SPDX-License-Identifier: CC-BY-4.0
77
-->
88

9-
## Python v3.6+ required
9+
## Building
1010

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
1412

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.
1718

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.
1923

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:
2547

2648
| Visual Studio | Version Number |
2749
| -------------------- |:--------------:|
2850
| Visual Studio 2013 | 12 |
2951
| Visual Studio 2015 | 14 |
3052
| Visual Studio 2017 | 15 |
53+
| Visual Studio 2019 | 16 |
3154

32-
### Windows 64-bit
55+
#### Windows 64-bit
3356

3457
First, generate the 64-bit solution and project files using CMake:
3558

36-
```
59+
```cmd
3760
mkdir build\win64
3861
cd build\win64
3962
cmake -G "Visual Studio [Version Number] Win64" ../..
4063
```
4164

4265
Finally, open the build\win64\OPENXR.sln in the Visual Studio to build the samples.
4366

44-
### Windows 32-bit
67+
#### VS2019
4568

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`:
4770

71+
```cmd
72+
mkdir build\win64
73+
cd build\win64
74+
cmake -G "Visual Studio [Version Number]" -A x64 ../..
4875
```
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
4987
mkdir build\win32
5088
cd build\win32
5189
cmake -G "Visual Studio [Version Number]" ../..
5290
```
5391

5492
Open the build\win32\OPENXR.sln in the Visual Studio to build the samples.
5593

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
7495

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" ../..
75102
```
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
76129
mkdir -p build/linux_debug
77130
cd build/linux_debug
78131
cmake -DCMAKE_BUILD_TYPE=Debug ../..
79132
make
80133
```
81134

82-
### Linux Release
135+
#### Linux Release (with debug symbols)
83136

84-
```
137+
```sh
85138
mkdir -p build/linux_release
86139
cd build/linux_release
87-
cmake -DCMAKE_BUILD_TYPE=Release ../..
140+
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../..
88141
make
89142
```
90143

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
99145

100-
# Running the HELLO_XR sample
146+
### OpenXR runtime installation
101147

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>
103153

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
109155

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.
112159

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
117161

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.
120167

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`.
122171

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
125173

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.
127177

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)
130179

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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve `BUILDING.md`, including adding details on how to specify architecture for VS2019.

0 commit comments

Comments
 (0)