[cmake-developers] generator expression for path slash conversion

Brad King brad.king at kitware.com
Wed Sep 23 10:57:07 EDT 2015


On 09/23/2015 10:45 AM, Kislinskiy, Stefan wrote:
> I see. I would suggest that I add another output flag to
> cmOutputConverter like SHELL_NO_ESCAPE then. If this flag is passed
> to ConvertToOutputFormat() instead of SHELL, the call of
> EscapeForShell() will be circumvented. This way there wouldn't be
> code duplication and we would still cover the MSYS case
> (drive letter conversion).

The conversion code in question is about 10 lines and could be
factored out into another helper method.  Then the genex impl
could just use the helper directly.

> Isn't it possible to specify parameters for generator expressions?

Yes.

> How about something like $<SHELL_PATH:c:/this/is/an/example,ESCAPE>?

Neat idea.  However, for now I'd rather not try to predict the
use cases for which such parameters will be needed.  Instead
we should just make sure the interface leaves room for future
extension.  Since "," is allowed in paths we cannot simply
disallow it or blindly use it as a separator.  Therefore we
should have the actual path always be the last parameter.

For now I think you can just require (with an error) that the
value given to SHELL_PATH as input must be an absolute path
(cmSystemTools::FileIsFullPath).  Then in the future
we could recognize things like $<SHELL_PATH:ESCAPE,c:/path>
without ambiguity.  Please include test cases for errors on
relative paths (see Tests/RunCMake/GeneratorExpression).

Thanks,
-Brad



More information about the cmake-developers mailing list