The src/CMakeLists.txt files will have a main target composed of mesh.cpp, node.cpp, solver.cpp, element.cpp. I also have a unit-test/CMakeLists.txt that unit tests the mesh, element and solver components. How to avoid having to recompile the same mesh.cpp, node.cpp, solver.cpp, element.cpp also in the unit-test subdirectory? I do not want to define them as targets again but rather be able to use the targets already defined in src/CMakeLists.txt
The blog follows the same approach you mentioned of defining a library. It does not really use an alternative approach. It only adds the use of CTest and GTest to the mix but that I am already doing.
Thus, in essence it seems the approach is to define a library