-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d83a8cf
commit 10a66c8
Showing
7 changed files
with
198 additions
and
64 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,66 +2,29 @@ | |
|
||
This repository is a template for C/C++ packages. | ||
|
||
## Package structure | ||
|
||
``` bash | ||
. | ||
└── c_cpp_pkg_template | ||
├── .clang-format | ||
├── .clang-tidy | ||
├── CMakeLists.txt | ||
├── docs | ||
│ ├── assets | ||
│ │ └── placeholder | ||
│ ├── index.md | ||
│ └── javascripts | ||
│ └── mathjax.js | ||
├── .github | ||
│ └── workflows | ||
│ └── mkdocs_ci_gh_pages.yml | ||
├── .gitignore | ||
├── include | ||
│ └── PackageName | ||
│ ├── temp.hpp | ||
│ └── template.h | ||
├── mkdocs.yaml | ||
├── PackageName-config.cmake.in | ||
├── .pre-commit-config.yaml | ||
├── README.md | ||
├── src | ||
│ ├── CMakeLists.txt | ||
│ ├── example | ||
│ │ ├── CMakeLists.txt | ||
│ │ └── temp_ex.c | ||
│ └── template.c | ||
└── test | ||
├── CMakeLists.txt | ||
├── main_test.c | ||
└── temp_test.c | ||
``` | ||
|
||
## Setup | ||
|
||
### Prerequisites | ||
|
||
- CMake | ||
- C/C++ compiler | ||
- check (unit testing framework) | ||
- Doxygen | ||
- clang-format | ||
- clang-tidy | ||
- pre-commit | ||
- [pre-commit](https://pre-commit.com/) | ||
|
||
#### Install prerequisites | ||
|
||
``` bash | ||
sudo apt-get install check clang-format clang-tidy | ||
```bash | ||
sudo apt-get install doxygen check clang-format clang-tidy | ||
|
||
pip install pre-commit | ||
``` | ||
|
||
### Workspace setup | ||
|
||
``` bash | ||
```bash | ||
mkdir ~/c_cpp_ws && cd ~/c_cpp_ws | ||
|
||
mkdir build install src | ||
|
@@ -77,15 +40,15 @@ You can use any directory structure you prefer. | |
|
||
1. Clone the repository | ||
|
||
``` bash | ||
```bash | ||
cd ~/c_cpp_ws/src | ||
|
||
git clone [email protected]:secorolab/c_cpp_pkg_template.git | ||
``` | ||
|
||
2. Rename the cloned repository | ||
|
||
``` bash | ||
```bash | ||
mv c_cpp_pkg_template <PackageName> | ||
cd <PackageName> | ||
|
@@ -104,7 +67,7 @@ or | |
2. Add the necessary content to the files | ||
3. Initialize the git repository | ||
|
||
``` bash | ||
```bash | ||
git init | ||
``` | ||
|
||
|
@@ -116,46 +79,79 @@ or | |
|
||
2. Run the following command in the `root` directory of the package to install the pre-commit hooks. | ||
|
||
``` bash | ||
```bash | ||
pre-commit install | ||
``` | ||
|
||
## Build and install | ||
|
||
1. Create a build directory for the package | ||
|
||
``` bash | ||
```bash | ||
cd ~/c_cpp_ws/build | ||
mkdir PackageName && cd PackageName | ||
``` | ||
|
||
2. Run the following command in the build directory | ||
|
||
``` bash | ||
cmake -DCMAKE_INSTALL_PREFIX=../../install ../../src/PackageName -DCMAKE_BUILD_TYPE=Debug \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_TESTS=ON | ||
```bash | ||
cmake -DCMAKE_INSTALL_PREFIX=../../install ../../src/PackageName \ | ||
-DCMAKE_BUILD_TYPE=Debug \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | ||
-DENABLE_TESTS=ON | ||
``` | ||
|
||
- `-DCMAKE_INSTALL_PREFIX=../../install`: Specifies the installation directory | ||
- `-DCMAKE_BUILD_TYPE=Debug`: Specifies the build type (Debug, Release, RelWithDebInfo, MinSizeRel) | ||
- `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON`: Generates compile_commands.json file | ||
- `-DENABLE_TESTS=ON`: Enables the unit tests | ||
- `-DENABLE_DOC=ON`: Enables the documentation generation | ||
|
||
3. Build the package | ||
|
||
``` bash | ||
```bash | ||
make -j $(nproc) | ||
``` | ||
|
||
- If `ENABLE_TESTS` is set to `ON`, the tests will be built as well. | ||
|
||
4. Install the package | ||
|
||
``` bash | ||
```bash | ||
make install | ||
``` | ||
|
||
## Configs | ||
|
||
### MkDocs | ||
|
||
- To generate the documentation, you can use the [MkDocs](https://www.mkdocs.org/) tool. | ||
- The [mkdocs.yaml](mkdocs.yaml) file contains the configuration for the documentation. | ||
- Refer to the Plugins and Reference sections in the [Material for MkDocs documentation](https://squidfunk.github.io/mkdocs-material/reference/) | ||
for more information about the configuration. | ||
|
||
### Doxygen | ||
|
||
- To generate the documentation, you can use the [Doxygen](https://www.doxygen.nl/index.html) tool. | ||
- The [Doxyfile](Doxyfile.in) file contains the default configuration for the documentation. | ||
|
||
> [!IMPORTANT] | ||
> Refer the [best practices](https://github.com/secorolab/.github-private/blob/main/best_practices/c_cpp.md) | ||
for more information. | ||
> Configure the [mkdocs.yaml](mkdocs.yaml) and [mkdocs_gh_pages_deploy.yml](/github/workflows/mkdocs_gh_pages_deploy.yml) | ||
files accordingly based on whether your project has API documentation or not. | ||
|
||
### Pre-commit | ||
|
||
- The [pre-commit-config.yaml](.pre-commit-config.yaml) file contains the configuration for the | ||
pre-commit hooks. | ||
- Update the `build` and `install` paths in the `clang-format` and `clang-tidy` hooks, based on your | ||
workspace setup. | ||
- Also, update the `Set up build` and `Configure and build` in the [build_format_lint.yml](.github/workflows/build_format_lint.yml), | ||
if you have a different build setup. | ||
|
||
### GitHub Actions | ||
|
||
- The [build_format_lint.yml](.github/workflows/build_format_lint.yml) file contains the configuration | ||
to test the package build, and check the code formatting and linting. | ||
- The [mkdocs_gh_pages_deploy.yml](.github/workflows/mkdocs_gh_pages_deploy.yml) file contains the | ||
configuration to deploy the documentation to GitHub Pages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.