MantisBT - CMake
View Issue Details
0013702CMakeCMakepublic2012-11-19 00:072013-04-17 08:54
Nick Hutchinson 
Brad King 
normalcrashalways
closedfixed 
LinuxUbuntu12.10
CMake 2.8.10.1 
CMake 2.8.10.2CMake 2.8.10.2 
0013702: CMake crashes when reconfiguring build
Attached is a reduced test case that reliably crashes CMake.
1. Execute the following commands:
~~~~~
mkdir build && cd build
cmake ../path/to/source/folder -DCMAKE_C_COMPILER=cc -DFOOBAR=0
~~~~~
CMake should abort the configure with the message: "CMake Error at CMakeLists.txt:8 (message): FOOBAR was not set"

2. Execute the following command:
cmake ../path/to/source/folder -DCMAKE_C_COMPILER=cc -DFOOBAR=1

Expected behaviour:
CMake reconfigures the project.

Actual behaviour:
CMake displays the following message, then crashes:
~~~~~~
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= cc

CMake Error at CMakeLists.txt:3 (add_library):
  add_library cannot create imported target "testlib" because another target
  with the same name already exists.

[1] 20462 segmentation fault (core dumped) cmake ../ -DCMAKE_C_COMPILER=cc -DFOOBAR=1
Core dump is included in the attachment.
No tags attached.
zip CMake Crash.zip (158,517) 2012-11-19 00:07
https://public.kitware.com/Bug/file/4571/CMake%20Crash.zip
Issue History
2012-11-19 00:07Nick HutchinsonNew Issue
2012-11-19 00:07Nick HutchinsonFile Added: CMake Crash.zip
2012-11-19 08:30Brad KingAssigned To => Brad King
2012-11-19 08:30Brad KingStatusnew => assigned
2012-11-19 08:43Brad KingNote Added: 0031607
2012-11-19 08:43Brad KingFixed in Version => CMake 2.8.11
2012-11-19 08:43Brad KingTarget Version => CMake 2.8.11
2012-11-19 08:43Brad KingStatusassigned => resolved
2012-11-19 08:43Brad KingResolutionopen => fixed
2012-11-27 15:22David ColeFixed in VersionCMake 2.8.11 => CMake 2.8.10.2
2012-11-27 15:22David ColeTarget VersionCMake 2.8.11 => CMake 2.8.10.2
2013-04-17 08:54Robert MaynardNote Added: 0032884
2013-04-17 08:54Robert MaynardStatusresolved => closed

Notes
(0031607)
Brad King   
2012-11-19 08:43   
Fixed:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5ff75873 [^]

The issue has existed since CMake 2.8.8. The fix patch should apply to that version of CMake through 2.8.10.1.

Work around the issue by always specifying the compiler via the "CC" environment variable or always passing a full path to the compiler to CMAKE_C_COMPILER.
(0032884)
Robert Maynard   
2013-04-17 08:54   
Closing resolved issues that have not been updated in more than 4 months.