How to specify build directory?
Answered
I need to specify build directory (cmake-build-debug) in CMakeLists.txt file, not in Settings interface. What variables does it? If it is necessary I use catkin_make. When I build the project some_dir/src/project/ all the build files are generated in some_dir/src/project/cmake-build-debug, but i need in some_dir/cmake-build-debug.
Please sign in to leave a comment.
Hi! Why do you need to specify it right in the CMakeLists.txt file? The right way to specify the output dir is to use 'Settings | Build, Execution, Deployment | CMake | Generation path'.
Hi, Anna! I know about this setting, but I need to specify it from the CMakeLists.txt. I use CLion only as a comfortable editor and build the projects from console, so there are sometimes problems with generated files by CLion and console cmake/catkin. Also I have many projects and it is not comfortable to specify the path for each project in Settings. More easier to specify it in every CMakeLists without reference to usable editor. I predict that build path is read from CMakeLists variable or some hidden config file but I hope that true is the first way.
Hi, Daniel,
Sorry for the late response. You can specify the directory in which binaries will be generated by setting CMAKE_RUNTIME_OUTPUT_DIRECTORY in CMakeLists.txt.
CLion 2020.1 -> File -> Settings... -> Build, Execution, Deployment -> CMake -> Generation path
The `Generation path` is manually configured, it doesn't seem to follow any in-source settings from `CMakeLists.txt` files.
The directory names chosen by the IDE are outside of automatic influence by the sources - they cannot be ignored until set via clicks (or luckily guessed), they also cannot be moved/hidden automatically under some directory to avoid clutter.
Any ideas how to deal with it and make this setting controllable from state of the sources?
Could you please specify what in-source settings from `CMakeLists.txt` files you mean in particular?
Hi Anna,
I am also having a hard time trying to set up the build directory from CMakeLists.txt. I did set the CMAKE_RUNTIME_OUTPUT_DIRECTORY variable to my liking but CLion continues to use `cmake-build-${CMAKE_BUILD_TYPE} as the directory where it generates all the CMake stuff. It seems that the final output is generated in the directory specified by CMAKE_RUNTIME_OUTPUT_DIRECTORY, but this is not what I'm looking for.
What I want is to have the same behavior I have changing the Build directory option under Build, Execution, Deployment -> CMake, but I want to set it in CMakeLists.txt, not on CLion. What can I do?