Page 1 of 1

Allow different compilers in a single project

Posted: Wed Mar 04, 2009 6:17 pm
by RJP Computing
Is there a way to invoke another compiler that is different then the entire project?

Here is my example. I have a C++ project, but I have one file in the project that is just C and CodeLite is compiling it with g++. This is not what I expected and was wondering if this can be changed to allow what compiler is used to be set on a file level.

Thanks.

Re: Allow different compilers in a single project

Posted: Thu Mar 05, 2009 3:05 pm
by eranif
Hi Ryan,

When u choose compiler for a project what it actually does it sets the $(CompilerName) variable to be the selected compiler.

Which is then replaced when creating the build rules for the makefile.

To override this behavior, i.e. to set a different compiler do this:
- assuming that you are using 'gnu g++' compiler
- open the compiler settings from: settings -> build settings -> compilers tab
- select the 'File Type' entry for the selected compiler
- replace the line for the 'C' extension from

Code: Select all

$(CompilerName) $(SourceSwitch) "$(FileFullPath)" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)
to

Code: Select all

gcc $(SourceSwitch) "$(FileFullPath)" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)
This will invoke the 'C' compiler for 'C' files.

Eran

Re: Allow different compilers in a single project

Posted: Thu Mar 05, 2009 8:53 pm
by RJP Computing
Perfect!

Do you think this could/should be set by default. There is hardly a time, that I can think of, to treat C files as C++.

Re: Allow different compilers in a single project

Posted: Thu Mar 05, 2009 10:14 pm
by eranif
By keeping $(CompilerName) you allow users to use the value set in the tools chain.

Eran

Re: Allow different compilers in a single project

Posted: Fri Mar 06, 2009 11:17 pm
by RJP Computing
eranif wrote:By keeping $(CompilerName) you allow users to use the value set in the tools chain.

Eran
I agree, but if you have a program that has both C and C++ source what are you suppose to do in a multi-user case. It seems hard for me to tell my team to set this setting each time they install CodeLite. To make this clearer, if I have an Open Source project that uses CodeLite then any number of developers will need to set this before being able to build that application.

Re: Allow different compilers in a single project

Posted: Sat Mar 07, 2009 11:06 am
by eranif
RJP Computing wrote:It seems hard for me to tell my team to set this setting each time they install CodeLite
Once installed and changed codelite will not modify your settings even after upgrade. The settings are saved into the user settings and those are not modified by the installer so it is really a one time mission.
You could add this line to the wiki of your OS project:
...
- install codelite
- change $(CompilerName) to gcc for 'C' extension
...
Eran