cmake install?

Hi,

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?

0
3 comments

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:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${test123_SOURCE_DIR}/build")

0

Hi Georg.

We have a feature request in the tracker:
https://youtrack.jetbrains.com/issue/CPP-838
Feel free to comment or upvote and also try to use some workaround from the comments.

This article also could be helpful:
https://www.jetbrains.com/clion/help/external-tools.html

0

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.

0

Please sign in to leave a comment.