@@ -709,38 +709,39 @@ void Checks::read_parallel_checks_for_workers(const path &dir)
709709
710710void Checks::write_definitions (CMakeContext &ctx, const Package &d, const StringSet &prefixes) const
711711{
712- String m = " INTERFACE" ;
713- if (!d.flags [pfHeaderOnly])
714- m = " PUBLIC" ;
715- if (d.flags [pfExecutable])
716- m = " PRIVATE" ;
717-
718- auto print_def = [&ctx, &m, &prefixes](const String &value, auto &&s)
712+ const auto m = [&d]
713+ {
714+ if (!d.flags [pfHeaderOnly])
715+ return " PUBLIC" s;
716+ if (d.flags [pfExecutable])
717+ return " PRIVATE" s;
718+ return " INTERFACE" s;
719+ }();
720+
721+ auto print_def = [&ctx, &m, &prefixes](const auto &value, const auto &s)
719722 {
720- ctx << m << " " << s << " =" << value << CMakeContext::eol ;
723+ ctx. addLine (m + " " + s + " =" + value) ;
721724 for (const auto &p : prefixes)
722- ctx << m << " " << p + s << " =" << value << CMakeContext::eol ;
725+ ctx. addLine (m + " " + p + s + " =" + value) ;
723726 return 0 ;
724727 };
725728
726- auto add_if_definition = [&ctx, &print_def](const String &s, const String &value, auto && ... defs )
729+ auto add_if_definition = [&ctx, &print_def](const String &s, const String &value, const std::vector<String> &defs = std::vector<String>() )
727730 {
728- ctx.addLine (" if (" + s + " )" );
729- ctx.increaseIndent ();
731+ ctx.if_ (s);
730732 ctx.addLine (" target_compile_definitions(${this}" );
731733 ctx.increaseIndent ();
732734 print_def (value, s);
733- using expand_type = int [];
734- expand_type{ 0 , print_def (value, std::forward< decltype (defs)>(defs))... } ;
735+ for ( auto &def : defs)
736+ print_def (value, def) ;
735737 ctx.decreaseIndent ();
736738 ctx.addLine (" )" );
737- ctx.decreaseIndent ();
738- ctx.addLine (" endif()" );
739+ ctx.endif ();
739740 ctx.addLine ();
740741 };
741742
742743 // aliases
743- add_if_definition (" WORDS_BIGENDIAN" , " 1" , " BIGENDIAN" , " BIG_ENDIAN" , " HOST_BIG_ENDIAN" );
744+ add_if_definition (" WORDS_BIGENDIAN" , " 1" , { " BIGENDIAN" , " BIG_ENDIAN" , " HOST_BIG_ENDIAN" } );
744745
745746 for (auto &c : checks)
746747 {
0 commit comments