[CMake] visual studio compiler option not being set

Brandon Van Every bvanevery at gmail.com
Fri Jun 8 21:03:22 EDT 2007


On 6/8/07, Jon W <knowdat at gmail.com> wrote:
> I'm just beginning to learn cmake, and am trying to add the "/EHac-"
> option to the additional command line options.
>
> I'm setting the CMAKE_C_FLAGS as follows:
> ---------------------------------------------------------
> SET (MY_C_FLAGS "/EHac-")
> MARK_AS_ADVANCED (MY_C_FLAGS)
>
> SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_C_FLAGS}" CACHE STRING
> "Resetting the default compiler options." FORCE)
> ---------------------------------------------------------
>
> The CMakeCache.txt has the proper options:
> CMAKE_C_FLAGS:STRING= /DWIN32 /D_WINDOWS /W3 /Zm1000 /EHac-
>
> However, the generated vcproj file looks as follows (note that EHac-
> is just c-):
> AdditionalOptions=" /DWIN32 /D_WINDOWS  /Zm1000 c-    /D NDEBUG
>
> Any idea what I'm doing wrong, or is this possibly a bug?

Some kind of problem with the double quotes and things getting passed
as semicolon separated lists.  Perhaps it's getting expanded as
"buncha_flags "/Ehac-"", which is 2 strings and not anything like
you'd expect.  You have to be very careful when using quotes, escapes,
and double escapes in CMake.  I'd like to say my Chicken Scheme build
has examples on pitfalls, but I recall doing my darndest to eliminate
this kind of stuff wherever possible, because it is so dangerous.

This kind of problem is what I mean by "untyped shells."  It's really
stone age having quote and backspace problems blow up in our faces.
It's not a CMake problem particularly, just one of my gripes about
computers in general.


Cheers,
Brandon Van Every


More information about the CMake mailing list