<div dir="ltr"><div>Thanks, Boris! it worked like a charm.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 29, 2019 at 11:17 AM Boris Kolpackov <<a href="mailto:boris@codesynthesis.com">boris@codesynthesis.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Alberto Sartori <<a href="mailto:alberto.sartori@sissa.it" target="_blank">alberto.sartori@sissa.it</a>> writes:<br>
<br>
> I would like to use build2 to build some executables for a course of<br>
> C++. I have several source files (each one with a main) and I would like<br>
> to compile a couple of them with a couple of more flags with respect to<br>
> the others. How can I do that?<br>
> <br>
> $ cat build/root.build<br>
> cxx.std = 14<br>
> <br>
> using cxx<br>
> <br>
> cxx{*}: extension = cc<br>
> <br>
> cxx.coptions=-O3<br>
> cxx.poptions=-Wall -Wextra<br>
> <br>
> $ cat buildfile<br>
> <br>
> src = 01_enum.cc      \<br>
> 02_scoped_enum.cc     \<br>
> 03_namespace.cc               \<br>
> 04_why_scoped.cc      \<br>
> 05_struct_class.cc    \<br>
> 06_constructor_destructor.cc  \<br>
> 07_template_class.cc<br>
> <br>
> for s : $src<br>
> {<br>
>   n = $name($s)<br>
>   ./: exe{$n".x"} : cxx{$n}<br>
> }<br>
<br>
You can use target-specific variables for that, for example:<br>
<br>
obj{01_enum}: cxx.coptions += -Wno-uninitialized<br>
<br>
You can also list several targets at once:<br>
<br>
obj{01_enum 02_scoped_enum}: cxx.coptions += -Wno-uninitialized<br>
<br>
If you want link options instead of compile, then you would use<br>
the executable target:<br>
<br>
exe{01_enum.x}:<br>
{<br>
  cxx.loptions += -static<br>
  cxx.libs += -lpthread<br>
}<br>
<br>
BTW, that .x extension for the executable target makes your project<br>
non-portable (since you've specified your own extension, build2 will<br>
do as it's told and use this extension even on Windows).<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font color="#999999">Alberto Sartori, Ph.D.</font></div><div><font color="#999999"><br></font></div><div style="font-size:12.8px"><font style="font-size:12.8px" color="#999999">Master in High Performance Computing,</font><font color="#999999"><br></font></div><div><font color="#999999"><a href="http://www.mhpc.it" target="_blank">www.mhpc.it</a></font></div><div><br></div><div><font color="#999999">SISSA, International School for Advanced Studies</font></div><div><span style="color:rgb(153,153,153);font-size:12.8px">via Bonomea 265, 34136 Trieste, Italy</span><br></div><div><font color="#999999">office: 723, phone: +39 040 3787 851 </font></div><div><font color="#999999">email:</font> <a href="mailto:alberto.sartori@sissa.it" target="_blank">alberto.sartori@sissa.it</a></div><div><br></div></div></div></div></div></div>