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

Dekeyser, Kris Kris.Dekeyser at lms.be
Wed Aug 11 13:24:51 EDT 2004


Thanks for your suggestions.

The files reside indeed in a read-only repository. Due to a reason unknown
to me, some files have .c others have a .cpp extension.

I'll either try to use the CONFIGURE_FILE option or find myself a "monkey"
to rename all those files in the repository ;-)

-Kris

> -----Original Message-----
> From: William A. Hoffman [mailto:billlist at nycap.rr.com]
> Sent: Wednesday, August 11, 2004 18:04
> To: Matt Valerio; Matt Valerio
> Cc: 'cmake at www.cmake.org'; Dekeyser, Kris
> Subject: Re: [Cmake] Forcing the use of C++ compiler for .c files
> 
> 
> Assuming the files are under some sort of revision control, 
> and they have
> to stay .c files, you could try using the CONFIGURE_FILE 
> command to copy them
> into .cxx files.
> 
> SET( SOURCES foo.c bar.c car.c)
> FOREACH(f ${SOURCES})
>   SET( CXX_SOURCES ${CXX_SOURCES} ${project_BINARY_DIR}/${f}xx)
>   CONFIGURE_FILE(${project_SOURCE_DIR}/$f 
> ${project_BINARY_DIR}/${f}xx COPYONLY)
> ENDFOREACH(f)
> 
> ADD_LIBRARY(foocpp ${CXX_SOURCES})
> 
> -Bill
> 
> 
> At 11:52 AM 8/11/2004, Matt Valerio wrote:
> >On second thought, this one is a little more readable:
> >
> >for i in `ls *.c`; do mv $i `echo $i | sed -e 's/\.c/\.cpp/'`; done
> >
> >
> >Matt Valerio wrote:
> >
> >>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
> >>_______________________________________________
> >>Cmake mailing list
> >>Cmake at www.cmake.org
> >>http://www.cmake.org/mailman/listinfo/cmake
> >_______________________________________________
> >Cmake mailing list
> >Cmake at www.cmake.org
> >http://www.cmake.org/mailman/listinfo/cmake
> 
+-+-+- 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.



More information about the Cmake mailing list