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.

6 comments
Comment actions Permalink

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'.

0
Comment actions Permalink

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.

0
Comment actions Permalink

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. 

0
Comment actions Permalink

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?

0
Comment actions Permalink

Could you please specify what in-source settings from `CMakeLists.txt` files you mean in particular?

0
Comment actions Permalink

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?

0

Please sign in to leave a comment.