Customizing the build/run process

So I downloaded CLion today and started trying to get my company project working in it. This is already a well-established project that we've been working on for well over a year, and has a reasonably defined build process using cmake. I have been able to build the project, and that seems to work, however I'm a little bit confused about how running the actual project works. Oddly enough, I cannot run the actual software by using the run command - however, I am able to get it to run with the debug command. It looks like, when I try to run it, CLion executes the binary in a folder that looks something like /home/developer/.clion10/system/cmake/generated/62f2c3c6/62f2c3c6/Debug/output/bin/<target>. That's a little problematic for me, as I need to specify some paths relative to the binary in an environment variable and a argument - additionally we have things in the program itself that create log files, for example, relative to the executeable. So the question is

#1 is there a token or special variable I can use to specify the build path in my build parameters?
#2 is there a way to specify the actual build path to something of my choosing rather than a random folder deep in clion folder structure?

0
4 comments

Hello,

CLion takes all the information from cmake so you can use usual CMake variables to specify this like CMAKE_BINARY_DIR.

0

What about the second question? It seems like there is nothing I can do to change where the binary is built at.

0

For this set CMAKE_RUNTIME_OUTPUT_DIRECTORY in CMakeListst.txt or directly in CMakeCache (you can also check the discussion here: http://youtrack.jetbrains.com/issue/CPP-96).

0

For building libraries use:

 
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib)


For executables use:

 
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin)


The absolute path is necessary, because relative paths are relative to the build directory and not your project directory.

0

Please sign in to leave a comment.