CLion and virtual project structure

Is it possible to have a project structure independent on folder structure? I have quite complex physical project structure spanning different repositories. It looks like:

  • RepoA (cross platform)
    • ProjectA
      • src
        • FolderA
          • SubFolderA
        • FolderB
      • include
    • ProjectB
      • src
      • include
  • RepoB (platform specific)
    • ProjectA
      • src
        • FolderA
          • SubFolderA
        • FolderB
      • include
    • ProjectB
      • src
      • include


To build for specific platform, content of RepoA and RepoB must be merged together (that is why everything is named exactly same). Resulting folder with CMake scripts looks like:

  • Platform
    • CMakeLists.txt
    • ProjectA
      • CMakeLists.txt
    • ProjectB
      • CMakeLists.txt


Individual CMakeLists.txt contain paths to source and include files from RepoA and RepoB.

When I open similar structure in CLion, I first get only Platform directory with its structure. All source files are directly in the root. Include files are not in the project at all. First of all why are include files missing and why are those files not added into folder where related CMakeLists.txt is located?

I need to change the project root to the first common parent of RepoA and RepoB to get all source codes and include files into CLion. The first problem is that it also brings in tons of other directories which I don't want in the project - I didn't find any project structure control known from Idea allowing me to exclude some directories. I really don't like idea of changing my folder structure or creating some links just to satisfy needs of IDE. The second problem is that it reflects the physical directory structure - repositories/projects/folders are not merged as in CMake files.

Is it possible to define virtual project structure based on CMake files? CLion already has all the knowledge about location of files and structure of project directory (containing CMakeLists.txt). Now it only needs to give me better options to structure those files. As a side note, this is not a problem in Visual Studio or XCode but I need a cross platform IDE.

4 comments
Comment actions Permalink

Ladislav,
it's hard do say why some files are missing without looking at CMakeLists files.
In general, CLion collects everything that is mentioned in add_executable/add_library targets in the CMakeLists.txt. add_custom_target is not currently supported.

As for the virtual structure, we'll discuss this possibiility in future.

0
Comment actions Permalink

Thanks Anton, is there at least a way to exclude directory or file from the CLion project? Right now if I want to have both RepoA and RepoB in CLion together, I must change the project root to parent folder of RepoA and RepoB. That folder can contain many unrelated directories (full of source codes) which I don't want in CLion.

0
Comment actions Permalink

No, it's not possible to exclude folders. Plese follow this reqiest

0
Comment actions Permalink

Hi, I'd really like the ability to create a virtual folder structure also. Swift package manager requires the directory structure to match the module build, so now I have to put over a 100 files into the same folder (which is annoying). Xcode and Visual Studio allow a virtual folder view for easy organization. This would allow users to see only files they care about in a way that makes sense to their project. It could be a separate view in the project panel.

1

Please sign in to leave a comment.