Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the way target.headers is merged into target.sources #68

Merged
merged 1 commit into from
Oct 6, 2022
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
1 change: 0 additions & 1 deletion include/project_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ struct Target {
TargetType type = target_last;
std::string type_name;

ConditionVector headers;
ConditionVector sources;

// https://cmake.org/cmake/help/latest/manual/cmake-commands.7.html#project-commands
Expand Down
17 changes: 10 additions & 7 deletions src/project_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,18 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
throw std::runtime_error(format_key_error(error, target.type_name, t.find("type")));
}

t.optional("headers", target.headers);
t.optional("sources", target.sources);

// Merge the headers into the sources
ConditionVector headers;
t.optional("headers", headers);
for (const auto &itr : headers) {
auto &dest = target.sources[itr.first];
for (const auto &jtr : itr.second) {
dest.push_back(jtr);
}
}

t.optional("compile-definitions", target.compile_definitions);
t.optional("private-compile-definitions", target.private_compile_definitions);

Expand All @@ -514,12 +523,6 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
t.optional("precompile-headers", target.precompile_headers);
t.optional("private-precompile-headers", target.private_precompile_headers);

if (!target.headers.empty()) {
auto &sources = target.sources.nth(0).value();
const auto &headers = target.headers.nth(0)->second;
sources.insert(sources.end(), headers.begin(), headers.end());
}

t.optional("condition", target.condition);
t.optional("alias", target.alias);

Expand Down