0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Mayaプラグインの開発環境をCLionで構築する方法

Posted at

環境

  • Windows
  • Autodesk Maya 2026
  • CLion 2025.1.1
  • Visual Studio 2022

CLionについて

JetBrains製のC/C++向けのIDEです。コンパイラは含まれていませんが、外部のコンパイラを利用できます。

環境構築

コンパイラのインストール

Mayaのプラグインをビルドするために、必要なコンパイラを確認します。
公式ドキュメントの Maya devkitの要件を見ると、Windows環境では Visual Studio 2022 が必要だとわかるので、Visual Studio 2022をインストールします (インストール手順については本題とそれるため、割愛します)。

Maya DevKitのダウンロード

Maya デベロッパーセンター から Maya 2026 win64 DevKit をダウンロードして任意の場所に保存します。

CLionの設定

ツールチェーンの設定

File > Settings... を選択し、Build, Execution, Deployment | ToolchainsVisual Studio をクリックします。

クリックすると Visual Studio の項目が作成されます。

CMakeプロファイルの設定

File > Settings... を選択し、Build, Execution, Deployment | CMake+ をクリックします。

ToolchainVisual StudioGeneratorVisual Studio 17 2022 に設定します。Build type は適宜設定してください。以後の文章では NameBuild typeDebug に設定したものとして記載します。

環境変数の設定とCMakeLists.txt

ビルドするためには環境変数とCMakeLists.txtの設定が必要です。環境変数に関してはCMakeLists.txtでも設定できるので、この記事ではCMakeLists.txtで設定する例を記載します。CMakeLists.txtには以下の内容を記述します。

  • 最小バージョン要件
  • プロジェクト名の設定
  • 環境変数の設定
  • devkitのCMakeファイルの読み込み
  • ソースファイルの設定
  • ライブラリの設定
  • ビルド関数の呼び出し

ビルド関数は、devkitのCMakeで build_plugin() として定義されているため、それを利用します。

環境変数とCMakeLists.txtの設定の詳細については 公式ドキュメントの Windows で Maya devkit を設定するCMakeLists.txtファイル を参照してください。

CMakeLists.txtのサンプル

CMakeLists.txt
# 最小バージョン要件
cmake_minimum_required(VERSION 3.22.1)

# プロジェクト名の設定
get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${PROJECT_NAME})

# 環境変数の設定
set(ENV{DEVKIT_LOCATION} "<devkitの保存先のパス>/Autodesk_Maya_2026_DEVKIT_Windows/devkitBase")
set(ENV{MAYA_LOCATION} "C:/Program Files/Autodesk/Maya2026")
set(ENV{PATH} "$ENV{PATH};$ENV{MAYA_LOCATION}/bin")

# devKitのCMakeファイルの読み込み
include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)

# ソースファイルの設定
set(SOURCE_FILES
    <プラグインファイル名>.cpp
)

# ライブラリの設定
set(LIBRARIES
     OpenMaya
     Foundation
)

# プラグインのビルド関数
build_plugin()

CMakeLists.txtを更新したら、右クリック > Reload CMake Project を選択して、リロードしてください。cmake-build-debug ディレクトリが作成、更新されます。

プラグインのサンプルコード

ビルド環境の確認用のサンプルコードなので、詳細は割愛します。

#include <maya/MIOStream.h>
#include <maya/MSimple.h>
#include <maya/MGlobal.h>


DeclareSimpleCommand(simplePlugin, "My Company", "1.0.0");


MStatus simplePlugin::doIt( const MArgList& )
{
	MGlobal::displayInfo("simple plugin");
	return MS::kSuccess;
}

ビルド

メニューの Build > Build Project または Build > Rebuild Project を選択して、プロジェクトをビルドできます。

参考情報

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?