Skip to content

sagiegurari/cmake-modules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmake-modules

Release license

Reusable cmake utilities for C projects.

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

list(APPEND CMAKE_MODULE_PATH "cmake-modules/src")

Load the cmake module

include(utils)

Another way is to automatically download it if missing, for example:

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:

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

Release History

See Changelog

License

Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.