A tutorial on creating the smallest possible viable USD program, using the dev branch of the official usd distribution.
In the spirit of minimalism, it skips Hydra, and Python bindings.
- git
- cmake 3.26 or greater installed for the command line
- Xcode command line tools, tested with Apple Clang 14
Shallow clone the USD dev branch into this project's packages directory:
cd tinyusd
mkdir packages
cd packages
git clone --depth 1 https://github.com/PixarAnimationStudios/USD.git -b dev
Fetch boost and unarchive it. Boost will not be built, the headers as is are sufficient.
./get_boost.sh
Fetch and build tbb. In the root directory:
./get_tbb.sh
If you are building USD with Hydra, you'll need OpenSubdiv.
./get_opensubdiv.sh
Once again, starting in the packages directory:
mkdir usd-build;cd usd-build
We are going to build USD without python, as python adds complexity, by requiring that boost python be built.
First, configure the build, from within the usd-build directory.
In the command below, replace the PREFIX and TOOLCHAIN variable values with appropriate paths.
cmake -DPXR_ENABLE_PYTHON_SUPPORT=OFF -DPXR_BUILD_MONOLITHIC=ON -DPXR_BUILD_DOCUMENTATION=OFF -DPXR_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=.. -G "Xcode" ../USD
cmake -DPXR_ENABLE_PYTHON_SUPPORT=OFF -DPXR_BUILD_MONOLITHIC=ON -DPXR_BUILD_DOCUMENTATION=OFF -DPXR_BUILD_TESTS=OFF -DPXR_BUILD_IMAGING=OFF -DCMAKE_INSTALL_PREFIX=.. -G "Xcode" ../USD
cmake --build . --config Release --target install
In a little while, packages/lib will contain the libusd_ms.dylib, and packages/include will have the headers, packages/bin will have sdfdump and sdffilter.
There is an executable in the bin directory called sdfdump. Running it should result in the executable describing its input arguments, without any complaints of missing dylibs.
Go back into the packages directory we made earlier, and create a tinyusd-build directory, and cd into it.
mkdir tinyusd-build;cd tinyusd-build
Then, configure the cmake build files. Once again, make sure the INSTALL_PREFIX and TOOLCHAIN variables are pointed appropriately.
cmake -G "Xcode" ../.. -DCMAKE_INSTALL_PREFIX=.. -DCMAKE_PREFIX_PATH=..
Build tinyusd.
cmake --build . --config Release --target install
Haven't got the rpath installation set up correctly in the cmake file yet, so go to the bin directory, and add it.
cd ../bin
install_name_tool -add_rpath ../lib tinyusd
Now, run tinyusd.
./tinyusd
Sanity check that tinyusd generated a file named test.usd, containing the following:
#usda 1.0
def Cube "Box"
{
float3 xformOp:scale = (5, 5, 5)
uniform token[] xformOpOrder = ["xformOp:scale"]
}