https://github.com/sagiegurari/cmake-modules
Reusable cmake utilities for C projects.
https://github.com/sagiegurari/cmake-modules
cmake cmake-modules
Last synced: 3 months ago
JSON representation
Reusable cmake utilities for C projects.
- Host: GitHub
- URL: https://github.com/sagiegurari/cmake-modules
- Owner: sagiegurari
- License: apache-2.0
- Created: 2020-08-21T15:18:41.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-21T15:48:16.000Z (almost 3 years ago)
- Last Synced: 2025-01-27T09:11:27.292Z (over 1 year ago)
- Topics: cmake, cmake-modules
- Language: CMake
- Homepage:
- Size: 23.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# cmake-modules
[](https://github.com/sagiegurari/cmake-modules/releases)
[](https://github.com/sagiegurari/cmake-modules/blob/master/LICENSE)
> Reusable cmake utilities for C projects.
* [Overview](#overview)
* [Usage](#usage)
* [Contributing](.github/CONTRIBUTING.md)
* [Release History](CHANGELOG.md)
* [License](#license)
## Overview
The cmake-modules contains basic reusable building blocks for cmake C projects.
Those include:
* Downloading git repository
* Downloading github repository
* Setting variables for sources, headers, etc... for downloaded repositories
* Add test targets easily
* Run ccpcheck
* Run uncrustify
* Create and increment build file
* Run xxd on resource files
Include the cmake modules in the module path
```cmake
list(APPEND CMAKE_MODULE_PATH "cmake-modules/src")
```
Load the cmake module
```cmake
include(utils)
```
Another way is to automatically download it if missing, for example:
```cmake
if(NOT EXISTS "target/cmake-modules/src/utils.cmake")
execute_process(COMMAND git clone https://github.com/sagiegurari/cmake-modules.git)
endif()
include("target/cmake-modules/src/utils.cmake")
```
Use the different capabilities in your CMakeLists.txt for example:
```cmake
utils_add_external_github_lib(
REPO_USERNAME sagiegurari
REPO_NAME c_scriptexec
TAG_NAME "0.1.3"
LIBRARY_NAME scriptexec
LIBRARY_PARENT_DIRECTORY target
)
utils_setup_c_test(
NAME
stability
long_run
valid_input
invalid_input
ADDITIONAL_SOURCES "test/core.c;test/core.h"
COMPILATION_FLAGS "-Werror -Wall -Wextra -Wcast-align -Wunused -Wshadow -Wpedantic"
BINARY_DIRECTORY "target/bin"
)
utils_setup_c_all_tests(
ADDITIONAL_SOURCES "test/core.c;test/core.h"
COMPILATION_FLAGS "-Werror -Wall -Wextra -Wcast-align -Wunused -Wshadow -Wpedantic"
BINARY_DIRECTORY "target/bin"
)
```
## Contributing
See [contributing guide](.github/CONTRIBUTING.md)
See [Changelog](CHANGELOG.md)
## License
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.