Author Topic: default flags for debug/release target  (Read 5615 times)

Offline exchg

  • Multiple posting newcomer
  • *
  • Posts: 11
default flags for debug/release target
« on: April 03, 2017, 09:30:25 pm »
Hi to all,

Is it possible to redefine default compiler flags for debug and release build target ?
I want that every new project release target by default have -O3 flag for example.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: default flags for debug/release target
« Reply #1 on: April 03, 2017, 10:47:37 pm »
Yes, change the template script you're using to create your projects.
(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 BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: default flags for debug/release target
« Reply #2 on: April 03, 2017, 10:53:10 pm »
Yes, change the template script you're using to create your projects.
This can be done by right click on the project type in the "new project wizard" and then hit "edit this script"

Offline exchg

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: default flags for debug/release target
« Reply #3 on: April 03, 2017, 11:01:53 pm »
ah, got it!
is there any script documentation ?

update:

i just try to use target.AddCompilerOption(_T("-O3")); and it works but it's toggle both flags -o2 and -o3 and also send both to compiler.
is it some bug or i just need also to add something like target.RemoveCompilerOption(_T("-O2")); ?
« Last Edit: April 03, 2017, 11:13:42 pm by exchg »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: default flags for debug/release target
« Reply #4 on: April 04, 2017, 09:42:57 am »
Have you inspected if the script adds the -O2 explicitly?
(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 exchg

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: default flags for debug/release target
« Reply #5 on: April 04, 2017, 12:45:05 pm »
Have you inspected if the script adds the -O2 explicitly?
No there is no explicit flags modification, you can check yourself, this is default console application script.

the place which was modified:
Code
function SetupTarget(target,is_debug)
{
    ...
    if (is_debug)
    {
        ...
    }
    else
    {
        ...
        target.AddCompilerOption(_T("-O3")); // <-- Set -o3
    }

    // all done!
    return true;
}

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1644
Re: default flags for debug/release target
« Reply #6 on: April 04, 2017, 01:25:10 pm »
Look at share\CodeBlocks\templates\wizard\common_functions.script, line 173 (or 201, depending on the compiler).

Offline exchg

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: default flags for debug/release target
« Reply #7 on: April 04, 2017, 01:48:47 pm »
Look at share\CodeBlocks\templates\wizard\common_functions.script, line 173 (or 201, depending on the compiler).
Yep, now it is works fine, thanks a lot.

But i am not sure that this is good from architectural point of view, because my changes will be reset after first update.
« Last Edit: April 04, 2017, 02:10:44 pm by exchg »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: default flags for debug/release target
« Reply #8 on: April 05, 2017, 12:06:31 am »
You can place your own templates in your user settings folder. These won't be overridden with the next update.
(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!]