[Cmake] Forcing the use of C++ compiler for .c files

Matt Valerio m-valerio at onu.edu
Wed Aug 11 11:47:56 EDT 2004


I know it's a kludge, but you could just rename all of your .c files to 
.cpp (assuming you are using a bash shell):

for i in `ls *.c`; do mv $i `echo $i | sed -e 's/\(.*\)\.c/\1\.cpp/'`; done

-Matt


Dekeyser, Kris wrote:

> Hi,
> 
> We currently have some legacy C++ code. Most of these files use extension
> .c, but they really contain C++ code. CMake however automatically selects
> the CMAKE_C_COMPILER to compile the files, which causes an error. Forcing
> CMake to use the C++ compiler doesn't work either, because CMake detects
> that it is not a C Compiler, but C++ compiler.
> 
> The only solution I found is to hack the
> ${CMAKE_ROOT}/Modules/CMakeTestCCompiler.cmake and disable the C++ check.
> 
> However, we do need to compile another project with the C Compiler and not
> with the C++ compiler, so we end up to hack/unhack the test file all the
> time.
> 
> Is there another - better - way to force the usuage of the C++ compiler in
> CMake for certain files? If not, could it be added?
> 
> Best regards,
> Kris
> +-+-+- Email Confidentiality Footer +-+-+- 
> Privileged/Confidential Information may be contained in this message. If you
> are not the addressee indicated in this message (or responsible for delivery
> of the message to such person), you may not print, retain, copy nor
> disseminate this message or any part of it to anyone and you should notify
> the sender by reply email and destroy this message. Neglecting this clause
> could be a breach of confidence. Please advise immediately if you or your
> employer does not consent to Internet email for messages of this kind.
> Opinions, conclusions and other information in this message that are not
> related to the official business of my firm shall be understood as neither
> given nor endorsed by it.
> 
> _______________________________________________
> Cmake mailing list
> Cmake at www.cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 


More information about the Cmake mailing list