I have a C++ project with the following structure (which I'm not sure it conforms to best-practices, maybe this needs restructuring):
ProjectRootDir
|-- program_subdir
|-- program.cpp
|-- libraries
|-- Library1
|-- Library1.h
|-- Library1.cpp
|-- Library2
|-- Library2.h
|-- Library2.cpp
My project has program.cpp (which should compile to an executable) on subdirectory "program_subdir". In turn, the code in program.cpp includes libraries 1 and 2 in the following way:
#include <Library1.h>
#include <Library2.h>
I've been searching how to correctly set up CMake to compile this project, and I see there are multiple and different answers that often refer to old versions of CMake (newer versions such as 3.15+, or 3.19+ seem to have added features for including subdirs, including libraries, etc, which directly affect the way this could be done).
As a note, maybe I should point out that I'm using the word "library" here, but there's no need to compile Library1 and Library2 as actual libraries that could be linked from elsewhere. This is just a way to structure the code in this project (again, maybe this is wrong?).
I have many years of experience in Java and other languages, but C++ is definitely not my strong suit, so perhaps there's some other misconception here.
How can I set up this project with CMake? (how many CMakeLists.txt files, how would an up to date CMakeLists.txt look like for this project taking advantage of all latest CMake features, which at the time of this writing looks like it's version 3.21).
Thanks!