[cmake] Group targets into folders #5188
Labels
No labels
Accessibility
Address
Android
Android Auto
Android Automotive (AAOS)
API
AppGallery
AppStore
Battery and Performance
Blocker
Bookmarks and Tracks
Borders
Bug
Build
CarPlay
Classificator
Community
Core
CrashReports
Cycling
Desktop
DevEx
DevOps
dev_sandbox
Directions
Documentation
Downloader
Drape
Driving
Duplicate
Editor
Elevation
Enhancement
Epic
External Map Datasets
F-Droid
Fonts
Frequently User Reported
Fund
Generator
Good first issue
Google Play
GPS
GSoC
iCloud
Icons
iOS
Legal
Linux Desktop
Linux packaging
Linux Phone
Mac OS
Map Data
Metro
Navigation
Need Feedback
Night Mode
NLnet 2024-06-281
No Feature Parity
Opening Hours
Outdoors
POI Info
Privacy
Public Transport
Raw Idea
Refactoring
Regional
Regression
Releases
RoboTest
Route Planning
Routing
Ruler
Search
Security
Styles
Tests
Track Recording
Translations
TTS
UI
UX
Walk Navigation
Watches
Web
Wikipedia
Windows
Won't fix
World Map
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: organicmaps/organicmaps#5188
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "github/fork/AndrewShkrob/cmake/group-targets-into-folders"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Small enhancement for cmake
CMakeLists.txt
to3party/CMakeLists.txt
.omim_add_subdirectory
that groups all targets under the subdirectory into one folder (for IDEs that support this feature).It won't break anything as it only affects the visual representation in the IDE
Before:
After:
This looks a bit hacky to achieve visual changes in IDE... What doesn't work if we keep original add_subdirectory() everywhere?
What doesn't work if we keep add_subdirectory() original?
Think of it as a generic solution to group targets recursively. It works even if the project in the subdirectory doesn't support this feature by default.
Everything will work except that we'll have a mess in the targets list as shown in the "Before" screenshot.
Some libs (especially 3party) produce a lot of targets that may be impossible to determine what library/module they belong to.
F.e.
gflags
. That's what it looks like after my changes.Another example is
protobuf
. We have now a very old version of it (v3, I guess). I'd like to update it to the new one (v23) and link it as a submodule directly. It should fix build warnings when we'll migrate to C++20. But it will produce dozen of targets (with meaningless names) that will mess up our targets list even more. So, that will be a good solution to store all related targets under the3party/protobuf/...
folder.Check the answer above
Does it rearrange targets in XCode only? Or also in CLion?
We do not use CMakelists.txt now in XCode. Do you generate XCode project manually?
It depends on the generator used by cmake. Xcode and Visual Studio generators support grouping targets into folders.
But IDE should also support this feature.
CLion supports folder structure for targets. Unfortunately, I wasn't able configure it to make it automatically based on CMakeLists.txt. Perhaps, in future updates they will add support for this feature.
Yes
I don't use XCode for core dev and don't know the problems. But, if you want, use the current solution with xcode/omim.xcworkspace and support it.
We have plans to complex reconsider XCode + cmake. Let's avoid such kind of patches like _omim_get_all_targets_in_dir for now.
So, let's make 3party/CMakeList only. XCode then will group all useless targets inside 3party folder and you even will not see them, right?
Ok, if XCode still will be ugly, you can put targets workaround code near add_subdirectory(3party) only ..
Or find an option to hide 3party subfolder in XCode (don't know if it's possible).
Is there a way to add upstream protobuf cmake project but import only relevant targets from it?
We can disable tests targets but seems nothing more.
One big problem is that it has https://github.com/abseil/abseil-cpp as a 3party which has target
base
It's not possible to have two targets with same name - abseil's base and our base
The only solution I figured out is to rename our targets - add the prefix
omim_
. And we can also add an alias likeOMIM::base
.What do you think?
I don't like adding complex code patches because if some 3party libs (or IDEs inconveniences).
Especially renaming our core code base. I suspect that we can easily compile 3party targets into separate 3party folder with literally 5 code lines. Or even don't compile useless targets for us. We need only protobuf lib.
Our initial approach was very flexible and lightweight, relatively easy to support (for non header-only 3party libs):
An alternative solution could be to use protobuf libs from the system, but it may complicate the development setup for contributors.
A complex protobuf submodule can be an issue. Renaming our base classes because of some other target looks badly wrong.
Only 3party/CMakeLists.txt left under this PR
approved this merge request
approved this merge request
mentioned in merge request !5557