Target differentiation in .gpr files needing different “with” clauses

In several post in the past months there were examples how to differentiate in .gpr files between different targets. But how to do that differentiation if the gpr file needs different “with” clauses for different targets. E.g, for Windows an app that wants to use the console (CMD) in virtual terminal emulation mode, so that it can use xterm ESC sequences to manipulate cursor and color, needs to set that mode for the console. That app uses the Win32ada library to do so and the .gpr consequently needs a “with win32ada;” clause. However, on Linux Win32ada is of course not available and not needed for this purpose (the tty is almost always xterm compliant).

Is there a way to avoid the use of 2 different .gpr files ?

I solve it by having two different win32_ada.gpr in different directories.

the one for Linux/Unix is basically empty


project Win32ada is
  for Source_Dirs use ();
end Win32ada;

Then I have different ADA_PROJECT_PATH content on different OS.

Each os includes the dir of its version of win32_ada.gpr in the ADA_PROJECT_PATH

I had this exact problem few weeks/month ago.

Take a look at : termicap/termicap.gpr at bb43f2cf563ac29f45c91124eee859b76776764f · adarium-labs/termicap · GitHub

Maybe this can help you. It’s an alire projet, but it could be adapted to non alire project.

Thanks for both replies. This helps a lot. Simple and as elegant as possible