2018-03-28 15:09:29 +02:00
# Building
2023-11-28 19:33:14 +01:00
The repository contains everything required to compile and build the examples on Windows, Linux, Android and MacOS using a C++ compiler that supports at least C++11. All required dependencies are included. The project uses [CMake ](https://cmake.org/ ) as the build system.
2018-03-28 15:09:29 +02:00
2023-11-28 19:33:14 +01:00
## General CMake options
### Asset path setup
Asset (and shader) paths used by the samples can be adjusted using CMake options. By default, paths are absolute and are based on the top level of the current CMake source tree. The following arguments can be used to adjust this:
- ```RESOURCE_INSTALL_DIR` ``: Set an absolute path for assets and shaders to which they are installed and from which they are loaded
- ```USE_RELATIVE_ASSET_PATH` ``: Use a fixed relative (to the binary) path for loading assets and shaders
## Platform specific build instructions
### <img src="./images/windowslogo.png" alt="" height="32px"> Windows
2018-03-28 15:09:29 +02:00
Use the provided CMakeLists.txt with [CMake ](https://cmake.org ) to generate a build configuration for your favorite IDE or compiler, e.g.:
2022-06-04 22:57:28 +02:00
2018-03-28 15:09:29 +02:00
```
2022-06-04 22:57:28 +02:00
cmake -G "Visual Studio 16 2019" -A x64
2018-03-28 15:09:29 +02:00
```
2023-11-28 19:33:14 +01:00
### <img src="./images/linuxlogo.png" alt="" height="32px"> Linux
2018-03-28 15:09:29 +02:00
Use the provided CMakeLists.txt with [CMake ](https://cmake.org ) to generate a build configuration for your favorite IDE or compiler.
##### [Window system integration](https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/vkspec.html#wsi)
- **XCB**: Default WSI (if no cmake option is specified)
- **Wayland**: Use cmake option ```USE_WAYLAND_WSI` `` (` ``-DUSE_WAYLAND_WSI=ON` ``)
2020-09-13 10:12:33 +02:00
- **DirectFB**: Use cmake option ```USE_DIRECTFB_WSI` `` (` ``-DUSE_DIRECTFB_WSI=ON` ``)
2018-03-28 15:09:29 +02:00
- **DirectToDisplay**: Use cmake option ```USE_D2D_WSI` `` (` ``-DUSE_D2D_WSI=ON` ``)
2023-11-28 19:33:14 +01:00
### <img src="./images/androidlogo.png" alt="" height="32px"> [Android](android/)
2018-03-28 15:09:29 +02:00
2020-11-26 07:34:43 +01:00
Building on Android is done using the [Gradle Build Tool ](https://gradle.org/ ):
2019-09-06 20:42:05 +02:00
2023-06-09 13:22:48 +08:00
If you want to build it through command line, set Android SDK/NDK by environment variable `ANDROID_SDK_ROOT` /`ANDROID_NDK_HOME` .
On Linux execute:
2023-04-18 11:27:19 +08:00
2019-09-06 20:42:05 +02:00
```
cd android
2020-11-26 07:34:43 +01:00
./gradlew assembleDebug
2019-09-06 20:42:05 +02:00
```
2023-06-09 13:22:48 +08:00
This will download gradle locally, build all samples and output the apks to ```android/examples/bin` ``.
2020-11-26 07:34:43 +01:00
2023-06-09 13:22:48 +08:00
On Windows execute ```gradlew.bat assembleDebug` ``.
2019-09-06 20:42:05 +02:00
If you want to build and install on a connected device or emulator image, run ```gradle installDebug` `` instead.
2018-03-28 15:09:29 +02:00
2023-06-09 13:22:48 +08:00
If you want to build it through [Android Studio ](https://developer.android.com/studio ), open project folder ```android` `` in Android Studio.
2023-04-18 11:27:19 +08:00
2023-11-28 19:33:14 +01:00
### <img src="./images/applelogo.png" alt="" height="32px"> [iOS and macOS](xcode/)
2018-03-28 15:09:29 +02:00
2024-03-04 22:09:21 +01:00
**Note:** Running these examples on Mac OS and iOS requires [**MoltenVK** ](https://github.com/KhronosGroup/MoltenVK ) and a device that supports the *Metal* api.
2020-09-12 03:19:28 +09:00
2024-03-04 22:09:21 +01:00
#### MacOS
2023-07-15 10:44:22 +01:00
Install Libomp with:
-brew install libomp
find the path
-brew --prefix libomp
use the path from the above command to populate the path in the -DOpenMP_C_FLAGS, -DOpenMP_omp_LIBRARY & -DOpenMP_CXX_FOUND statement below
2023-07-16 17:57:22 +01:00
Download Vulkan SDK and install it note the path as this will need to be configure in Xcode
curl -O https://sdk.lunarg.com/sdk/download/latest/mac/vulkan_sdk.dmg
Open vulkan_sdk.dmg and install Vulkan SDK
Navigate to the Vulkan SDK folder and run 'python install_vulkan.py'
2023-07-15 10:44:22 +01:00
2020-09-12 03:19:28 +09:00
Use the provided CMakeLists.txt with [CMake ](https://cmake.org ) to generate a build configuration for your favorite IDE or compiler, e.g.:
```
2023-07-16 17:57:22 +01:00
Example of cmake with libraries defined
cmake -G "Xcode" -DOpenMP_C_FLAGS=/usr/local/opt/libomp -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp -DOpenMP_CXX_FOUND=/usr/local/opt/libomp
```
2023-07-18 09:16:28 +01:00
2023-07-16 17:57:22 +01:00