[cmake-developers] generator expression for path slash conversion

Kislinskiy, Stefan s.kislinskiy at Dkfz-Heidelberg.de
Thu Sep 24 09:05:40 EDT 2015


I factored out the code from cmOutputConverter::ConvertToOutputFormat() into another helper method called ConvertDirectorySeparatorsForShell(), changed the SHELL_PATH genex to accept only absolute paths, and changed its documentation accordingly. I also added a BadSHELL_PATH test to the RunCMake/GeneratorExpression tests, that use the SHELL_PATH genex with an empty parameter as well as a relative path. I also fixed the TEST/CTEST typo you discovered yesterday.

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com] 
Sent: Mittwoch, 23. September 2015 16:57
To: Kislinskiy, Stefan
Cc: cmake-developers at cmake.org
Subject: Re: [cmake-developers] generator expression for path slash conversion

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: shell_path_genex_v4.patch
Type: application/octet-stream
Size: 14515 bytes
Desc: shell_path_genex_v4.patch
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150924/fd3011e7/attachment-0001.obj>


More information about the cmake-developers mailing list