[CMake] Using C++ compilers for C source files?

Alexandre.Feblot at thomsonreuters.com Alexandre.Feblot at thomsonreuters.com
Tue Apr 7 07:33:16 EDT 2009


By the way, I filled a (minor) bug for that:

http://public.kitware.com/Bug/view.php?id=8851



Regards,
Alexandre 
 
-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Nadir SOUALEM
Sent: Tuesday, 07 April 2009 13:01
To: Robert Blake; cmake at cmake.org
Subject: Re: [CMake] Using C++ compilers for C source files?

Robert Blake wrote:
> Aha!  Hadn't read this.  After following everyone's advice, and using 
> the following section in my CMakeLists.txt file:
>
> PROJECT(Blah)
> file(GLOB_RECURSE C_FILES ${CMAKE_CURRENT_SOURCE_DIR} *.c)
> set_source_files_properties(${C_FILES} PROPERTIES LANGUAGE CXX)
>
> ... I get the following make output after generating my makefiles:
> make VERBOSE=1
>
> [  1%] Building C object PrM/src/CMakeFiles/param.dir/build_mex.c.o
> cd /Users/rblake/sand/carp/m/seq/PrM/src && /usr/bin/gcc    -o 
> CMakeFiles/param.dir/build_mex.c.o   -c 
> /Users/rblake/sand/carp/m/PrM/src/build_mex.c
> /opt/local/bin/cmake -E cmake_progress_report 
> /Users/rblake/sand/carp/m/seq/CMakeFiles 7
>
> In other words, setting the language to CXX for this source code file 
> doesn't seem to have any effect.  Any other ideas?  I'm using cmake 
> 2.6-patch 2, could that be the source of the problem?
>
> Rob
>
> On Apr 3, 2009, at 10:54 AM, Alexandre Feblot wrote:
>
>> Hi,
>>
>> Look at that thread...
>> http://www.cmake.org/pipermail/cmake/2009-March/028352.html
>>
>>
>> Regards,
>> Alexandre
>>
>> -----Original Message-----
>> From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf
>> Of Robert Blake
>> Sent: Friday, 03 April 2009 16:46
>> To: cmake at cmake.org
>> Subject: [CMake] Using C++ compilers for C source files?
>>
>> I'm converting a large mixed C++/C cmake application to C++.  The
>> project has many ".c" files that I would like to compile with the C++
>> compiler instead of the C compiler.  Does anyone know the proper way
>> to do this in CMake?
>>
>> Things I've tried:
>> 1.) Changing CMAKE_C_COMPILER myself: Usually CMake doesn't let you
>> change CMAKE_C_COMPILER, but there are ways around that.  This way
>> feels like a hack.  The output while compiling still says "Compiling
>> C".  In addition, forcing CMAKE_*_COMPILER to change makes it very
>> difficult to run plane cmake on Unix machines where curses is not
>> installed.
>>
>> 2.) Tell CMake that ".c" files are in the CXX language:  I've tried
>> PROJECT(Blah CXX)
>> list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS c)
>>
>> When I run CMake on my project with these changes, I get errors like:
>>
>> CMake Error: Cannot determine link language for target "foobar"
>>
>> ...for all my targets that depend only on .c files.
>>
>> Help!
>> Rob
>>
>>
>> This email was sent to you by Thomson Reuters, the global news and 
>> information company.
>> Any views expressed in this message are those of the individual 
>> sender, except where the sender specifically states them to be the 
>> views of Thomson Reuters.
>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
Try to remove your CMakeCache ...

-- 
Nadir SOUALEM
Ingénieur INRIA - Équipe SAGE

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


This email was sent to you by Thomson Reuters, the global news and information company.
Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.




More information about the CMake mailing list