You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cmkr/README.md

158 lines
4.2 KiB

4 years ago
# cmkr
4 years ago
cmkr, pronounced "cmaker", is A CMakeLists.txt generator from TOML.
4 years ago
## Building
4 years ago
cmkr requires a C++11 compiler, cmake >= 3.15.
```
git clone https://github.com/moalyousef/cmkr
cd cmkr
cmake -Bbin
4 years ago
cmake --build bin --parallel
```
## Usage
4 years ago
cmkr parses cmake.toml files (using toml11 by Toru Niina) at the project directory. A basic hello world format with the minimum required fields:
```toml
[cmake]
4 years ago
minimum = "3.15"
4 years ago
[project]
name = "app"
version = "0.1.0"
[[bin]]
name = "app"
type = "exe"
sources = ["src/main.cpp"]
```
This project's cmake.toml:
```toml
[cmake]
4 years ago
minimum = "3.15"
4 years ago
[project]
name = "cmkr"
4 years ago
version = "0.1.3"
[fetch-content]
4 years ago
toml11 = { git = "https://github.com/ToruNiina/toml11" }
4 years ago
filesystem = { git = "https://github.com/gulrak/filesystem" }
4 years ago
[[bin]]
name = "cmkrlib"
type = "static"
4 years ago
sources = ["src/cmake.cpp", "src/gen.cpp", "src/help.cpp", "src/build.cpp", "src/error.cpp"]
include-dirs = ["include"]
4 years ago
features = ["cxx_std_11"]
link-libs = ["toml11::toml11", "ghc_filesystem"]
4 years ago
[[bin]]
name = "cmkr"
type = "exe"
4 years ago
sources = ["src/main.cpp", "src/args.cpp"]
link-libs = ["cmkrlib"]
4 years ago
[[install]]
targets = ["cmkr"]
destination = "${CMAKE_INSTALL_PREFIX}/bin"
```
Currently supported fields:
```toml
4 years ago
[cmake] # required for top-level project
4 years ago
minimum = "3.15" # required
subdirs = [] # optional
bin-dir = "bin" # optional
cpp-flags = [] # optional
c-flags = [] # optional
link-flags = [] # optional
4 years ago
generator = "Ninja" # optional, only valid when run using: cmkr build
config = "Release" # optional, only valid when run using: cmkr build
arguments = ["CMAKE_TOOLCHAIN_FILE=/path/to/toolchain"] # optional, valid when run using: cmkr build
[settings] # optional
CMAKE_BUILD_TYPE = "Release"
TOML_BUILD_TESTS = false # optional
TOML_BUILD_DOCS = { value = false, comment = "builds dependency docs", cache = true, force = true } # optional
OLD_VERSION = "0.1.1" # optional
4 years ago
[project] # required per project
name = "app" # required
version = "0.1.0" # required
4 years ago
[find-package] # optional, runs find_package, use "*" to ignore version
Boost = { version = "1.74.0", required = false, components = ["system"] } # optional
spdlog = "*"
4 years ago
[fetch-content] # optional, runs fetchContent
4 years ago
toml11 = { git = "https://github.com/ToruNiina/toml11", tag = "v3.5.0" } # optional
[options] # optional
APP_BUILD_STUFF = false # optional
APP_OTHER_STUFF = { comment = "does other stuff", value = false } # optional
4 years ago
[[bin]] # required, can define several binaries
4 years ago
name = "app" # required
4 years ago
type = "exe" # required (exe || lib || shared || static || interface)
sources = ["src/*.cpp"] # required, supports globbing
include-dirs = ["include"] # optional
alias = "" # optional
4 years ago
features = [] # optional
4 years ago
defines = [] # optional
link-libs = [] # optional
4 years ago
properties = { PROPERTY1 = "property1", ... } # optional
4 years ago
4 years ago
[[test]] # optional, can define several
4 years ago
name = "test1" # required
4 years ago
command = "app" # required
arguments = ["arg1", "arg2"] # optional
4 years ago
[[install]] # optional, can define several
targets = ["app"] # optional
files = ["include/*.h"] # optional
dirs = [] # optional
configs = [] # optional (Release|Debug...etc)
destination = "${CMAKE_INSTALL_PREFIX}/bin" # required
```
The cmkr executable can be run from the command-line:
```
Usage: cmkr [arguments]
arguments:
init [exe|lib|shared|static|interface] Starts a new project in the same directory.
gen Generates CMakeLists.txt file.
build <extra cmake args> Run cmake and build.
4 years ago
install Run cmake --install. Needs admin privileges.
clean Clean the build directory.
help Show help.
version Current cmkr version.
```
4 years ago
The build command invokes cmake and the default build-system on your platform (unless a generator is specified), it also accepts extra cmake build arguments:
```
4 years ago
cmkr build --config Release
```
## Binary types
### exe
Executable binary.
### lib
Library, can be static or shared depending on the BUILD_SHARED_LIBS variable.
### static
Static library/archive.
### shared
Shared/dynamic library.
### interface
4 years ago
Header-only library.
## Roadmap
4 years ago
- Support more cmake fields.
4 years ago
- Support conditional cmake args somehow!