I'm trying to convert several big makefile-based applications to CMake to use CLion on them.
Every time I open the project, however, CLion takes about a quarter of an hour to load the CMake project, while the memory indicator stays below "750 of 1987MB". I admit that I'm a CMake newbie, so I guess my CMakeLists.txt files are not optimal.
Basically every application has some specific source code in a directory of its own and is using a couple of 'common' libraries. I have made a structurally equivalent project for sharing on github:
https://github.com/pe-st/zalophus/tree/master/tree
In that project there is an application 'a' and two common librairies 'atlas' and 'greeting'. Every library contains a folder 'test' with Googletest tests.
+ common
| + atlas
| | + test
| + greeting
| + test
+ a
In reality there are about a dozen libraries below common with about 1500 .cpp and .hpp files in total, all of them using Boost and the standard library, nothing else.
The master branch of the project on github contains my first attempt, where all directories are referenced using 'add_subdirectory'. The second attempt (in the with_ext branch) is using ExternalProject_Add for the dependent libraries. When I compile/run the tests from 'greeting' it correctly compiles also the dependency 'atlas'. However it also tries to compile/run the tests of 'atlas' (which fails...) and I couldn't work out how to just compile 'atlas' without the tests.
So how should I better design the CMake project to work with a source code base as shown?
(Note: I have asked the same question also in the Jetbrains CLion forum: https://intellij-support.jetbrains.com/hc/en-us/community/posts/207559245-Large-CMake-Project-loading-is-slow-in-CLion-)
CLion is very, very slow – IDEs Support (IntelliJ Platform) | JetBrains. Please consider editing your post and mark it as obsolete instead.
The issue is not really with the CMakeLists.txt
. CLion parses all source files referenced in cmake to enable most features (navigation, code-completion, refactoring). In my experience, indexing large projects can take up to several (tens of) minutes.
A way to mitigate this issue is to mark "third party" directories of your project as such: right-click on your common
directory, and Mark directory as... > Libraries
. You can even exclude directories from the project if needed.
Also note that the results of CLion indexing are cached: after the initial indexing, only modified files should be reparsed, even when restarting the project (Note that modifying the build options in CMakeLists might trigger a full re-index)
Have you tried increasing the heap size?
https://www.jetbrains.com/help/idea/increasing-memory-heap.html
From the "Build File Properties" dialog box try increasing the Maximum heap size field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With