[CMake] *.c compiled with C compiler after clearing CMAKE_C_SOURCE_FILE_EXTENSIONS

Michael Wild themiwi at gmail.com
Tue Oct 12 09:33:32 EDT 2010


On 12. Oct, 2010, at 15:26 , Jed Brown wrote:

> I realize this may look silly, but after
> 
>  list (REMOVE_ITEM CMAKE_C_SOURCE_FILE_EXTENSIONS c)
>  list (APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS c)
> 
> source files matching *.c are still compiled with the C compiler (not C++).
> Is there a way to get *.c compiled with the C++ compiler?
> 
> (cmake-2.8.2)
> 
> Jed

This should do the trick:

set(SRCS src1.c src2.c src3.c)
set_source_files_properties(${SRCS} PROPERTIES LANGUAGE CXX)
add_executable(strange_beast ${SRCS})

Michael

--
There is always a well-known solution to every human problem -- neat, plausible, and wrong.
H. L. Mencken

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101012/4634d39d/attachment.pgp>


More information about the CMake mailing list