Compiling Maya Plug-ins with CMake

New year, new site design! I’ve posted some free videos talking about how to compile Maya plug-ins on all platforms using CMake. Check them out here:

28 thoughts on “Compiling Maya Plug-ins with CMake”

Marco Giordano January 25, 2015 at 2:15 am

Amazing work as usual man! keep rocking

Matt January 28, 2015 at 2:24 am

Hi Chad,
I was trying to use your module to compile spReticle plugin under OSX 10.9 for Maya 2015. I found the plugin is building properly, but libraries are not linked based on error given:

ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[2]: *** [src/spReticle.bundle] Error 1
    make[1]: *** [src/CMakeFiles/spReticle.dir/all] Error 2

Also ld is looking at /Applications/Autodesk/maya2015/ which does not exist.

Chad January 28, 2015 at 8:38 am

Hi Matt,
Maya on OSX requires a different compiler (gcc 4.2) than the default clang. The easiest way to get it is with brew. brew install apple-gcc42. Then you can run cmake like this:

cmake -G "Unix Makefiles" -DCMAKE_C_COMPILER:FILEPATH=/usr/local/bin/gcc-4.2 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/local/bin/g++-4.2 ../

PJ April 24, 2015 at 11:51 pm

Hey Chad,

Is there a more elegant way to implement the includes for xgen’s headers and libs? At the moment I’m just adding it to the end of my CMakeList.txt as an extra include. I was curious if there was a way to create a FindXgen.cmake where it requires FindMaya.cmake so it can use it’s ${MAYA_LOCATION} variable? Then just append the directories to the MAYA_INCLUDE_DIR and MAYA_LIB _DIR? I’m new to cmake and I’m having a difficult time finding answers on the web.


find_package(Maya REQUIRED)
find_package(OpenGL REQUIRED)

target_link_libraries(${PROJECT_NAME} ${MAYA_LIBRARIES})

# XGen Specific setup



PJ April 25, 2015 at 9:45 pm

I think I got a working FindXgen.cmake. I think it works, I’m still having troubles linking though so I’m not exactly sure if I did it right.

# - Maya finder module
    # Set a default Maya version if not specified
        set(MAYA_VERSION 2015 CACHE STRING "Maya version")

    # OS Specific environment setup
        # Windows
        set(MAYA_INSTALL_BASE_DEFAULT "C:/Program Files/Autodesk")
        # Apple
        set(MAYA_INSTALL_BASE_DEFAULT /Applications/Autodesk)
        # Linux
        set(MAYA_INSTALL_BASE_DEFAULT /usr/autodesk)
        if(MAYA_VERSION LESS 2016)
        "Root path containing your maya installations, e.g. /usr/autodesk or /Applications/Autodesk/")

# OS Specific environment setup
    # Windows
    set(XGENLIB libAdskXGen.lib)
    # Apple
    set(XGENLIB libAdskXGen.dylib)
    # Linux

# XGen library directory
    DOC "XGen library path"

# XGen include directory
find_path(XGEN_DIR XgObject.h
    DOC "XGen include path"

# SeExpr include directory
find_path(SEEXPR_DIR SeExpression.h
    DOC "SeExpr include path"


# Xgen libraries
set(_XGEN_LIBRARIES AdskCaf AdskFabricGeom AdskFabricMath AdskGLee AdskPartio AdskSeExpr AdskSubEngine AdskXGen AdskXgUI AdskXpd)

find_package_handle_standard_args(Xgen DEFAULT_MSG XGEN_INCLUDE_DIR XGEN_LIBRARIES)

PJ April 25, 2015 at 10:47 pm

Looks like the FindXgen.cmake did work. I just had to set these flags to resolve the linking issues I was having. Thanks, your tutorial got me there. I didn’t have to use XCODE!

    ## Maya requires gcc 4.2 compiler
    set(CMAKE_C_COMPILER "/usr/bin/gcc")
    set(CMAKE_CXX_COMPILER "/usr/bin/g++")
    set(CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libstdc++")
#    set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libstdc++")

Chad May 2, 2015 at 11:30 am

@PJ Cool I’m glad it worked. I would have probably just added it all in FindMaya. Also Maya 2015 and on does actually work with XCode 6.1/Clang 6. You just need to do what you put down in your snippet. I did something like this in FindMaya:

    # Clang and Maya needs to use libstdc++
    set(MAYA_CXX_FLAGS "-std=c++0x -stdlib=libstdc++")

Then in your program CMakeLists, you can say:


You just need to be mindful of mixing things like mixing string types and such.

Luiz May 6, 2015 at 4:35 pm

Hi Chad,
Im using Maya 2014 on Windows. I used your FindMaya cmake module and CMakeLists files but when I try building with cmake I get the errors:

No CMAKE_C_COMPILER could be found.
No CMAKE_CXX_COMPILER could be found.

Do you think it is something related to cmake installation, or visual studio?

Thank you for putting up all this information. This is great!

Chad May 9, 2015 at 1:44 pm

Hi Luiz. Do you have Visual Studio installed? I think 2014 uses Visual Studio 2010.

David Johnson May 17, 2015 at 6:48 am

Amazingly clear and concise tutorial Chad. Exactly what I needed. Many thanks and much appreciation.

Felix June 13, 2015 at 1:52 pm

Hi there,
and first of all chad thanks for this great instruction, I am really looking foward to improve my build pipline.

Unfortunately i run into issues using Visual C++ 2012 Express Edition. In former times, i.e. with VC 2008/2010 one needed the Windows SDK for 64 bit compilation, but with 2012 that should actually not be necessary anymore.

Has anyone got this working?


Matt November 19, 2015 at 6:46 am

Hi Chad,

back again. Still having problems with some plugins, that I need to compile through GCC. I’m not able to finish configuring cmake build:

CMake Error at /usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Maya (missing: MAYA_LIBRARIES)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cgcmake/modules/FindMaya.cmake:93 (find_package_handle_standard_args)
src/CMakeLists.txt:14 (find_package)

Chad December 10, 2015 at 9:57 pm

Hi Matt,
Make sure you download the devkit. In more recent versions of Maya, it is a separate download.

Andy Seymour February 18, 2016 at 7:59 am

If you are trying to compile for a recent version of Maya such as 2016 The MAYA_LIBRARY_DIR seems to get confused if you have Maya 2013.5 (The DX11 Extension Version) installed as well. It detects the Maya2013.5 directory instead.

Chad February 23, 2016 at 8:38 pm

That’s strange. I haven’t seen that before, but then again I don’t have Maya 2013.5 installed.

eric June 3, 2016 at 8:54 am

Hi Chad, I’m attempting to use your findMaya cmake file for newer versions of maya. However, no matter what i set as the maya version, or change the findMaya.cmake file to default to a more current version of maya, I still get compiler errors

No rule to make target `/usr/autodesk/maya2016/lib/’

I’ve more or less removed all mentions of 2016 in the findMaya.cmake, so where might this be coming from?


Chad June 15, 2016 at 10:22 pm

Hi Eric, What platform and maya version are you trying to use?

eric June 16, 2016 at 8:11 am

hey Chad, linux 2017 with qt 5.6.1. It seems like a few things have changed in regards to cmake and qt5, and my cmake skills are not up to speed yet 🙂


Pusht October 20, 2016 at 11:26 am

I dont see how this is supposed to be correct ? :
find_path(MAYA_INCLUDE_DIR maya/MFn.h
“maya” folder is not situated directly in the install folder….

Stepan March 16, 2017 at 2:51 am

Hi Chad,
great tutorial! Could you suggest a compiler I could use to compile for mac and linux on windows?

Stephan Osterburg May 7, 2017 at 5:28 am

Hello Chad,
I followed your tutorial which was super informative and well explained.

But I am still unable to compile. And was wondering if you had some pointers of what I do wrong here. I actually downloaded at the end your version from github. I am on MacOS Sierra 10.12.4, python 2.7 with cmake 3.7 and trying to compile for Maya 2017.

cmake -G "Unix Makefiles" ../

CMake Error at /Users/stephanosterburg/anaconda/lib/python2.7/site-packages/cmake/data/ (message):
Call Stack (most recent call first):
/Users/stephanosterburg/anaconda/lib/python2.7/site-packages/cmake/data/ (_FPHSA_FAILURE_MESSAGE)
module/FindMaya.cmake:93 (find_package_handle_standard_args)
CMakeLists.txt:12 (find_package)

Thanks a lot for the help,

Chad May 8, 2017 at 8:26 pm

@stepan You can’t compile for mac and linux on Windows. You’ll need either a virtual machine or an actual machine with those operating systems.

@Stephan It can’t find the Maya install. Check to make sure the install location is the same as inside the FindMaya file. If it’s different, you can just update it to point to wherever it’s installed on your system.

T May 23, 2017 at 10:58 am

Hello Chad,

This tutorial series has been really useful! Thank you so much for making it!

I have one small issue that I was hoping you might be able to clarify:

I’m building on Mac OS X for Maya 2016 and managed to follow along and modify your FindMaya script to match my needs and configuration (as far as I can tell), and I am able to build successfully. However, I am having an issue getting make to install the plugin in the install directory the way that you did in part 6 of the tutorial series. Whenever I try to build using the “–target Install” option, make gives me the following error: “make: *** No rule to make target `Install’. Stop.”

I’m not super familiar with makefiles, so it would be great to know how I might be able to fix this issue.

Anyway, thank you again for the great tutorial!

Conan May 31, 2017 at 10:23 am

Hey Chad,

I have to say, after nearly 6 months of trying and failing to do ANYTHING with Maya and QT it is so refreshing to see a tutorial that is actually helpful to someone like me.

I am trying to compile on the Mac (not my comfort zone to begin with). I get the error Could NOT find Maya (missing: MAYA_INCLUDE_DIR MAYA_LIBRARIES). I have the 2017 devkit installed but noticed that there is no “include” folder inside the devkit folder – where did it move to with 2017? For the second missing variable, again, I have the devkit installed so I don’t understand why these issues are coming up.

Again, thanks for what you’re doing to help people out! It’s so nice to have hope that I, even I, can do something after 6 months of unending frustration.

Conan May 31, 2017 at 1:07 pm


I misspelled PATH_SUFFIXES. I excluded one of the f’s. I have successfully compiles something – ANYTHING! – for Maya.

Chad May 31, 2017 at 10:55 pm

@T You’ll need to specify the install command in your CMakeLists scripts. Do you have that anywhere?

George November 26, 2017 at 9:47 pm

Hi Chad,

Thanks for this tutorial! I'm having some trouble just getting cmake to build on windows. I've searched around and have not found any solutions. I'm on Windows 10 with VS 2015 installed and trying to compile for maya 2016.

It looks like a permissions issue, but I have the proper permissions on all my build directories.

Here's the cmake command I'm running:

cmake -G "Visual Studio 14 2015 Win64" -DMAYA_VERSION=2016 ..\

Any info would be appreciated!


CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:174 (file):
  file failed to open for writing (Permission denied):

Call Stack (most recent call first):
  CMakeLists.txt:2 (project)

CMake Error: Could not open file for write in copy operation C:/Users/gsaaav/Documents/maya/pluginDev/basicNode_CM/build/CMakeFiles/3.10.0/CMakeSystem.cmake.tmp
CMake Error: : System Error: Permission denied
CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:186 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)

CMake Error at CMakeLists.txt:2 (project):
  Failed to run MSBuild command:

    C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe

  to get the value of VCTargetsPath:

    Microsoft (R) Build Engine version 14.0.25420.1
    Copyright (C) Microsoft Corporation. All rights reserved.

    MSBUILD : error MSB1009: Project file does not exist.
    Switch: VCTargetsPath.vcxproj

  Exit code: 1

-- Configuring incomplete, errors occurred!
CMake Error: Cannot open file for write: C:/Users/gsaaav/Documents/maya/pluginDev/basicNode_CM/build/CMakeCache.txt.tmp
CMake Error: : System Error: Permission denied
CMake Error: Unable to open cache file for save. C:/Users/gsaaav/Documents/maya/pluginDev/basicNode_CM/build/CMakeCache.txt
CMake Error: : System Error: Permission denied

Fred April 21, 2018 at 4:23 am

Hi Chad,

Thanks for the tutorial!
I am using Mac and Maya 2017. I still have some problem when building the actual plug-in. It seems that for some reason, Maya’s include files cannot recognize my operating system. The terminal gives:

/Applications/Autodesk/maya2017/include/maya/MTypes.h:283:2: error: unknown type name ‘Unknown’
Unknown OS: need to provide an implementation here

Do you have any idea what is going wrong?
I have some temporary solution by changing “if statement” in “MTypes.h” but I don’t think I should do that. So I am still looking for some better solutions.



Leave A Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

<code> For inline code.
[sourcecode] For multiline code.