Skip to content

Latest commit

 

History

History
75 lines (47 loc) · 3.59 KB

BUILD.md

File metadata and controls

75 lines (47 loc) · 3.59 KB

Building

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++14. All required dependencies are included. The project uses CMake as the build system.

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

Windows

Use the provided CMakeLists.txt with CMake to generate a build configuration for your favorite IDE or compiler, e.g.:

cmake -G "Visual Studio 16 2019" -A x64

Linux

Use the provided CMakeLists.txt with CMake to generate a build configuration for your favorite IDE or compiler.

  • XCB: Default WSI (if no cmake option is specified)
  • Wayland: Use cmake option USE_WAYLAND_WSI (-DUSE_WAYLAND_WSI=ON)
  • DirectFB: Use cmake option USE_DIRECTFB_WSI (-DUSE_DIRECTFB_WSI=ON)
  • DirectToDisplay: Use cmake option USE_D2D_WSI (-DUSE_D2D_WSI=ON)

Building on Android is done using the Gradle Build Tool.

The recommended way is building via Android Studio. Simply open the project folder android, build and after that you can select the sample you want to run from the project list.

If you want to build it via the command line, set Android SDK/NDK by environment variable ANDROID_SDK_ROOT/ANDROID_NDK_HOME.

On Linux execute:

cd android
./gradlew assembleDebug

This will download gradle locally, build all samples and output the apks to android/examples/bin.

On Windows execute gradlew.bat assembleDebug.

If you want to build and install on a connected device or emulator image, run gradle installDebug instead.

macOS and iOS

Note: Running these examples on macOS and iOS requires MoltenVK and a device that supports the Metal api.

macOS

Download the most recent Vulkan SDK using: curl -O https://sdk.lunarg.com/sdk/download/latest/mac/vulkan_sdk.dmg

Open vulkan_sdk.dmg and install the Vulkan SDK with System Global Installation selected.

Install libomp from homebrew using: brew install libomp

Define the libomp path prefix using: export LIBOMP_PREFIX=$(brew --prefix libomp)

Use CMake to generate a build configuration for Xcode or your preferred build method (e.g. Unix Makefiles or Ninja).

Example of cmake generating for Xcode with libomp library path defined: cmake -G "Xcode" -DOpenMP_omp_LIBRARY=$LIBOMP_PREFIX/lib/libomp.dylib .

iOS

Navigate to the apple folder and follow the instructions in README_MoltenVK_Examples.md