• 11
• 9
• 10
• 9
• 11

# What Is A Good Src Hierarchy For An Engine Using Cmake?

This topic is 437 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello all,

I started working on an engine. For beginning I had all my src files in one folder, and one CMakeLists.txt.
Now, it seems a good time to split things up a bit.
I'm wondering if I'm splitting things up a bit much.
Here is basic layout for my  hierarchy:

Low-Level-Systems-Library (LLSL)

• Atomic Data Types
• Collections and Iterators
• Hi-Resolution timer
• Platform Detection
• Assertions
• Memory Allocation
• Input

Game-Engine-Library (GEL)

• Physics
• PhysicsWorld.cpp
• PhysicsBodies(folder)
• .cpp & .hpp files
• Forces & Constraints
• HUD
• Button
• Slider
• Game Object
• Particle Systems
• Camera
• AI Systems

Game-Creation-Software (GCS)

Anyways the point is I'm not sure this will play will with CMake. That'd be alot of CMakeLists.txt.
Then there is also the difference between src layout, and project filter layout.

What do you recommend?

This will require alot of CMakeLists.txt & each directory essentially becomes a library.
I'm a beginner at using CMake and was wondering what you would recommend/ What is a good layout (eg the sweet spot with sub-dirs/ how to decide that sweet spot & considerations when looking at project dir layout, and src layout when using CMake.

Thanks!

##### Share on other sites

Ideally I think this is about discover-ability. Personally I like to be able to look at the source tree in the Explorer and get at least some understanding how the engine is structured, So what you describe looks already pretty good. I use something along the lines like this:

Game1

Game2

Engine

Tools

And then something along these lines:

Engine

Common

Physics

Renderer

MaterialSystem

SceneSystem

GameObjects

Tools

ModelEditor

MayaPlugin

CMake should be able to support this and having one CMake file per project seems fine. I use Premake which I prefer over CMake and I have one premake.lua file per project as well.

If you ever want to ship some kind of SDK it might make sense to split the source tree into public headers and implementation.

##### Share on other sites

If you are using Visual Studio and want your solution filters to reflect the directory structure you should take a look at this post on stackoverflow: How to set Visual Studio Filters for nested sub directory using cmake

You can also organise the projects into folders by first enabling solution folders

set_property(GLOBAL PROPERTY USE_FOLDERS ON)


and then setting them for each project

set_target_properties(yourLibraryOrExecutable PROPERTIES FOLDER "Parentfolder/yourLib")


Keep in mind that (afaik) these only affect the way your stuff is organized in your solution files and otherwise have no effect on your build.

EDIT: I did not realize this thread was already half a year old when answering, but maybe my information might still be helpful to someone who stumbles across this thread.

Edited by Infinity95