r/cmake

▲ 3 r/cmake

Help for project configuration

Hi. I am starting a pretty big C++ project and I want to set up CMake as my build system. I am new to it and I struggle mostly with subdirectory and library stuff. For instance, this is my current setup. It seems to work okay but I just have a feeling it isn't up to par. I would just like the opinion of anyone with more experience than I on how to set up a big project with many subdirectories and files. Thank you in advance

Main or root CMakeLists.txt file

cmake_minimum_required(VERSION 4.0)

project(PoticusEngine LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED_ON)

add_executable(poticus main.cpp)

set(SOURCES
  engine/core/memory/arena.cpp
  engine/core/memory/arena.h
)

add_library(engine STATIC ${SOURCES})

add_subdirectory(engine)

target_sources(poticus 
  PRIVATE
    log.cpp
    log.h
    main.cpp
    types.h
)

engine/CMakeLists.txt

add_subdirectory(core)

engine/core/CMakeLists.txt

add_subdirectory(memory)

engine/core/memory/CMakeLists.txt

target_sources(poticus
  PRIVATE
    arena.cpp
    arena.h
)
reddit.com
u/Ok_Voice9367 — 4 days ago