Jump to content
  • Advertisement
Sign in to follow this  

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

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

If you intended to correct an error in the post then please contact us.

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
  • Treading Library
  • Platform Detection
  • Assertions
  • Memory Allocation
  • Input


Game-Engine-Library (GEL)

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

Game-Creation-Software (GCS)
    (Not sure about this one, it's basically my editor)



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.


Share this post

Link to post
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:







And then something along these lines:














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 this post

Link to post
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


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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!