News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

default flags for debug/release target

Started by exchg, April 03, 2017, 09:30:25 PM

Previous topic - Next topic

exchg

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.

oBFusCATed

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!]

BlueHazzard

Quote from: oBFusCATed on April 03, 2017, 10:47:37 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"

exchg

#3
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")); ?

oBFusCATed

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!]

exchg

Quote from: oBFusCATed on April 04, 2017, 09:42:57 AM
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:
function SetupTarget(target,is_debug)
{
    ...
    if (is_debug)
    {
        ...
    }
    else
    {
        ...
        target.AddCompilerOption(_T("-O3")); // <-- Set -o3
    }

    // all done!
    return true;
}

Miguel Gimenez

Look at share\CodeBlocks\templates\wizard\common_functions.script, line 173 (or 201, depending on the compiler).

exchg

#7
Quote from: Miguel Gimenez 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).
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.

oBFusCATed

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!]