@@ -487,9 +487,18 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
487487 throw std::runtime_error (format_key_error (error, target.type_name , t.find (" type" )));
488488 }
489489
490- t.optional (" headers" , target.headers );
491490 t.optional (" sources" , target.sources );
492491
492+ // Merge the headers into the sources
493+ ConditionVector headers;
494+ t.optional (" headers" , headers);
495+ for (const auto &itr : headers) {
496+ auto &dest = target.sources [itr.first ];
497+ for (const auto &jtr : itr.second ) {
498+ dest.push_back (jtr);
499+ }
500+ }
501+
493502 t.optional (" compile-definitions" , target.compile_definitions );
494503 t.optional (" private-compile-definitions" , target.private_compile_definitions );
495504
@@ -514,12 +523,6 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
514523 t.optional (" precompile-headers" , target.precompile_headers );
515524 t.optional (" private-precompile-headers" , target.private_precompile_headers );
516525
517- if (!target.headers .empty ()) {
518- auto &sources = target.sources .nth (0 ).value ();
519- const auto &headers = target.headers .nth (0 )->second ;
520- sources.insert (sources.end (), headers.begin (), headers.end ());
521- }
522-
523526 t.optional (" condition" , target.condition );
524527 t.optional (" alias" , target.alias );
525528
0 commit comments