fulmicoton
fulmicoton

Reputation: 15968

Organizing a CMake project so that sources can be easily browsed in Visual C++

(I'm new to CMake and I am not so familiar with Visual Studio.)

I need to implement a relatively big library the solution/project files will be generated by CMake, and my problem is that I would like the organization of the files in VC GUI to reflect the directory structure on the disk.

Basically, the library is split into different parts. For instance one of them is called "common" and will implement some headers used by the library. On the disk it will be in a specific "common" directory, which may have one or more subdirectory.

src/
   common/
     ...
   portfolio/
     ...
   asset/
     contracts/
     physical_assets/
     ...
   mathutils/
   ...

I'd like to have the see the same thing within Visual Studio's Solution Explorer, but I only know how to split the solution into different projects. How can I do that?

Upvotes: 8

Views: 3767

Answers (3)

Georg Fritzsche
Georg Fritzsche

Reputation: 98994

You can do that using SOURCE_GROUP, the CMake FAQ covers that.

Upvotes: 8

JesperE
JesperE

Reputation: 64414

I don't think you can. If you use "Show All Files" you will get what you want, but only at the project level. Creating a VS project at the root may give you the possiblity of viewing all your files, but you will still need separate projects for each exe/dll/etc. you want to build. Remember that a solution in VS terms is a set of projects, not a directory tree.

Upvotes: 1

stijn
stijn

Reputation: 35901

Not sure if this is what you're after, but: first make sure you have "Tools->Options->Projects and Solutions->Solution Explorer Mode" set to "Show All Files". Then if you create a VS project in the root source directory (probably the same as where your CMakeLists.txt goes), VS will show all files in that directory and all it's subirectories.

Upvotes: 0

Related Questions