Map LANGUAGE source file property to compiler language flag
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
CMake seems to assumes that gcc
calls the C compiler while g++
calls the C++ compiler. Well this is not entirely true:
$ cat foo.C
int bar() { return 42; }
$ gcc -o foo.o -c foo.C
$ nm foo.o
0000000000000000 T _Z3barv
U __gxx_personality_v0
Compared to:
$ gcc -x c -o foo.o -c foo.C
$ nm foo.o
0000000000000000 T bar
Which means that the following CMake code is not working (at least on debian+gcc compiler because of implicit gcc behavior treating capital C file extension):
project(t)
add_library(foo foo.C)
set_source_files_properties(foo.C PROPERTIES LANGUAGE C)
set_target_properties(foo PROPERTIES LINKER_LANGUAGE C)
Edited by Brad King