Skip to content

Overview of the toy repository

Thomas Hahn edited this page Dec 12, 2024 · 5 revisions

In the rest of this tutorial, we work with the toy repository moderncpp_vscode.

Set up the repo

We first create our workspace folder moderncpp_vscode and then clone the GitHub repo into the source folder moderncpp_vscode.src:

mkdir moderncpp_vscode && cd moderncpp_vscode
git clone https://github.com/Thoemi09/moderncpp_vscode.git moderncpp_vscode.src

Then we open the workspace folder in VS Code by using >File: Open Folder... and selecting the folder moderncpp_vscode which we created above:

workspace

Note: Our workspace folder (opened in VS Code) is not the same as the source folder.

Overview of the repo

The toy repository contains a small linear algebra library linalg based on nda. Although it is kept very simple, it has a more or less standard project structure (all paths are relative to the source folder):

  • ./CMakeLists.txt: Top level CMakeLists.txt file.
  • ./include: Header files of the library.
  • ./src: Source files of the library.
  • ./tests: Unit tests based on googletest.
  • ./examples: Simple examples that use the library.
  • ./deps: Fetches the dependencies nda and googletest.

The other files ./.clang-format and ./.clang-tidy will be explained along the way.

The ./vscode folder contains VS Code specific files used in this tutorial.

Syntax highlighting

If you open the file ./src/linalg.cpp, you should see that VS Code supports basic syntax highlighting for C++:

syntax_highlighting

This is not the case for CMake files:

cmakelists_syntax_hl

In the bottom right corner, it says Plain Text. That means VS Code treats the file as a plain text file.

To fix this problem, we will install (enable) our first extension: CMake