Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: kirash4 on May 06, 2014, 10:19:43 pm

Title: Switching Build Target automatically?
Post by: kirash4 on May 06, 2014, 10:19:43 pm
Changing the Build Target appears to be a global action that affects every opened file. Is there a way to make it so it only affect the currently selected file (tab)? My reasoning behind this is this: I have a project that has several stand-alone console code files in it. Each one has its own Build Target defined so that I can just compile one file at a time, and not all of them. I can open a file, set its Build Target, and compile/run it. Open another file, set its Build Target, compile/run without needing to either close the previous one or the compiler trying to compile both at the same time. This works great, except I have to remember to change the Build Target each time I switch between opened files. If I can make the Build Target stick for each individual file, that would make it easier and I don't have to remember to change it each time. Is that possible?
Title: Re: Switching Build Target automatically?
Post by: stahta01 on May 06, 2014, 11:33:34 pm
I doubt if there is something like you asked for; but, I am NOT sure.

But, there is virtual targets in CB Project properties that might work in you situation.

Edit: In CB trunk there is build and clean a single file that also might be useful in your case.
But, I do NOT think it works by clicking on the file tabs; would be a nice feature.


Tim S.


Title: Re: Switching Build Target automatically?
Post by: kirash4 on May 06, 2014, 11:51:35 pm
Yeah, the more I thought about it, the more I came back to it not being possible ... right now.When you change the Build Target, it's a global change. Even when I switch to a different file (tab) and hit compile, it will still compile whatever the Build Target says it should, not the current (viewing) one.

Ah, it's fine, I'll just have to remember to do it. Generally that takes me at least two, usually more, times of hitting compile or rebuild to realize I forgot to change the Target Build ... kept wondering why the executable wasn't changing. :)
Title: Re: Switching Build Target automatically?
Post by: oBFusCATed on May 07, 2014, 01:13:12 am
This could probably be done with a script, which registers a menu entry and then you can set a keyboard shortcut for it.

You can look at this for examples and some documentation: http://wiki.codeblocks.org/index.php?title=Scripting_Code::Blocks