Author Topic: Build all targets, or target interdependencies  (Read 4223 times)

Offline ta0

  • Multiple posting newcomer
  • *
  • Posts: 16
Build all targets, or target interdependencies
« on: July 16, 2016, 06:02:57 pm »
I have set up a large project with many Build Targets used for building libraries (.a files) that are then supposed to be linked together with some other files into the final executable, which is also a Build Target.

Right now I build this by selecting each Target in the Build > Select target menu, and then pressing Build > Rebuild.

How can I automate this? I have read threads about scripting, but there were few examples and I didn't understand how to do it (I understand squirrel, but it is still difficult to understand how to script C::B).

I have also read about the Target Inter-dependencies or Inter-target dependencies feature of C::B, but I didn't understand how to configure it at all.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Build all targets, or target interdependencies
« Reply #1 on: July 16, 2016, 06:16:51 pm »
I would try using a Virtual Target called "All"; just like the CB Core project does it.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Build all targets, or target interdependencies
« Reply #2 on: July 16, 2016, 08:21:12 pm »
Use a virtual target then the targets that are part of it will be compiled from top to bottom. So if you reorder them in the project you can manage the dependencies. To get real dependencies you have to use separate projects. One for each library or executable and make sure that you use the same target names in each project.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ta0

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Build all targets, or target interdependencies
« Reply #3 on: July 19, 2016, 02:43:07 am »
Thanks, this worked great.

Offline fubo

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: Build all targets, or target interdependencies
« Reply #4 on: July 27, 2018, 11:27:49 am »
The trick is ok, but it does not work if a target depends on pre-build steps. In my case, the via file is generated from C::B variables (different for each target) using the pre-build step, but this step is executed only for first target.
Tested on C::B 17.12.

As per http://forums.codeblocks.org/index.php?topic=15572.0, I should specify the pre/post-build steps for EACH target, but as they are the same for all targets (they changes as I am using variables), it is more efficient to have it in project pane, instead of target pane.
« Last Edit: July 27, 2018, 11:36:47 am by fubo »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Build all targets, or target interdependencies
« Reply #5 on: July 27, 2018, 12:19:47 pm »
The trick is ok, but it does not work if a target depends on pre-build steps. In my case, the via file is generated from C::B variables (different for each target) using the pre-build step, but this step is executed only for first target.
Tested on C::B 17.12.

As per http://forums.codeblocks.org/index.php?topic=15572.0, I should specify the pre/post-build steps for EACH target, but as they are the same for all targets (they changes as I am using variables), it is more efficient to have it in project pane, instead of target pane.

Without seeing the pre/post commands I see no way to help you.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org