Build your operator using CMake
Creating an operator with CMake is a two-step process. The first call to cmake
generates a Makefile or a Visual Studio project. The second call to cmake
builds your operator using the Makefile or project, and creates a Bifrost pack for your operator.
To build your operator and its Bifrost pack:
On Windows, open a Visual Studio 2019 command window. On macOS and Linux, open a terminal window. Make sure that the
cmake
command is in your path. On Linux, make sure thatgcc
is also in your path.Set the
BIFROST_LOCATION
environment variable to point to your Bifrost installation.Platform Bifrost location Windows C:\Program Files\Autodesk\Bifrost\<Maya_version>\<Bifrost_version>\bifrost\
macOS /Applications/Autodesk/bifrost/<Maya_version>/<Bifrost_version>/bifrost/
Linux /usr/autodesk/bifrost/<Maya_version>/<Bifrost_version>/bifrost/
You can also pass the location of the Bifrost installation to
cmake
on the command line. The location passed tocmake
from the command line will take precedence over the environment variable.Note:On Windows, the path can contain spaces, but not quotation marks of any kind.
Change directory to your project's
src
directory and run the following command to create a Visual Studio project or a Makefile:cmake -S <operator_directory> -B <build_location>
To create an Xcode project, run:
cmake -S <operator_directory> -B <build_location> -GXcode
The build files will be created in the
build_location
directory you passed tocmake
.cmake
will use defaults to generate the Visual Studio project or Makefile. These can be changed on thecmake
command line.Parameter Default Command line option to change the default C++ standard your compiler's default -DCMAKE_CXX_STANDARD=17
Bifrost installation location BIFROST_LOCATION
environment variable-DBIFROST_LOCATION=<path_to_Bifrost_installation>
Activate warnings Default is OFF
-DBIFROST_WARNINGS_AS_ERRORS=<ON or OFF>
Pack install directory Build directory -DCMAKE_INSTALL_PREFIX=<target_directory>
On macOS with Apple Silicon chips, the target architecture will be arm64 by default. Similarly, on macOS with Intel chips, the target architecture will be Intel x86_64 by default. You can choose to build for both architectures using the CMAKE_OSX_ARCHITECTURES option:
cmake -S <operator_directory> -B build_output -DCMAKE_INSTALL_PREFIX=bifrost_packs -DCMAKE_OSX_ARCHITECTURES=x86_64;arm64
If you need to rebuild, delete the build directory first.
To build the operator and create its Bifrost pack, run:
cmake --build <build_location> --target install
Use the same build location as you used in your previous command.
Note:If you are building on Windows, or if you are building using an Xcode project, you will need to specify that you are building a release version:
cmake --build <build_location> --target install --config Release
If you are building directly from within Visual Studio or Xcode, modify your project to use the
install
target withRelease
configuration.This will generate a Bifrost pack named
<project_name>-<project_version>
as specified in the CMakeLists.txt file.If you specified a directory for
CMAKE_INSTALL_PREFIX
in the previous call tocmake
, the Bifrost pack will be installed in that directory. If you did not specifyCMAKE_INSTALL_PREFIX
, the pack will be installed in the build directoryIf you need to rebuild, delete the build directory and restart from the previous step.
To use the nodes in your Bifrost pack, ensure that your Bifrost pack is in a location that is accessible to the application that will be using it, and add the full path to the Bifrost pack's
<project_name>Config.json
, including the name of the file, to theBIFROST_LIB_CONFIG_FILES
environment variable. The<project_name>Config.json
file is located at the top level of the Bifrost pack directory.For example:
BIFROST_LIB_CONFIG_FILES=$HOME/MyBifrostPacks/MyOperator-1.0.0/MyOperatorPackConfig.json
BIFROST_LIB_CONFIG_FILES
can point to multiple json files. Separate each path with a semicolon (;
) on Windows, or a colon (:
) on macOS or Linux.If you will be using your nodes with the Bifrost Extension for Maya, you can also set this environment variable in the
Maya.env
file.