How to structure your project

    First, this is what your files should look like when you start if your project is creatively called , with a library called lib, and a executable called app:

    The names are not absolute; you’ll see contention about test/ vs. tests/, and the application folder may be called something else (or not exist for a library-only project). You’ll also sometime see a folder for python bindings, or a cmake folder for helper CMake files, like Find<library>.cmake files. But the basics are there.

    You often want a cmake folder, with all of your helper modules. This is where your Find*.cmake files go. An set of some common helpers is at github.com/CLIUtils/cmake. To add this folder to your CMake path:

    Your extern folder should contain git submodules almost exclusively. That way, you can control the version of the dependencies explicitly, but still upgrade easily. See the Testing chapter for an example of adding a submodule.

    If you want to avoid the build directory being in a valid source directory, add this near the top of your CMakeLists:

    See the .