Setting CMake Options and Build Directory

I'm trying to create a CLion plugin which needs to set some additional CMake generation options, as well as the build directory. I've come across some promising code in the `CMakeSettings` class, and have managed to use this inside a custom project component to set a custom build directory and generation option. My questions are:

  • Is it possible to customise the directory in which the cmake command runs?
  • Is there a better way to customise the build options without overwriting the user's global CMake settings?
  • The custom build directory has the target name appended to it (e.g. my/build/directory/Debug), is there a way to avoid this?

Thanks.

6 comments

Andrew, currently it's not possible to override the default CLion behavior with a plugin. What workflow do you want to support with a custom plugin?

 

0

I'm trying to create a plugin for Robot Operating System (ROS) support. It's a meta-framework for building robotic applications commonly used in research and a bit in industry.

ROS uses Catkin, which is essentially a slightly customised CMake build. It would be great if I could integrate the CLion build process to support this. Catkin expects the following layout for a workspace:

  • src/ - the source files of the project, opened as the project root in CLion
  • devel/
  • build/ - the directory where the cmake command is run
  • install/

To be able to support this I would need to:

  1. Be able to run `cmake ...` in the "build" directory.
  2. Be able to specify "-DCMAKE_INSTALL_PREFIX" and "-DCATKIN_DEVEL_DIR" arguments to the cmake command.
0

Andrew, while you can specify arguments passed to the cmake manually or via plugin, it is not possible to override the build (generation) folder. We plan to implement it 2016.2 (can't commit on this, though), here are a couple of request you might want to follow:

CPP-3374 Ability to specify the build/generation output directory

CPP-2596 Allow opening project from existing CMake generated folder

CPP-838 Ability to run 'install' and choose CMAKE_INSTALL_PREFIX before debugging/running the application

0

Thanks for the helpful links Anton, I will keep an eye on them.

In terms of specifying arguments passed to cmake via a plugin, could you share some brief pointers on the best way to do this? At the moment I'm overwriting the user's custom cmake argument settings, which obviously is not ideal.

0

This is the only way currently, I'm afraid.

How are these arguments specified normally? (without using the IDE, I mean)

0

It uses the catkin_make command which is a python script that performs some workspace sanity checks and then calls cmake with some arguments set.

0

Please sign in to leave a comment.