Skip to content

Building

Alex Dixon edited this page Jan 16, 2021 · 24 revisions

To build pmtech for different platforms pmbuild is used to generate projects/makefiles, game ready data and also build code from the command line. pmbuild originated in pmtech but has since moved to it's own repository which contains more detailed documentation. You can run pmbuild from the pmtech directory, or if you add the pmtech directory to your path this will allow you to simply run pmbuild.

  1. Prerequisites
  2. Building Examples
  3. Building Tools
  4. Live Coding

Prerequisites

pmtech only needs minimal external dependencies, just a c++ compiler and python3.

Windows

vs2017 or vs2019
python3

Users who want to use OpenGL or Vulkan require vcredist 2013 for the glsl/spirv validator.

macOS / iOS

Xcode

or clang or gcc.

homebrew

brew install python3

Linux

sudo apt-get install python3
sudo apt-get install libglew-dev
sudo apt-get install gcc-7 g++-7

or clang.

Android

Android Studio

Vulkan

If you want to target Vulkan please ensure you have the vulkan sdk installed and the VK_SDK_PATH variable is set if you wish to use the vulkan implementation.

Web Assembly

If you want to target Web Assembly you will need to install and configure the Emscripten SDK.

Building Examples

Navigate to the pmtech/examples directory:

cd pmtech/examples

You can see all available pmbuild profiles by running:

pmbuild -help

--------------------------------------------------------------------------------
pmbuild (v4) -------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
pmbuild version 4.0 -help  -----------------------------------------------------
--------------------------------------------------------------------------------

usage: pmbuild <profile> <tasks...>
       pmbuild make <target> <args...>
       pmbuild launch <target> <args...>

options:
    -help (display this dialog).
        <profile> -help (display help for the chosen profile).
        make <profile> -help (display help for the chosen make toolchain).
    <profile> <tasks...> -help (display help for the chosen tasks).
    -cfg (print jsn config for current profile).
    -verbose (print more).
    -all (build all tasks).
    -<task> (build specified tasks by name or by type).
    -n<task> (exclude specified tasks).

profiles:
    config.jsn (edit task settings in here)
        base
        mac
        mac-gl
        win32
        win32-vulkan
        win32-gl
        ios
        ios-ci
        linux
        linux-vulkan
        web
        android
        extensions
        tools_help

Building projects and data

Choose a build profile you want to build for and on the first run also supply -libs this will build third party library dependencies from source.

pmbuild <profile> -libs -all

After the first time building you should not need to supply -libs again unless the libraries need updating.

Once built, Xcode workspaces, Visual Studio solutions or make files will be generated in the examples/build folder.

Building code

you can build code using xcode or visual studio, but you can build also the examples from the command line using pmbuild make as follows:

pmbuild make <profile> all

When running pmbuild make you will be using a platform specific toolchain so can supply any specific arguments as well. Some common examples:

msbuild

pmbuild make win32 all /p:Platform=x64 /p:Configuration=Release

xcodebuild

pmbuild make mac all -Configuration=Release

make/emmake

pmbuild make linux all config=release

To see help for the associated toolchain with a profile:

pmbuild make <profile> -help

Running Tests

You can run and launch the example tests as follows:

pmbuild make <profile> all -test

Examples

macOS for Xcode with Metal

mac

cd pmtech/examples
pmbuild mac -libs -all
cd build/osx
open examples_osx.xcworkspace

macOS for Xcode with OpenGL

mac

cd pmtech/examples
pmbuild mac-gl -libs -all
cd build/osx
open examples_osx.xcworkspace

macOS with makefiles

mac

cd examples
pmbuild mac-ci -libs -all
cd build/osx
make config=release

Linux with makefiles and OpenGL

linux

cd examples
pmbuild linux -libs -all
cd build/linux
make config=release

Windows for Visual Studio with Direct3D11.

win32

cd examples
pmbuild win32 -libs -all

Windows for Visual Studio with Vulkan.

win32

cd examples
pmbuild win32-vulkan -libs -all

Windows for Visual Studio with OpenGL.

win32

cd examples
pmbuild win32-gl -libs -all

Note for Windows users, if you see this message during the build:

"Cannot find 'vcvarsall.exe'"
"Please enter the full path to the vc installation directory containing vcvarsall.exe"

You must have Visual Studio 2017 or 2019 installed, pmbuild will try and find visual studio installations and select the latest version of visual studio and windows sdk by default.

You can add a jsn member to the win32 build profile to force select a different visual studio version:

win32(base):
{
    vc_version: "latest", // supported options: latest, vs2017, vs2019
}

iOS with Metal on macOS

mac

cd examples
pmbuild ios -libs -all
cd build/ios
open examples.xcworkspace

Android on MacOS or win32 from a MinGW terminal

cd examples
pmbuild android -libs -all
cd build/android
open in android studio

Web Assembly via Emscripten

Make sure to setup emsdk_env first.

cd examples
pmbuild <win32/mac/linux> -libs
pmbuild web -all
cd build/web
emmake make 

Building Tools

pmtech contains a tools project which contains a mesh optimised and a graphical editor, to build these use the same process as building the examples but instead navigate to pmtech/tools:

pmbuild <profile>-editor

Live coding with dynamically reloaded c++

From within the pmtech tools solution or workspace, build and run pmtech_editor. Edit code in live_lib.cpp and then build the live_lib project inside the tools solution. Code changes will be dynamically reloaded for rapid development.

Clone this wiki locally