Why does CLion not instantly generate configuration files in my new project?

 

I'm currently working on a CLion Plugin, which involves creating a new Project. Once it's created, I open up a new window with said project. My problem is that CLion only seems to generate the .iml and modules.xml files after I close and reopen the project. My question is, what am I missing or doing wrong?

My steps so far:

  1. I create the necessary project root directory
  2. I call ProjectManager.getInstance().createProject(projectName, projectPath) which returns a Project object.
  3. I open the project in a new Window by calling ProjectManager.getInstance().loadAndOpenProject(project.getPresentableUrl())

A new window opens but the config files mentioned above are not generated. Only if I close the project and reopen it, the config files are generated and cmake support is enabled.

My thoughts on this: I would probably need to create a module inside the project? But then what exactly is the right way to do this programmatically? In this case I would like to create a C Module but I found nothing showing me how to do this. Following the tutorial on the intellij sdk documentation by creating a modulebuilder doesn't seem to work in CLion. The only source code I found while searching the internet is the CLion Arduino Plugin, which quite frankly has the same problem.

Anything pointing me in the right direction on this one would be greatly appreciated. Is there any documentation on how to do this kind of thing?

1
5 comments

Could you please explain what kind of functionality you would like to build? I'll try to come up with suggestions.

0
Avatar
Permanently deleted user

What I'm trying to do, is creating a new Project (C/C++) with certain configurations applied to said project. These configurations enable support for developing applications for embedded systems and integrates an on chip debugging tool.
So, I want to be able to create a new Project and apply certain settings to it (e.g. hardware configuration like flash address) in a project wizard. What this project wizard does: create a new project (obviously), create/add a run configuration and a debugging configuration, generate an appropriate toolchain configuration file for cmake all while using the settings provided in the project wizard.
I've been using com.jetbrains.cidr.cpp.cmake.projectWizard.CMakeProjectWizard and CMakeProjectStepAdapter as base classes for my project wizard.
Given the case, that I still want to create C/C++ applications, which do not run on embedded systems, I thought it would be better to have a separate project wizard alltogether, rather than altering anything post "normal" project creation.
Due to a lot of experimenting/trial and error my code base is a mess at the moment, but if it helps I can share some code snippets...
Long story short: I want to be able to create a new project and instantly be able to compile, run and debug my application with the appropriate hardware without messing around with any other configurations!
I hope this makes some kind of sense!

0
Avatar
Permanently deleted user

So in short my question would be, how do I create a new CLion project programmatically?

0

You need to inherit from one of `com.jetbrains.cidr.cpp.cmake.projectWizard.generators.CMakeProjectGenerator` subclasses. E.g. `CMakeAbstractCPPProjectGenerator` for a C++ project. To make your project templates distinct, provide a custom group name via `CMakeProjectGenerator#getGroupName`

1
Avatar
Permanently deleted user

Thank you for pointing me in the right direction. Another question came up: `CMakeProjectGenerator#generateProject()" takes a Module as argument. How do I correctly handle the Module creation? `ModuleManager#newModule()` fails with "IllegalArgumentException: Extension is missing for storage file".

0

Please sign in to leave a comment.