Author Topic: Switching Build Target automatically?  (Read 5744 times)

Offline kirash4

  • Multiple posting newcomer
  • *
  • Posts: 42
Switching Build Target automatically?
« 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?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7789
    • My Best Post
Re: Switching Build Target automatically?
« Reply #1 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.


« Last Edit: May 06, 2014, 11:35:08 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline kirash4

  • Multiple posting newcomer
  • *
  • Posts: 42
Re: Switching Build Target automatically?
« Reply #2 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. :)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Switching Build Target automatically?
« Reply #3 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
(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!]