How to change a build directory in CLion? Is it possible to use in-source-tree build? Why does CLion generate several build types at once?

To change build output path, go to Build, Execution, Deployment | CMake settings and set it there. Alternatively, you can configure the RUNTIME_OUTPUT_DIRECTORY property in your CMakeLists.txt file.

Please note that CLion currently supports only out-of-source build and does a lot in the background that makes in-source-tree and CMake execution directory configurations impossible. Moreover, files under ~/.clion/system/cmake/generated are not intended to be used directly, as they are managed and updated by the IDE.

In case of a low amount of disk space for your user directory, you should probably move the whole ~/clion/system folder to another partition. Read here how to do it.

To guarantee the correct language model, CLion needs to generate the project for several build types (e.g. Debug, Release), and keep them synchronized and up to date. These generated files are stored in the private folder, and actually it's 'implementation details.' In this scheme there are not one but several CMAKE_BINARY_DIR folders, for each build type.

You can, however, benefit from it by changing the configuration type (Debug -> Release, or other ways) and getting the correct code resolve in editor, in compliance with the configuration type. How to change the configuration type.

Currently we do consider adding ability to specify the generation output directory under this feature request. Please, share your use case in the linked ticket.



Hi Team! The out of source builds are great! I currently use the Build Output Path setting to put all the build artifacts together into a single folder which is a bit more accessible -- in case i need to run these executables from the CMD prompt in Windows. The problem i'm encountering though is that not all the files are actually being routed to this alternative output path. For example, the configured headers 


Similarly, flat files copied into the build directory using file(COPY...) are also not copied. 

file(COPY ./etc/post_run.rcf DESTINATION etc)

Is there anything I'm doing wrong, or would this be an enhacement to the Build Output Path feature for the IDE?


When you set Build Output Path in CLion, it actually configures the CMAKE_RUNTIME_OUTPUT_DIRECTORY. So this is just the setting that is passed to CMake. So you can just use the CMAKE_RUNTIME_OUTPUT_DIRECTORY variable for the DESTINATION in your CMake files to do the job. 




So...I was expecting that when I set the "Build Output Path", this would allow me to control the "--build" parameter passed to cmake.  It doesn't.  I'd like to control where my builds go.  Is that possible?

Edited by Steve Wilson

Build Output Path in CLion is exactly the CMAKE_RUNTIME_OUTPUT_DIRECTORY variable of CMake. So it's the directory where the final artefacts are copied.


That's understood from your earlier comments.  Once again, we're looking for control over where the build actually takes place (i.e. where object files are generated), not where build output products like libraries and executables are copied to.  Every IDE I've ever used has allowed me to control where the build takes place, including the very awesome intellij.  I would also suggest that "Build Output Path" is a misleading name given that the build output doesn't actually go there.  

I will look around the support site for a "feature enhancement request" since this doesn't seem to be the right venue.


Steve, it's currently not possible to change the directory where the actual build takes place (, since it's the directory CLion uses internally.
We hope to fix it in 2016.3 version.


Please sign in to leave a comment.

Have more questions?

Submit a request