MantisBT - CMake
View Issue Details
0014516CMake(No Category)public2013-10-28 10:312016-06-10 14:31
Mathieu Malaterre 
Kitware Robot 
normalfeaturehave not tried
closedmoved 
 
 
0014516: Map LANGUAGE source file property to compiler language flag
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):

$ cat CMakeLists.txt
project(t)
add_library(foo foo.C)
set_source_files_properties(foo.C PROPERTIES LANGUAGE C)
set_target_properties(foo PROPERTIES LINKER_LANGUAGE C)
No tags attached.
related to 0015438closed Kitware Robot project([...] C) for Objective-C 
patch bug728108.patch (360) 2015-02-05 06:45
https://public.kitware.com/Bug/file/5375/bug728108.patch
Issue History
2013-10-28 10:31Mathieu MalaterreNew Issue
2015-02-05 06:45Mathieu MalaterreFile Added: bug728108.patch
2015-02-05 06:45Mathieu MalaterreNote Added: 0037919
2015-03-25 10:52Brad KingSeverityminor => feature
2015-03-25 10:52Brad KingSummaryset_source_files_properties( ... C) not working => Map LANGUAGE source file property to compiler language flag
2015-03-25 10:53Brad KingNote Added: 0038290
2015-03-25 10:55Brad KingNote Added: 0038291
2015-03-25 10:58Mathieu MalaterreNote Added: 0038292
2015-03-25 11:00Brad KingRelationship addedrelated to 0015438
2016-06-10 14:29Kitware RobotNote Added: 0042404
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0037919)
Mathieu Malaterre   
2015-02-05 06:45   
adding patch, thanks for consideration.
(0038290)
Brad King   
2015-03-25 10:53   
A similar issue has been raised here:

 nonstandard C++ source filename extension
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.user/52028 [^]
(0038291)
Brad King   
2015-03-25 10:55   
Re 0014516:0037919: We should not depend on the user to keep the "-x c" flag in the cache entry. Instead the CMAKE_<LANG>_COMPILE_OBJECT rule variable should be updated to include the flag as needed for each compiler. Supporting this in general will require research to collect the proper flag for each compiler.
(0038292)
Mathieu Malaterre   
2015-03-25 10:58   
Just for later reference, fixing this bug will affect bug 0015438.

Indeed cmake rely on the gcc compiler to have correct behavior for obj-c and obj-c++ (proper linking). In other word, the patch suggest in 0015438:

add_executable(foo foo.c foo.m)
set_source_files_properties(foo.m PROPERTIES LANGUAGE C)

will not work once 0014516 is fixed IMHO.
(0042404)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.