cmake install?


I'm new to CMake, so maybe there's a better way to do this, but how can I make CLion install an executable/component it just built?

Basically, I want some targets (Run/Debug Configurations), but not others, to automatically perform an installation step after building as defined by the install command in the CMake project. So I'd like to be able to somehow append "install" or a component name to the CMake command line generated by CLion, but I haven't found a way to do this. The "Build options" under CMake Settings appear to apply to all targets (including Clean) so that won't really help. This doesn't seem like an uncommon thing to do so maybe I'm just misunderstanding how either CMake or CLion are meant to be used. Any ideas?

Comment actions Permalink

You can define the build directory... where executable, resources, ... can be placed:

If your project is named test123 and you have the desire to place all files in a directory named "build", it would be:

Comment actions Permalink

Hi Georg.

We have a feature request in the tracker:
Feel free to comment or upvote and also try to use some workaround from the comments.

This article also could be helpful:

Comment actions Permalink

Thanks. I added an external tool step to the configurations that need it. But that solution seems somewhat inelegant given that building and installing could be achieved with a single CMake command.


Please sign in to leave a comment.