CMake simple MVC structure

788 Views Asked by At

I have a simple question about how to organize my simple MVC application in C++. I'm new to CMake and I'm just learning how to use it.

Imagine a simple folder organization like the following:

Folder Structure

-Can someone please tell me if this structure is correct? -If so what is the best way to write the cmake files for it?

1

There are 1 best solutions below

9
On BEST ANSWER

It looks pretty normal structure to me. In fact I use the same one in my projects. In the root CMake file you will put: include(Src/Model/CMakelists.txt) and CMakelists.txt might look like this:

set(MODEL_HEADERS 
    src/Model/model.hpp)
set(MODEL_SOURCES
    src/Model/model.cpp 
    ${MODEL_HEADERS})
list(APPEND ALL_SOURCES ${MODEL_SOURCES})
source_group("Model" FILES ${MODEL_SOURCES})

Where ALL_SOURCES is the variable from the root file which is later passed to add_executable

Repeat the same for all your subfolders and you will have the final project.