This is a template repository for creating Autodesk Maya plugin using C++ Maya API and CMake. Using this template you can easily start plugin development and don't care about setting up CMake and confuguring build.
I recommend you to use this template with JetBrains CLion because the project were set up in this IDE. But you always can use it with pure CMake.
For best practise you should use CLion version higher or equal to
2021.1
.
Open CMakeLists.txt
file in the repository root and change maya-plugin-template
to your project name. Also,
you can change description to your text.
project(maya-plugin-template VERSION 1.0 DESCRIPTION "My Maya Plug-in" LANGUAGES CXX)
Use src
directory for source code. You can organise directories in src
as you wish. For example, create next
structure:
.
├── src
│ ├── include
│ └── source
└── ...
To add source files to the project simply add this files to src/CMakeLists.txt
file to field SOURCE_FILES
at the top of the file.
set(SOURCE_FILES
HelloWorld.cpp
HelloWorld.h
plugin.cpp
plugin.h
)
If you are using CLion - files will be added automatically. You don't have to care about that.
- Download Maya Development Kit (MDK) for your OS.
- Rename MDK directory to
maya_dev_kit
- Place MDK to
libraries
directory as shown below:. ├── libarires │ ├── maya_dev_kit │ │ ├── include │ │ ├── lib │ │ └── ... │ ├── .gitignore │ └── README.md └── ...
First you need to prepare project for build.
- Go to
File->Settings->Build, Execution, Deployment->CMake
. - Select profile you need for development. It depends on your toolchain and OS.
- Check the
Enable profile
checkbox on profile you need and uncheck on other. - Open CMake panel. (by default at the bottom of your editor window)
- Press
Reload CMake Project
button.
After that you can select run configuration and build project.
UNIX using MinGW and Make
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" -DMAYA_VERSION=none ../
cmake --build . --target YOUR_PROJECT_NAME -j 3
Windows using MVSC
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 -DMAYA_VERSION=none ../
cmake --build . --target YOUR_PROJECT_NAME -j 3
If you want to compile for release - change
-DCMAKE_BUILD_TYPE
flag from Debug to Release.
Author Danil Andreev.
Thanks to Chad Vernon for the cgcmake library.