[CMake] Mixing c and c++ with MinGW

Werner Smekal smekal at iap.tuwien.ac.at
Fri Dec 29 11:09:57 EST 2006


Hi Bill,

thanks a lot, that is what I needed.

Regards,
Werner

Bill Hoffman wrote:
> Werner Smekal wrote:
>> Hi,
>>
>> it is normally possible to mix c and c++ in a project with the GNU 
>> compiler. Normally you compile c files with gcc and c++ files with g++ 
>> and than link all together with g++.
>>
>> In our project (plplot) we allow c++ code into the mainly c code 
>> library under some circumstances - everything works fine, ar links 
>> everything together.
>>
>> We have now c and c++ examples which use this mixed library, but the c 
>> examples won't compile with gcc obviously since a lot of c++ stuff is 
>> unreferenced.
>>
>> I tried to set CC to g++, but cmake didn't allow this.
>>
>> Is there any solution for this problem?
> See :
> 
> SET_TARGET_PROPERTIES(target1 target2 ...
>                        PROPERTIES prop1 value1
>                        prop2 value2 ...)
> ....
> 
> The LINKER_LANGUAGE property is used to change the tool used to link an 
> executable or shared library. The default is set the language to match 
> the files in the library. CXX and C are common values for this property.
> 
> You can use that property to link with c++ but compile with c.
> 
> -Bill
> 


-- 
Dipl. Ing. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria

email: smekal at iap.tuwien.ac.at
web:   http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office)
        +43-(0)1-58801-13469 (laboratory)
fax:   +43-(0)1-58801-13499



More information about the CMake mailing list