[CMake] VS.NEt generator flag missing

Darko Miletic darko at uvcms.com
Mon Jan 30 14:47:16 EST 2006


Jorgen Bodde wrote:
> Hi all,
> 
> Since a while I am missing this flag from the VS.NET generator: /EHsc
> 
> Every app I compile crashes unless i add it, I nevber had problems with
> my apps with older versions of CMakeSetup (using 2.2 patch 2). Is this
> flag removed for a reason? Or is this already fixed in newer versions?
> 
> The flag is needed virtually always, it is generating code related to
> the unwind stack for exception handling.
> 
> If this flag is not going to be added, how can I add this to my VS.NET
> generated projects with the ADD_DEFINITIONS ?

First must go ADD_EXECUTABLE or ADD_LIBRARY and after that

ADD_DEFINITIONS("/EHsc")

Or even something more advanced like this

IF (CMAKE_BUILD_TYPE MATCHES Release)
  IF (CMAKE_USING_VC_FREE_TOOLS)
    SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2")
    SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /TC")
  ENDIF (CMAKE_USING_VC_FREE_TOOLS)
  SET (DEFINES ${DEFINES} "-DNDEBUG /FD /EHsc /GS /GR /W3 /nologo /c /Wp64")
ENDIF (CMAKE_BUILD_TYPE MATCHES Release)

IF (CMAKE_BUILD_TYPE MATCHES Debug)
  IF (CMAKE_USING_VC_FREE_TOOLS)
    SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MDd /Zi /Od /RTC1")
    SET (CMAKE_C_FLAGS_DEBUG_INIT "/MDd /Zi /Od /RTC1 /TC")
  ENDIF (CMAKE_USING_VC_FREE_TOOLS)
  SET (DEFINES ${DEFINES} "-D_DEBUG /Gm /EHsc /RTC1 /GR /W3 /nologo /c
/Wp64")
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)

ADD_DEFINITIONS( -D_MBCS ${DEFINES})

Of course all of this hoes after ADD_EXECUTABLE too




More information about the CMake mailing list