Cmake package manager in rust-cargo style
- unloading and caching of dependencies;
- formalization of the project structure and configuration;
- semantic version control;
- automatic target generation (lib/bin/test/bench);
- cross-compilation;
- post-commit hook for clang-format
- pre-commit hook for auto-tagg by version
- CMake >= 3.10
- git
- python3 (optional for git-hooks)
Copy and include bastard_setup.cmake file in CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
include(cmake/bastard_setup.cmake)
bastard_setup()
project(${BASTARD_PACKAGE_NAME})Run cmake
cd build && cmake ..Project initialization will begin. Bastard's files will be unloaded into the .deps directory as an simple dependence. Next, config of the package will be unloaded from bastard.toml file and all build targets will be generated.
Project initialization begins after calling the bastard_setup() function, so any global specific options must be set higher.
-
[package]
name: strPackage name (must be unique for build)authors: list[str]List of authorsautogen-defines: boolDefines autogeneration from options (with prefix)version: strPackage version (vX.X.X)lang: strDefault lang for all targets of packagec90|c99|c++98|c++11|c++14|c++17|c++20system: [str]Default platform specification (usuallyUnix | Windows | Generic)processor: [str]Default processor specification (see. CMAKE_SYSTEM_PROCESSOR)
-
[dependencies] General package dependencies
<package>: strPackage namegit: strGit url (git@orhttp)tag: strGit tag (formatvX.X.X)branch: strGit branchrev: strGit hashlinks: list[str]List of libraries for links. Only for non-bastard packages, cause bastard package can contain only single library.path: strPath for local dependencyinterface: strPath for header library filessystem: [str]Platform specification (see [package.system])processor: [str]Processor specification (see [package.processor])
-
[dev-dependencies] Developers dependencies
- Similar to
[dependencies]
- Similar to
-
[sys-dependencies] System dependencies (cmake find_package)
<package>: strPackage name (example Thread, Boost)components: list[str]Components listlinks: list[str]Library list
-
[lib] General package library
name: strLibrary namelang: strUsing language (see. package.lang)include: [str]Include files relative bylibdir (example[*.cpp, *.c])exclude: [str]Exclude files (seeinclude)
-
[[bin]] Package binaries
name: strTarget name (or path for default, ifpathsection not exist)path: strPath of file/directory for buildlang: strUsing language (see. package.lang)include: [str]Include filesexclude: [str]Exclude filesincludeиexcluderelativebin/nameorbindirectoryconsole: boolIf application is console (by default true)
-
[[test]] Package test-binaries
- Similar to
[bin]
- Similar to
-
[[example]] Package examples
- Similar to
[bin]
- Similar to
-
[options] CMake variables for targets (legacy)
<package> = { <name>=<value> }
By default, if the sections [lib] [[bin]] are not specified, the legacy agreement is accepted when all dependencies are connected manually in CMakeLists.txt. For legacy mode, it is possible to use any project structure, however, the bastard functionality is limited only to uploading dependencies and setting options. If you follow the project structure agreement, then the package configuration will occur automatically.
-- cmake/
-- include/
---- mylib/
------ mylib.h
-- lib/
---- mylib.cpp
-- tests/
---- main.cpp
-- bastard.toml
-- CMakeLists.txt
-- cmake/
-- bin/
---- app1/
------ main.cpp
---- app2/
------ main.cpp
-- bastard.toml
-- CMakeLists.txt
-- cmake/
-- bin/
---- app1/
------ main.cpp
---- app2/
------ main.cpp
-- include/
---- mylib/
------ mylib.h
-- lib/
---- mylib.cpp
-- tests/
---- test1.cpp
---- test2.cpp
-- bastard.toml
-- CMakeLists.txt
to be continued...
