Share

Edit your CMakeLists.txt files

There are two CMakeLists.txt files required to build operators and package them into a Bifrost pack.

The first CMakeLists.txt file is located at the top level of a project. This file specifies the name of your project. The only section you will need to edit in this section is the project section. Replace <project_name> with your own project name.

# Project Name
project(
    <project_name>
    VERSION 1.0.0
    LANGUAGES CXX
)

The second CMakeLists.txt file is located in the src directory. This file specifies the source code, header files, and build targets for your project.

Set the libraries, definitions, sources, and paths, so that they use your project name and your source files. Each C++ source file in target_sources must be separated by a space.

# Build and install the library
add_library( <project_name>Ops SHARED)
target_compile_definitions( <project_name>Ops PRIVATE <PROJECT_NAME>_BUILD_NODEDEF_DLL )
target_sources( <project_name>Ops PRIVATE <list of cpp files>)
target_link_libraries( <project_name>Ops PUBLIC Amino::Cpp )
target_link_libraries( <project_name>Ops PUBLIC Amino::Core )
bifrost_set_install_rpath(<project_name>Ops)
install( TARGETS <project_name>Ops DESTINATION lib )

Add the header files that contain the annotations that will be parsed by the cpp2json tool.

# Generate and install the Bifrost definition JSON files
set( headers_to_parse <header_file_list> )

The header files in the list must be separated by a space, or must be on separate lines.

You will also need to provide a name for the location where your Bifrost definition JSON files will be built and installed. This location will be under the build and installation locations specified when you run cmake. See Build your operator using CMake.

bifrost_header_parser(
    <project_name>JsonFiles  # Name of the target
    <json_file_location_name>    # Bifrost definition JSON file installation and build directory
    INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
    HEADER_FILES ${headers_to_parse})

Once this is done, save your files. You can now build your project.

Was this information helpful?