0

I have a couple of executables that I want to be able to use the same libraries. After building, I want the tree to look like this (simplified example):

Root
|--Prog1
|  |--src
|  |--obj
|  |--Prog1.gpr
|  |--Prog1.exe
|  |--libLib1.dll
|
|--Prog2
|  |--src
|  |--obj
|  |--Prog2.gpr
|  |--Prog2.exe
|  |--libLib1.dll
|
|--Lib1
   |--src
   |--obj
   |--Lib1.gpr

Normally, the simple thing to do is build a single copy of Lib1 and let each refer to that build with a relative reference to the location of the Lib1.gpr. But I want each executable to have its own dependencies included in its own directory.

If I put this in Lib1.gpr, it'll put the libLib1.dll in Prog1 only:

for Library_Dir use "../Prog1";

Which is not what I want, because then Prog2 won't be able to use it.

If I pass --relocate-build-tree=. at command line, it will move the whole build tree, which is also not what I want (it also complains about not being able to relocate deeper than object directory).

I tried just specifying Library_Dir for one of the two and doing a dumb file copy to copy it to the other before running that gpr, and this worked at first but is becoming unwieldy as the overall project gets more complex. I thought about trying to parameterize out the "for Library_Dir" but I'm not convinced that won't result in only one location being updated (after all, the source won't change between the two builds).

Why not just leave it in Lib1 and let each refer to the save copy? For binary distribution reasons--certain binaries are development support tools and not intended for distribution, while the others are each separate projects that should be distributed separately.

Is there a way gprbuild can be configured to produce a library and place it in two target directories?

5
  • 1
    have you tried using an external variable for lib1.gpr to select a different output directory for the library? that would let you run gprbuild twice (with different variable), and it would place liblib1.dll in each project.
    – Jere
    Commented Nov 9 at 16:43
  • ou can use a case statement that switches on the external varialbe to select a different for Library_Directory use clause in the gpr file.
    – Jere
    Commented Nov 9 at 16:48
  • Also consider GPRinstall.
    – trashgod
    Commented Nov 9 at 18:56
  • @Jere What I ended up doing was adding an external variable that it uses to pass the Prog1/Prog2 directory, which it uses as Library_Dir and appends /obj to to use as Object_Dir. This way the objects are updated for each build, and consequently the lib is rebuilt.
    – Devsman
    Commented Nov 13 at 2:56
  • What prevents you from placing all your executables in a single output directory? This is the most common and robust strategy. Commented Nov 28 at 2:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.