(probably stupid) CLion project/library question
Answered
Hi folks, I have a question about the correct way to load two existing projects, one of which is a library and the other is the program. As of now they exist in completely different directories. I'd like to open both in a way that allows symbol navigation between the two.
Is there a way to open (and potentially edit) both, with the primary benefit being code navigation?
Thanks in advance.
Please sign in to leave a comment.
Hello
I'm trialing CLion and have been trying to figure this sort of stuff out too.
There apparently isn't a “workspace” concept in CLion, as exists in VS Code, Visual Studio, XCode etc. It's a requested feature, but apparently this goes back years and years and they've not implemented it yet, so presumably it's not likely in the short term at least.
I have a bunch of static library projects, with some dependencies between some of them. They all exist and can be built independently but I also wanted them to appear in the same “workspace” in CLion. It seems one has to create an additional “super project”. Once I did this, I was able to load all the projects via this super project and run batch builds etc on them. I didn't have to change the individual CMakeLists.txt - they were still able to exist with their own project(mylib) name in their own CMakeLists.txt.
So my super CMakeLists.txt just contain something like this:
project(superbuild)
add_subdirectory(lib1)
add_subdirectory(lib2)
add_subdirectory(lib3)
etc.
This works reasonably well as far as I can tell so far.
Maybe you can achieve similiar with your app + lib? I think the only problem would be you might need to locate them in subdirectories below the new super project.
Hope this helps
Oviano, thank you so much for your response; I'll try that approach.
Cheers!
Hello!
Just for the record, here is the related feature request - https://youtrack.jetbrains.com/issue/CPP-1537. Feel free to comment or upvote it. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.
The current workaround for CMake projects is indeed creating a top-level CMake file containing just
add_subdirectory()
projects pointing to the actual projects.