Per file compiler flags

General questions regarding the usage of CodeLite
teknogrebo
CodeLite Curious
Posts: 7
Joined: Mon Mar 09, 2015 2:31 pm
Genuine User: Yes
IDE Question: c++
Contact:

Per file compiler flags

Post by teknogrebo »

Hi there,

I am porting a project from osx to linux and unfortunately it requires one of our compilation units to be unoptimised when doing an otherwise optimised build. It was possible in XCode to set some compilation options on a per file basis, but I can't find a way of doing this in codelite, short of manually editing the make file that get's generated. Am I missing something in the IDE, or is it just not supported? If not, then are there plans to support it in the future?

Thanks,

Tom
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Per file compiler flags

Post by eranif »

This is not supported. TBH, the requirement for this never arise
Feel free to either submit a feature request or even better a PR (Pull Request)

Eran
Make sure you have read the HOW TO POST thread
Gibbon1
CodeLite Expert
Posts: 167
Joined: Fri Jul 22, 2011 5:32 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Per file compiler flags

Post by Gibbon1 »

I've had to this on occasion for debugging complicated switch statements. The -Os turns the code into something that is unpossible to comprehend. -O0 turns the code into something that won't fit in 64k of flash memory.

What I did was compile everything with -Os. Then change -Os to -O0 in the project settings, delete the particular object file and recompile. At least for now since the makefile isn't part of the dependency it'll just recompile and link the file you're debugging.

Probably doesn't help you if it's required for production.

Might be possible to do some magic, create a second project in the workspace with the alternative flags to just compile the offending file. At least that gives your the object file you need. Then maybe use a prepossessing script to copy it into the main project before compiling. Of course this is evil and ugly and might not work, but... no will work. There isn't any reason you can't compile the same file in two projects in codelite (most of my projects do that). The object files end up in different ./Debug ./Release directories. So you should be able to use a pre-post build command to copy the object file to the other projects ./Debug or ./Release directory. And then because it's current the file won't be compiled and the linker will happily link it into the executable.

I hope this make sense.
teknogrebo
CodeLite Curious
Posts: 7
Joined: Mon Mar 09, 2015 2:31 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Per file compiler flags

Post by teknogrebo »

Thanks for the replies. I;ll try Gibbon's approach - as I can probably pull all the non optimised bits into a separate project fairly easily. I can probably find out with a bit more browsing, but how do I make a feature request? I may have a poke around in the codebase myself in the near future, but I can't do it in work hours :)
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Per file compiler flags

Post by eranif »

Make sure you have read the HOW TO POST thread
Post Reply