• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## Basic build using CMake
2
3Panda libraries can be built using CMake:
4```
5$ mkdir build
6$ cd build
7$ cmake ${panda_dir}
8$ make
9```
10
11Where ${panda_dir} is a path to panda dirrectory.
12These steps will create libraries and some debug targets (if you have installed additional libraries, like google-test, clang-format, clang-tidy, etc.).
13
14## Build directory structure
15
16In the current build directory structure, each project has its own subdirectory. For example, the vixl library is located inside the `third_party/vixl` folder. The root CMakeLists.txt has an entry for this directory:
17```
18add_subdirectory(third_party/vixl)
19```
20You may use built libraries in your component (e.g., `target_link_libraries(tests compiler base vixl)`), but for getting variables please use the INTERFACE includes (e.g. `target_include_directories(INTERFACE .)`).
21
22
23## Check style
24
25To check style, build the project and then also build style-checker targets (you must install clang-format and clang-tidy with libraries - look at scripts/bootstrap*.sh):
26```
27$ make clang_format
28    Built target clang_format_opt_tests_graph_creation_test.cpp
29    Built target clang_format_opt_opt.h
30    ...
31
32$ make clang_tidy
33    Scanning dependencies of target copy_json
34    Move compile commands to root directory
35    ...
36    Built target copy_json
37    Scanning dependencies of target clang_tidy_opt_codegen_codegen.cpp
38    ...
39```
40
41You may force fixes for clang-format issues, with the `make clang_force_format` command.
42Run `make help | grep clang` to see all possible clang-[format|style] targets.
43For example, to check style issues in the opt.cpp file, you can use corresponding clang-format target (`make clang_format_opt_opt.cpp`) or the clang-tidy one (`make clang_tidy_opt_opt.cpp`). To force clang-format code style - `make clang_force_format_opt_opt.cpp`.
44To check code-style through just one check-system - use `make clang_tidy` or `make clang_format`.
45
46Generated files:
47*  `compile_commands.json` - json nija-commands file to correct execution clang-tidy.
48*  Standard cmake-files: `CMakeCache.txt`, `Makefile`, `cmake_install.cmake`  and `CMakeFiles` folder.
49
50[Coding style](../docs/coding-style.md)
51
52*  Clang-tidy style file - `.clang-tidy`
53*  Clang-format style file - `.clang-format`
54*  Script to show diff through clang-format execution - `scripts/run-clang-format.py`
55
56