0

I am completely new to CMake, and I have never used it before. I am trying to understand how to organize my files. Right now, I have this structure:

.
├── cli
│   ├── cli.cpp
│   ├── cli.h
│   ├── interactive.cpp
│   ├── interactive.h
│   ├── web.cpp
│   └── web.h
├── core
│   ├── Job.cpp
│   ├── Job.h
│   ├── Settings.cpp
│   ├── Settings.h
│   ├── Utils.cpp
│   └── Utils.h
└── ui
    ├── img
    │   └── appicon.xpm
    ├── main.cpp
    ├── main.h
    ├── MainHeader.cpp
    ├── MainHeader.h
    ├── MainWindow.cpp
    ├── MainWindow.h
    ├── SettingsPanel.cpp
    └── SettingsPanel.h

How should I rearrange these files and what would a basic CMakeLists.txt look like?

Thank you.

  • Does this help? https://stackoverflow.com/a/34439276/15284149 – Mysterious User Feb 28 '21 at 03:28
  • Do you want to create **single executable** from all of these files? If so, then use command `add_executable` with list of all files. Or do you want to create a **library** from files under `cli/` and compile other files into the executable? The library is created with `add_library` command. "I am completely new to CMake, and I have never used it before." - Have you tried to read any tutorial about CMake? – Tsyvarev Feb 28 '21 at 09:11
  • CMake does not impose any sort of structure on your files. The question you should be asking yourself is what the correct logical organization of your build should be: which files are grouped together to create libraries and executables. Design your directory layout around that, and the CMake will follow. – Alex Reinking Feb 28 '21 at 20:44

0 Answers0