Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ project organisation (with gtest, cmake and doxygen)
    primarykey
    data
    text
    <p>I am new to programming in general so I decided that I would start by making a simple vector class in C++. However I would like to get in to good habits from the start rather than trying to modify my workflow later on.</p> <p>I currently have only two files <code>vector3.hpp</code> and <code>vector3.cpp</code>. This project will slowly start to grow (making it much more of a general linear algebra library) as I become more familiar with everything, so I would like to adopt a "standard" project layout to make life easier later on. So after looking around I have found two ways to go about organizing hpp and cpp files, the first being:</p> <pre><code>project └── src ├── vector3.hpp └── vector3.cpp </code></pre> <p>and the second being:</p> <pre><code>project ├── inc │ └── project │ └── vector3.hpp └── src └── vector3.cpp </code></pre> <p>Which would you recommend and why?</p> <p>Secondly I would like to use the Google C++ Testing Framework for unit testing my code as it seems fairly easy to use. Do you suggest bundling this with my code, for example in a <code>inc/gtest</code> or <code>contrib/gtest</code> folder? If bundled, do you suggest using the <code>fuse_gtest_files.py</code> script to reduce the number or files, or leaving it as is? If not bundled how is this dependency handled?</p> <p>When it comes to writing tests, how are these generally organized? I was thinking to have one cpp file for each class (<code>test_vector3.cpp</code> for example) but all compiled in to one binary so that they can all be run together easily?</p> <p>Since the gtest library is generally build using cmake and make, I was thinking that it would make sense for my project to also be built like this? If I decided to use the following project layout:</p> <pre><code>├── CMakeLists.txt ├── contrib │ └── gtest │ ├── gtest-all.cc │ └── gtest.h ├── docs │ └── Doxyfile ├── inc │ └── project │ └── vector3.cpp ├── src │ └── vector3.cpp └── test └── test_vector3.cpp </code></pre> <p>How would the <code>CMakeLists.txt</code> have to look so that it can either build just the library or the library and the tests? Also I have seen quite a few projects that have a <code>build</code> and a <code>bin</code> directory. Does the build happen in the build directory and then the binaries moved out in to the bin directory? Would the binaries for the tests and the library live in the same place? Or would it make more sense to structure it as follows:</p> <pre><code>test ├── bin ├── build └── src └── test_vector3.cpp </code></pre> <p>I would also like to use doxygen to document my code. Is it possible to get this to automatically run with cmake and make?</p> <p>Sorry for so many questions, but I have not found a book on C++ that satisfactorily answers these type of questions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload