I want to change some options passed to the CMake command through the plugin code. Unfortunately I can't figure out how to do it.
Is there any API to communicate with CLion specific functionality?
You said "CMake command", which is unclear. I guess you want to change the CMake location.
This code can give you a CPPToolchains.Toolchain
instance:
val Project.toolchains: CPPToolchains
get() = ServiceManager
.getService(this, CPPToolchains::class.java)
.toolchains
.firstOrNull()
Or if you don't understand Kotlin, use Java:
CPPToolchains.Toolchain tools = ServiceManager
.getService(project, CPPToolchains.class)
.getToolchains().get(0);
And you can get the settings by codes like
tools.getCMake().getExecutable()
Or change them by invoking methods like
com.jetbrains.cidr.cpp.toolchains.CPPToolchains.Toolchain#setCustomMakePath
Just explore through those classes and methods, you'll get what you want.
If you still can't find any, try replace CPPToolchains
in the first two codes with CMakeSettings
and see if there's something in the class that fits your expectation.