Integration with CMake

Hello,

I configured my project in CLion 1.2.1 with CMake flag -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=my_build_dir and some other flags that I normally use. CLion puts the compiled executables in the specified directory (i.e. my_buld_dir), but does not copy any input files needed to run tests, for example. When configuring from command line in Linux, I can do the following:

cd my_build_dir
cmake -D[some flags] my_source_dir
make && ctest

Can CLion be configured so that it builds the executables in my_build_dir and the contents of my_build_dir is identical to the content I would obtain when building from command line?

Thank you.

Martin

6 comments
Comment actions Permalink

Hi Martin.

Please try setting Build Output path on the Settings | Build, Execution, Deployment | CMake tab. Does that help?

0
Comment actions Permalink

Hello Anna,

the Build Output path was set to my_build_dir. When I don't do that, the sources don't compile (I get an error when the compiler doesn't manage to explicitly instantiate a template class). In addition, CLion seems to ignore the fact that I set -DCMAKE_BUILD_TYPE=RELWITHDEBINFO and puts the compiled executables in a folder my_build_dir/Debug. Finally, I set the make flags to '-j2', but CLion anyway uses all (8) cores of my computer.

Best regards,

  Martin

0
Comment actions Permalink

Could you send a screenshot with the 'Settings | Build, Execution, Deployment | CMake' tab, please?

0
Comment actions Permalink

Hello Anna,

I'm attaching 3 screenshots with cmake config options and also the build window. As you can see (cmake_build.jpg), the build is first performed in ~/.CLion12/..../Debug, despite the fact that I said that the build type should be RelWithDebInfo. Are the cmake configuration options case sensitive? As far as I know, CMake itself is not.

Best regards,

Martin



Attachment(s):
cmake_config2.jpg
cmake_config1.jpg
cmake_build.jpg
0
Comment actions Permalink

Hi Martin!

Unfortunatelly, there is no way to limit CLion’s processor core usage, -j2 is an option passed to make so building the project will use only two cores. Does it match with observed behaviour?
Please try changing RelWithDebInfo in the Run | Edit Configurations - Configuration pane. Will it work?

0
Comment actions Permalink

Hi Anna,

changing to RelWithDebInfo as you suggested indeed works, but I find this behaviour confusing at best - what's the point of specifying CMake arguments if CLion ignores them? This is not much of an issue though. What interests me the most is whether I can compile the code in a user-specified directory and have the correct directory structure (with input files needed testing, ctest config etc.). Is this possible?

Martin

0

Please sign in to leave a comment.