self-hosting
MoAlyousef 4 years ago
parent 23eeaf667c
commit 4db372900d

3
.gitignore vendored

@ -1,4 +1,5 @@
bin bin
compile_commands.json compile_commands.json
.clangd .clangd
temp.* temp.*
.vs

@ -50,6 +50,7 @@ type = "exe" # required (exe || shared || static)
sources = ["src/main.cpp", "src/args.cpp", "src/gen.cpp"] # required sources = ["src/main.cpp", "src/args.cpp", "src/gen.cpp"] # required
include_directories = ["vendor"] # optional include_directories = ["vendor"] # optional
compile_features = ["cxx_std_17"] # optional compile_features = ["cxx_std_17"] # optional
# definitions = [] # optional
# link_libraries = [] # optional # link_libraries = [] # optional
``` ```
@ -59,13 +60,13 @@ Usage: cmkr [arguments]
arguments: arguments:
init [exe|shared|static] Starts a new project in the same directory. init [exe|shared|static] Starts a new project in the same directory.
gen Generates CMakeLists.txt file. gen Generates CMakeLists.txt file.
build [cmake args...] Run cmake and build. build [extra cmake args] Run cmake and build.
help Show help. help Show help.
version Current cmkr version. version Current cmkr version.
``` ```
The build command invokes cmake and the default build-system on your platform, it also accepts extra cmake arguments: The build command invokes cmake and the default build-system on your platform, it also accepts extra cmake arguments:
``` ```
cmkr build -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain -DCMAKE_BUILD_TYPE=Release cmkr build -GNinja -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain -DCMAKE_BUILD_TYPE=Release
``` ```
## Roadmap ## Roadmap

@ -18,5 +18,6 @@ type = "exe" # required (exe || shared || static)
sources = ["src/main.cpp", "src/args.cpp", "src/gen.cpp"] # required sources = ["src/main.cpp", "src/args.cpp", "src/gen.cpp"] # required
include_directories = ["vendor"] # optional include_directories = ["vendor"] # optional
compile_features = ["cxx_std_17"] # optional compile_features = ["cxx_std_17"] # optional
# definitions = [] # optional
# link_libraries = [] # optional # link_libraries = [] # optional

@ -167,6 +167,7 @@ void generate_cmake() {
} }
ss << ")\n\n"; ss << ")\n\n";
} }
if (bin.contains("link_libraries")) { if (bin.contains("link_libraries")) {
const auto libraries = toml::find(bin, "link_libraries").as_array(); const auto libraries = toml::find(bin, "link_libraries").as_array();
ss << "target_link_libraries(" << bin_name << " PUBLIC\n\t"; ss << "target_link_libraries(" << bin_name << " PUBLIC\n\t";
@ -175,6 +176,7 @@ void generate_cmake() {
} }
ss << ")\n\n"; ss << ")\n\n";
} }
if (bin.contains("compile_features")) { if (bin.contains("compile_features")) {
const auto feats = toml::find(bin, "compile_features").as_array(); const auto feats = toml::find(bin, "compile_features").as_array();
ss << "target_compile_features(" << bin_name << " PUBLIC\n\t"; ss << "target_compile_features(" << bin_name << " PUBLIC\n\t";
@ -183,6 +185,15 @@ void generate_cmake() {
} }
ss << ")\n\n"; ss << ")\n\n";
} }
if (bin.contains("definitions")) {
const auto defs = toml::find(bin, "definitions").as_array();
ss << "target_add_definitions(" << bin_name << " PUBLIC\n\t";
for (const auto &def : defs) {
ss << def << "\n\t";
}
ss << ")\n\n";
}
} }
} }

Loading…
Cancel
Save