cmake, glob, glob_recurse, adding files, reloading cmake and performance issues

I'm having some performance issues with my cmake project in CLion. In my cmake files we are using glob (and maybe glob_recurse, not sure) to avoid having to add files to the cmake files all the time.

This practice is not recommended by CMake and I understand that the reason is that if you add a file and rely on glob to pick it up then cmake doesn't actually know that a dependency changed because the cmake file didn't change because you didn't actually add the file name to cmake file. And that's why I have to reload the CMake files when using CLion.

CLion supports adding files to the build dependency, and this solves the problem when not using glob. The user gets a dialog offering to add that file to one or more cmake files. The cmake file gets the source file added thereby touching the cmake file and the build dependency works. There is no need to reload the entire cmake hierarchy. And I'll have to guess that CLion can take advantage of this and not rebuild the entirety of the indices, only modify the parts that changed.

Here's the idea though. If the dialog that offers to add the file to the source dependencies in the cmake files would offer to just touch the files instead then we get the same effect, I believe. Or even just silently touching them. I've tried this method by opening the cmake file in question and just making a cosmetic change and saving it to "touch it". It appears to work. A full reload is no longer necessary.

From a CLion perspective this could be really cool because cmake files using glob would work better in CLion than outside CLion. The recommendation from the cmake guys to not use glob won't change. It just won't apply to CLion users anymore so CLion users will be an exception. And that could make the CLion/CMake combination the most elegantly working IDE build system and the standard to beat.

 

6 comments
Comment actions Permalink

That's interesting. Olof, have you already placed this as a feature request to the tracker? If not, we'll probably do. This really sounds like a good idea we need to investigate deeper.

0
Comment actions Permalink

I'm glad you liked the idea. :)

I hope it can work out nicely.

I have not entered an issue and you'll probably do it better. Please go ahead. 

0
Comment actions Permalink

Olof, I've put it into the tracker as is for now: https://youtrack.jetbrains.com/issue/CPP-7589
Feel free to follow and comment on the initial idea.

0
Comment actions Permalink

I arrived here after some desperate googling.  

Is there a guide/example for how to use CLion with a CMake file that uses globbing.  I am not in a position to change the entire build system of our project to support an editor, but I really cannot find a way to get CLion to locate header files located within the same project as my source files.   

0
Comment actions Permalink

All you need is to add headers to the SOURCE_FILES used for CMake targets.

However GLOB is not a convenient option, since you need to manually reload CMake in CLion when adding some files, since CMake doesn't actually know that a dependency changed because you didn't actually add the file name to CMake file.

Could you maybe try Import Project functionality in CLion?

0
Comment actions Permalink

@Olof sorry for being late here. I have a couple of questions regarding your suggestion. Could we move the discussion to the ticket (CPP-7589)?

0

Please sign in to leave a comment.