Excluding external subprojects from being added to run configurations...
Hi,
I've recently starting using cmake's FetchContent system to add external projects to my CLion project. This largely automates the process of ‘importing’ an external project in a git repository into your own project.
It mostly works, except that CLion adds all subprojects from the external projects to my list of 'Run Configurations', making it hard to find my own actual projects, as there's a lot of external subprojects but only a few of mine!
There's an EXCLUDE_FROM_ALL option to FetchContent_Declare which I think is supposed to prevent this happening, but it doesn't seem to do anything. EXCLUDE_FROM_ALL doesn't seem to do anything in add_subdirectory either.
Also, semi-related, but is there any way to prevent CLion auto-detecting .git folders in subprojects as VCS roots?
Subprojects from FetchContent are actually stored in cmake-build-blah dirs, and I've already got a .gitignore pattern for these so I was a bit surprised that they showed up at all.
Bye!
Mark
Please sign in to leave a comment.
Hi Mark,
You can disable automatic detection of VCS roots (including those of subprojects added by FetchContent_Declare) by navigating to Settings > Version Control > Directory Mappings and unchecking “Enable automatic mapping detection” and hit “Apply”. Note that you may need to manually add your project's root.
I'm not sure how to similarly ignore the build targets of subprojects, though you can organise them into folders to make them less obtrusive. Navigate to Run > Edit Configurations, then select the run configurations of your dependencies and click the “Move into New Folder” button in the top left. You should notice that the list of run configurations is collapsed into your new folder. You can also “Pin” the run configurations of your own project from the drop down menu to further improve visibility.
Yours sincerely,
Robert