Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Test
run: |
cd build/tests
ctest -C ${{ env.BUILD_TYPE }}
ctest -C ${{ env.BUILD_TYPE }} --verbose

- name: Upload artifacts
uses: actions/upload-artifact@v2
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/examples/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ description = "Header-only library"
[target.mylib]
type = "interface"
include-directories = ["include"]
compile-features = ["cxx_std_11"]

[target.example]
type = "executable"
Expand Down
40 changes: 40 additions & 0 deletions docs/examples/templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# Automatically generated from tests/templates/cmake.toml - DO NOT EDIT
layout: default
title: Target templates
permalink: /examples/templates
parent: Examples
nav_order: 7
---

# Target templates

To avoid repeating yourself in targets you can create your own target type (template). All properties of the template are inherited when used as a target type.

```toml
[project]
name = "templates"
description = "Target templates"

[template.app]
type = "executable"
sources = ["src/templates.cpp"]
compile-definitions = ["IS_APP"]

# Unlike interface targets you can also inherit properties
[template.app.properties]
CXX_STANDARD = "11"
CXX_STANDARD_REQUIRED = true

[target.app-a]
type = "app"
compile-definitions = ["APP_A"]

[target.app-b]
type = "app"
compile-definitions = ["APP_B"]
```

**Note**: In most cases you probably want to use an [interface](/examples/interface) target instead.

<sup><sub>This page was automatically generated from [tests/templates/cmake.toml](https://github.com/build-cpp/cmkr/tree/main/tests/templates/cmake.toml).</sub></sup>
69 changes: 0 additions & 69 deletions include/enum_helper.hpp

This file was deleted.

14 changes: 13 additions & 1 deletion include/project_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ enum TargetType {
target_interface,
target_custom,
target_object,
target_template,
target_last,
};

extern const char *targetTypeNames[target_last];

struct Target {
std::string name;
TargetType type = {};
TargetType type = target_last;
std::string type_name;

ConditionVector headers;
ConditionVector sources;
Expand Down Expand Up @@ -100,6 +105,12 @@ struct Target {
ConditionVector include_after;
};

struct Template {
Target outline;
std::string add_function;
bool pass_sources_to_add_function = false;
};

struct Test {
std::string name;
std::string condition;
Expand Down Expand Up @@ -160,6 +171,7 @@ struct Project {
std::vector<Package> packages;
Vcpkg vcpkg;
std::vector<Content> contents;
std::vector<Template> templates;
std::vector<Target> targets;
std::vector<Test> tests;
std::vector<Install> installs;
Expand Down
Loading