MantisBT - CMake
View Issue Details
0014511CMakeCMakepublic2013-10-25 08:552013-10-29 10:42
Nils Gladitz 
Nils Gladitz 
normalcrashalways
closedfixed 
CMake 2.8.12 
CMake 3.0 
0014511: Makefile generators segfault when custom target sources have compile definitions
The Makefile generators crash when sources listed in custom targets have COMPILE_DEFINITIONS.
Obviously these don't make much sense either but it should preferably not crash.

I could reproduce this issue with the NMake and Unix Makefiles generators.
Ninja and Visual Studio generators have no problem in this case.
CMakeLists.txt
 cmake_minimum_required(VERSION 2.8.11)
 add_custom_target(mytarget SOURCES foo.cpp)
 set_source_files_properties(foo.cpp PROPERTIES COMPILE_DEFINITIONS "FOO")

foo.cpp
 any random content
Relevant stack trace:

3 cmMakefileTargetGenerator::WriteObjectBuildFile cmMakefileTargetGenerator.cxx 569 0x8906f0
4 cmMakefileTargetGenerator::WriteObjectRuleFiles cmMakefileTargetGenerator.cxx 467 0x88ff12
5 cmMakefileTargetGenerator::WriteTargetBuildRules cmMakefileTargetGenerator.cxx 190 0x88e3db
6 cmMakefileUtilityTargetGenerator::WriteRuleFiles cmMakefileUtilityTargetGenerator.cxx 62 0x8a0bc2
7 cmLocalUnixMakefileGenerator3::Generate cmLocalUnixMakefileGenerator3.cxx 157 0x877050
8 cmGlobalGenerator::Generate cmGlobalGenerator.cxx 1128 0x845d30
9 cmGlobalUnixMakefileGenerator3::Generate cmGlobalUnixMakefileGenerator3.cxx 105 0x85f97d
10 cmake::Generate cmake.cxx 1845 0x73df64
11 cmake::Run cmake.cxx 1825 0x73ddb6
12 do_cmake cmakemain.cxx 313 0x65cb7d
13 main cmakemain.cxx 177 0x65c315

Specifically *this->FlagFileStream faults because FlagFileStream is 0.
No tags attached.
Issue History
2013-10-25 08:55Nils GladitzNew Issue
2013-10-25 09:04Brad KingAssigned To => Nils Gladitz
2013-10-25 09:04Brad KingStatusnew => assigned
2013-10-25 09:05Brad KingNote Added: 0034239
2013-10-25 09:06Brad KingNote Added: 0034240
2013-10-25 09:09Nils GladitzNote Added: 0034241
2013-10-29 10:42Nils GladitzNote Added: 0034284
2013-10-29 10:42Nils GladitzStatusassigned => resolved
2013-10-29 10:42Nils GladitzFixed in Version => CMake 3.0
2013-10-29 10:42Nils GladitzResolutionopen => fixed
2013-10-29 10:42Nils GladitzStatusresolved => closed

Notes
(0034239)
Brad King   
2013-10-25 09:05   
Nils, as a developer please feel free to fix things like this yourself :)
(0034240)
Brad King   
2013-10-25 09:06   
Also please include a test case for this. It can be added to one of the existing tests that exercises these features.
(0034241)
Nils Gladitz   
2013-10-25 09:09   
Thanks! Will try :p
(0034284)
Nils Gladitz   
2013-10-29 10:42   
fixed by http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f80eaf98175f9a60089f8146d4c9281e72d72f4;hp=afe6adfabaabab8808ff441172319cf357b30886 [^]