MantisBT - CMake
View Issue Details
0006440CMakeCMakepublic2008-02-25 05:172008-04-21 15:22
Fabien Lavignotte 
Bill Hoffman 
normalmajoralways
closedfixed 
 
CMake-2-6 
0006440: Exception handling cannot be removed with VS 2005
When the flags /EHsc and /GX are removed from CMAKE_CXX_FLAGS, the exception handling is not desactivated.
I found why, the VS generator writes in the vcproj : ExceptionHandling="FALSE"
This is not understood by VS 2005, the generator should writes : ExceptionHandling="0"
I have made the modification in line 1675 of cmLocalVisualStudio7Generator.cxx.
Replaces :
  this->FlagMap["ExceptionHandling"] = "FALSE";
by
  this->FlagMap["ExceptionHandling"] = "0";


It works with VS8 and VS71.
No tags attached.
zip CMakeBug.zip (2,962) 2008-04-17 12:19
https://public.kitware.com/Bug/file/1413/CMakeBug.zip
Issue History
2008-02-25 05:17Fabien LavignotteNew Issue
2008-02-25 16:35Alex NeundorfCategoryCCMake => CMake
2008-02-27 11:18Bill HoffmanStatusnew => assigned
2008-02-27 11:18Bill HoffmanAssigned To => Bill Hoffman
2008-04-15 16:29Matthew HungerfordNote Added: 0011351
2008-04-16 10:07Bill HoffmanAssigned ToBill Hoffman => David Cole
2008-04-16 11:22Gerhard GrimmNote Added: 0011396
2008-04-16 11:25Gerhard GrimmNote Edited: 0011396
2008-04-17 11:20David ColeStatusassigned => resolved
2008-04-17 11:20David ColeFixed in Version => CMake-2-6
2008-04-17 11:20David ColeResolutionopen => fixed
2008-04-17 11:20David ColeNote Added: 0011407
2008-04-17 11:21David ColeAssigned ToDavid Cole => Bill Hoffman
2008-04-17 11:21David ColeStatusresolved => feedback
2008-04-17 11:21David ColeResolutionfixed => reopened
2008-04-17 11:21David ColeNote Added: 0011408
2008-04-17 12:19Gerhard GrimmFile Added: CMakeBug.zip
2008-04-17 12:23Gerhard GrimmNote Added: 0011410
2008-04-18 10:57Matthew HungerfordNote Added: 0011429
2008-04-21 03:31Gerhard GrimmNote Added: 0011444
2008-04-21 03:32Gerhard GrimmNote Edited: 0011444
2008-04-21 07:59Bill HoffmanNote Added: 0011447
2008-04-21 08:10Gerhard GrimmNote Added: 0011448
2008-04-21 08:11Bill HoffmanNote Added: 0011449
2008-04-21 14:51Bill HoffmanNote Added: 0011461
2008-04-21 15:22Bill HoffmanStatusfeedback => closed
2008-04-21 15:22Bill HoffmanNote Added: 0011463
2008-04-21 15:22Bill HoffmanResolutionreopened => fixed

Notes
(0011351)
Matthew Hungerford   
2008-04-15 16:29   
This issue is plaguing our use of cmake with visual studio 2005. Even if we edit window_cl.cmake in share/modules/platform to edit cmake_cxx_flags_init to remove EHsc, and CMAKE_CXX_FLAGS (and CMAKE_CXX_FLAGS_DEBUG) don't contain any instance of GX or EHsc, the system still defaults to /EHsc. If we set /EHa, it correctly goes to /EHa. It looks as if when nothing is set, the VS8 generator fills exceptionhandling=false instead of exceptionhandling=0 (from the fix in cmLocalVisualStudio7Generator.cxx). Fix from http://www.cmake.org/Bug/view.php?id=6440 [^] (id=0006440) works. Effects 2.4.8 and 2.6.0RC8.
(0011396)
Gerhard Grimm   
2008-04-16 11:22   
(edited on: 2008-04-16 11:25)
A similar problem exists in the Visual Studio .NET 2003 generator of CMake 2.6.0-RC8. With /EHa specified as exception handling option instead of /EHsc, it generates ExceptionHandling="TRUE", where it should read ExceptionHandling="FALSE", since MSVC 7.1 always interprets "TRUE" as /EHsc.
CMake 2.5-20071119 was working correctly regarding this issue.

(0011407)
David Cole   
2008-04-17 11:20   
Fixed in CVS HEAD of CMake:
/cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v <-- Source/cmLocalVisualStudio7Generator.cxx
new revision: 1.223; previous revision: 1.222

Assigning to Bill for merging to the CMake-2-6 branch.

ggrimm, is there a "/GX" in your CMAKE_CXX_FLAGS? That would also turn on ExceptionHandling even if you specify "/EHa" instead of "/EHsc" -- you may need to remove a /GX as well... If that's not the case for you, could you please submit a small sample project that demonstrates your problem?
(0011408)
David Cole   
2008-04-17 11:21   
Bill, could you merge to CMake-2-6?
(0011410)
Gerhard Grimm   
2008-04-17 12:23   
Hi David, I've attached a minimal sample. When using the Visual Studio .NET 2003 generator (using config_mvs7.bat in the "build" directory), the compiler will issue warning D4025 (which can't be suppressed, since it's a "command line warning").
When using the NMake Makefile generator (using config_nmake.bat), no such warning will appear during the build.
(0011429)
Matthew Hungerford   
2008-04-18 10:57   
Tried the nightly build Window 2.7.20080418, and now exception handling works correctly (in that it is now disabled when we have no /GX /EHsc in the CMake_Flags). Looks great, hope it makes the 2.6 final release :) .
(0011444)
Gerhard Grimm   
2008-04-21 03:31   
(edited on: 2008-04-21 03:32)
Hi David, I've tested CMake 2.7-20080421, it still exhibits the problem when using Visual Studio .NET 2003.

(0011447)
Bill Hoffman   
2008-04-21 07:59   
ggrimm, can you please provide a very small example that shows the problem?
(0011448)
Gerhard Grimm   
2008-04-21 08:10   
Hi Bill, as stated in note 0011410 above, I've already attached a sample to this issue (CMakeBug.zip). I'm afraid it can't be done any simpler than with a single target and a single source file...
(0011449)
Bill Hoffman   
2008-04-21 08:11   
Never mind, I did not notice the example already attached. We will re-try with vs 2003 sounds like it works for vs2500.
(0011461)
Bill Hoffman   
2008-04-21 14:51   
OK, I found it...

This was a much bigger bug than what I thought it was...

Your flags in the cache were being ignored altogether! So, it was actually correctly turning exceptions on, because it was getting the /GX flag. I have checked in a fix that should solve the problem.
(0011463)
Bill Hoffman   
2008-04-21 15:22   
This should be fixed now.