aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 5c163d2619b9cd764b00b5f3ebfd266ada092441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

C++ Basics, simple C++ lessons

Original document location.

Git Repository

This project's canonical repositories is hosted on Gothel Software.

Goals

This project aims to demonstrate the C++ language for our computer science class.

Supported Platforms

C++20 and better.

Building Binaries

Build Dependencies

  • CMake 3.13+ but >= 3.18 is recommended
  • C++20 compiler
    • gcc >= 10
    • clang >= 15
  • Optional for lint validation
    • clang-tidy >= 16
  • Optional for eclipse and vscodium integration
    • clangd >= 16
    • clang-tools >= 16
    • clang-format >= 16

Installing build dependencies on Debian (11 or better):

apt install git
apt install build-essential g++ gcc libc-dev libpthread-stubs0-dev 
apt install clang-16 clang-tidy-16 clangd-16 clang-tools-16 clang-format-16
apt install cmake cmake-extras extra-cmake-modules pkg-config
apt install doxygen graphviz

Perhaps change the clang version-suffix of above clang install line to the appropriate version.

After complete clang installation, you might want to setup the latest version as your default. For Debian you can use this clang alternatives setup script.

Build Procedure

The following is covered with a convenient build script.

For a generic build use:

CPU_COUNT=`getconf _NPROCESSORS_ONLN`
git clone --recurse-submodule git://jausoft.com/srv/scm/cs_class/cpp_basics.git
cd cpp_basics
mkdir build
cd build
cmake ..
make -j $CPU_COUNT install doc

Our cmake configure has a number of options, cmake-gui or ccmake can show you all the options. The interesting ones are detailed below:

Changing install path from /usr/local to /usr

-DCMAKE_INSTALL_PREFIX=/usr

Building with clang and clang-tidy lint validation

-DCMAKE_C_COMPILER=/usr/bin/clang 
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ 
-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy;-p;$rootdir/$build_dir

To build documentation run:

make doc

IDE Integration

Eclipse

IDE integration configuration files are provided for

  • Eclipse with extensions
    • CDT or CDT @ eclipse.org
    • CDT-LSP recommended
      • Should work with clang toolchain >= 16
      • Utilizes clangd, clang-tidy and clang-format to support C++20 and above
      • Add to available software site: https://download.eclipse.org/tools/cdt/releases/cdt-lsp-latest
      • Install C/C++ LSP Support in the Eclipse CDT LSP Category
    • CMake Support, install C/C++ CMake Build Support with ID org.eclipse.cdt.cmake.feature.group

You can import the project to your workspace via File . Import... and Existing Projects into Workspace menu item.

For Eclipse one might need to adjust some setting in the .project and .cproject (CDT) via Eclipse settings UI, but it should just work out of the box.

VSCodium or VS Code

IDE integration configuration files are provided for

For VSCodium one might copy the example root-workspace file to the parent folder of this project (note the filename change) and adjust the path to your filesystem.

cp .vscode/cpp_basics.code-workspace_example ../cpp_basics.code-workspace
vi ../cpp_basics.code-workspace

Then you can open it via File . Open Workspace from File... menu item.

  • All listed extensions are referenced in this workspace file to be installed via the IDE
  • The local settings.json has clang-tidy enabled
    • If using clang-tidy is too slow, just remove it from the settings file.
    • clangd will still contain a good portion of clang-tidy checks