[CMake] Ensuring spaces in CFLAGS reach Visual Studio project files
Martin O'Brien
martin.matthew.obrien at gmail.com
Sun Dec 19 15:17:07 EST 2010
>Alternatively, consider using a configured header file that gets included
in the places that need those definitions. They're much easier to deal with
than trying to wrap your head around escapings and multiple platforms and
compilers.
This is what I do. Much, much easier than dealing with 'nested' escape
sequences.
mm
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of
David Cole
Sent: Friday, December 17, 2010 5:59 PM
To: Clifford Yapp
Cc: CMake List
Subject: Re: [CMake] Ensuring spaces in CFLAGS reach Visual Studio project
files
Have you tried add_definitions for -D flags?
I'm not sure what's required for getting spaces-in-the-value across, but I
think it's possible.
Maybe somebody who's done it more recently than me can speak up here?
Alternatively, consider using a configured header file that gets included in
the places that need those definitions. They're much easier to deal with
than trying to wrap your head around escapings and multiple platforms and
compilers.
HTH,
David
On Fri, Dec 17, 2010 at 5:54 PM, Clifford Yapp <cliffyapp at gmail.com> wrote:
I have a situation where I need to pass strings with spaces in them as
definitions in CFLAGS, e.g.
SET(CMAKE_C_CFLAGS -DINPUT_STRING=\\\"first\\ second\\\"")
This is NOT working for Visual Studio, which is apparently quite picky
about this - it apparently needs to end up with something like:
INPUT_STRING="\"first second\""
I can duplicate the "\" quote structure part (VERY ugly -
\\\"\\\\\\\") but I'm getting stopped cold by the space between first
and second. I've tried quoting variations, and while I can preserve
the space as far as CMake's definition in the cache, the results that
get written into the Visual Studio file ALWAYS seem to break on the
space, quoted or not. e.g. I get:
INPUT_STRING="\"first
or
INPUT_STRING="\"first\
etc.
For variable definitions I might be able to live with not using a
space, but some of the arguments I have to pass in are pathnames with
spaces. That's user controlled - I HAVE to be able to handle it, or
in the worst case impose the limitation of no spaces in pathnames on
Windows (ouch).
Can someone tell me how to quote a space such that it ends up included
in the preprocessor definition line in a Visual Studio project?
Cheers,
CY
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101219/5302d064/attachment-0001.htm>
More information about the CMake
mailing list