Adding Third-Party Libraries

You can use the find_package() call to add 3rd-party libraries to to your CMake project.

find_package(<package_name>) searches $DEVKIT_LOCATION/cmake/modules/ on Linux and macOS, and %DEVKIT_LOCATION%\cmake\modules on Windows, for its corresponding Find<package_name>.cmake file. Find<package_name>.cmake then finds and loads settings from the corresponding 3rd-party library into your project.

For example, to add the Arnold for Maya package using the FindMtoA.cmake file, add the following to your CMakeLists.txt file:

find_package(MtoA)

For example:

cmake_minimum_required(VERSION 2.8)

include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)

set(PROJECT_NAME exampleNode)

set(RESOURCES_FILES myResource.xpm)

set(MEL_FILES 
    exampleNode.mel
    )

set(SOURCE_FILES
    exampleNode.cpp
    ${MEL_FILES}
    )

set(LIBRARIES
    OpenMaya Foundation
    )

find_package(MtoA)
build_plugin()

Before calling find_package(), make sure you have installed the 3rd party libraries they use, and that you have set any environment variables they require. For example, if you need to include the Arnold for Maya libraries, you will need to set the MTOA_LOCATION environment variable.

The Find<package_name>.cmake files can also be used as guides to create your own CMake package files. If you do create your own files, place them in the modules directory so they can be found by CMake.