[cmake-developers] generator expression for path slash conversion

David Cole DLRdave at aol.com
Thu Sep 24 09:52:07 EDT 2015


Unfortunately, "pushd" is an inappropriate command to use when the
argument is quoted. It works just fine with "/" characters if the
argument is quoted...

For example:

    C:\Users\davidcole>pushd C:\Windows\System32

    C:\Windows\System32>pushd C:/dev
    The syntax of the command is incorrect.

    C:\Windows\System32>pushd "C:/dev"

    C:\dev>

It would be better to use a test command that **actually** fails when
a "/" path is a quoted entity....


HTH,
David C.




On Thu, Sep 24, 2015 at 9:05 AM, Kislinskiy, Stefan
<s.kislinskiy at dkfz-heidelberg.de> wrote:
> 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
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake-developers


More information about the cmake-developers mailing list