Re: [cmake-developers] generator expression for path slash conversion

2015-09-25 Thread Brad King
On 09/24/2015 11:08 AM, Kislinskiy, Stefan wrote:
> Regarding the nice bracket tweak: Maybe the minimum required
> version in Tests/GeneratorExpression/CMakeLists.txt should be
> updated to 3.0.0 then?

The test also covers policy CMP0044 behavior and so cannot require
a version new enough to set that policy.  It doesn't really matter
because we never run the test suite except with the current version
of CMake anyway.

After nightly testing of the main change I added this fixup:

 fixup! Genex: Add a SHELL_PATH expression
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d1912e51

which I'll squash in to the final change before merging to 'master'.
The problem is that on Windows we support the "Unix Makefiles"
generator that uses forward slashes but not MSYS-style drive letter
conversion.

-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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-25 Thread Brad King
On 09/24/2015 11:08 AM, Kislinskiy, Stefan wrote:
> Regarding the ExternalProjectShellPathGenex test
[snip]
> there is a standard Windows command out there that cannot
> handle slashed even if they are quoted (any idea?)

Rather than trying to find a command for this you could just have
the test build a small binary that actually checks the slashes
of its arguments.

-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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-24 Thread David Cole via cmake-developers
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.kislins...@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.k...@kitware.com]
> Sent: Mittwoch, 23. September 2015 16:57
> To: Kislinskiy, Stefan
> Cc: cmake-developers@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 $?
>
> 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
-- 

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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-24 Thread Kislinskiy, Stefan
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.k...@kitware.com] 
Sent: Mittwoch, 23. September 2015 16:57
To: Kislinskiy, Stefan
Cc: cmake-developers@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 $?

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



shell_path_genex_v4.patch
Description: shell_path_genex_v4.patch
-- 

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

Re: [cmake-developers] generator expression for path slash conversion

2015-09-24 Thread Kislinskiy, Stefan
Great, thank you, Brad & David.

Regarding the ExternalProjectShellPathGenex test: I wrongly assumed that the 
WIN32 variable wouldn't be set when using MSYS and the like. Would it make 
sense to keep the test when changing the WIN32 check to MSVC? Good to know that 
pushd is working for quoted paths. As I didn't use paths with spaces, the 
argument wasn't quoted and the test worked like expected for me (succeeded with 
the SHELL_PATH genex and failed when I removed the SHELL_PATH genex). We could 
ensure that there isn't any space character in the argument by using a 
top-level path like C:/. Not hard coded but derived from a variable like 
CMAKE_SOURCE_DIR. Or, of course, there is a standard Windows command out there 
that cannot handle slashed even if they are quoted (any idea?). I chose pushd, 
as that was the command that started it all (used indirectly by the Boost build 
scripts).

Regarding the nice bracket tweak: Maybe the minimum required version in 
Tests/GeneratorExpression/CMakeLists.txt should be updated to 3.0.0 then?

Stefan

-Original Message-
From: Brad King [mailto:brad.k...@kitware.com] 
Sent: Donnerstag, 24. September 2015 16:22
To: Kislinskiy, Stefan
Cc: cmake-developers@cmake.org
Subject: Re: [cmake-developers] generator expression for path slash conversion

On 09/24/2015 09:05 AM, Kislinskiy, Stefan 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.

Thanks.  I started with a change to simplify the test infrastructure slightly:

 Tests: Simplify GeneratorExpression check implementation
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7de868c4

Then I applied your changes with minor tweaks and merged to 'next'
for testing:

 Genex: Add a SHELL_PATH expression
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8adf6ab5

I left out the ExternalProjectShellPathGenex test because it fails on the 
Ninja, MSYS Makefiles, and MinGW Makefiles generators on Windows.  The 'pushd' 
and 'popd' commands do not work there due to the way the build tool runs the 
command in a shell.  It passed for me only in a VS IDE generator.  See also 
David Cole's sibling response about this test.

-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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-24 Thread Brad King
On 09/24/2015 09:05 AM, Kislinskiy, Stefan 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.

Thanks.  I started with a change to simplify the test infrastructure slightly:

 Tests: Simplify GeneratorExpression check implementation
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7de868c4

Then I applied your changes with minor tweaks and merged to 'next'
for testing:

 Genex: Add a SHELL_PATH expression
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8adf6ab5

I left out the ExternalProjectShellPathGenex test because it fails
on the Ninja, MSYS Makefiles, and MinGW Makefiles generators on
Windows.  The 'pushd' and 'popd' commands do not work there due to
the way the build tool runs the command in a shell.  It passed for
me only in a VS IDE generator.  See also David Cole's sibling
response about this test.

-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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-24 Thread James Johnston
> -Original Message-
> From: cmake-developers [mailto:cmake-developers-boun...@cmake.org]
> On Behalf Of Kislinskiy, Stefan
> Sent: Thursday, September 24, 2015 15:09
> To: Brad King
> Cc: cmake-developers@cmake.org
> Subject: Re: [cmake-developers] generator expression for path slash
> conversion
> 
> Great, thank you, Brad & David.
> 
> Regarding the ExternalProjectShellPathGenex test: I wrongly assumed that
> the WIN32 variable wouldn't be set when using MSYS and the like. Would it
> make sense to keep the test when changing the WIN32 check to MSVC?

Just an FYI:  MSVC can still be set; it's an indicator of the *compiler* in
use, not the *generator*.  For example, it could be set if using cl.exe with
Ninja.

Best regards,

James Johnston

-- 

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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-23 Thread Kislinskiy, Stefan
I wrote the documentation, added a genex test that checks it the given path is 
converted as expected on different platforms, and added another ExternalProject 
test for Windows that invokes pushd, which is is command sensitive to the path 
style. I wasn't sure about the VERSION I am supposed to write into the 
cmake_minimum_required() line in 
Tests/ExternalProjectShellPathGenex/CMakeLists.txt, so I chose 3.3.20150923. 
Maybe you need to adjust the version there? I tried to be as consistent as 
possible regarding the tests and their already existing fellow tests.

-Original Message-
From: Brad King [mailto:brad.k...@kitware.com] 
Sent: Donnerstag, 17. September 2015 15:56
To: Kislinskiy, Stefan
Cc: CHEVRIER, Marc; cmake-developers@cmake.org; James Johnston
Subject: Re: [cmake-developers] generator expression for path slash conversion

On 09/17/2015 09:51 AM, Kislinskiy, Stefan wrote:
> I wrote a SHELL_PATH genex which uses
> cmOutputConverter->ConvertToOutputFormat(..., SHELL) for the conversion.
> I decided to name the genex SHELL_PATH instead of TO_SHELL_PATH for 
> the sake of consistency to other genexes like LOWER_CASE. What do you think?

LGTM.

> I would write some documentation as well of course.

Yes, please.  Also please look at extending the test suite to cover it.
See Tests/GeneratorExpression for genex unit test examples.  If possible we 
should also have a case that uses it in practice in a way that fails on 
invocation of an actual native tool if the slashes are wrong.  That will 
confirm not only that the genex does what we expect but that it also solves the 
problem we're trying to solve.

Thanks,
-Brad



shell_path_genex_v3.patch
Description: shell_path_genex_v3.patch
-- 

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

Re: [cmake-developers] generator expression for path slash conversion

2015-09-23 Thread Brad King
On 09/23/2015 08:40 AM, Kislinskiy, Stefan wrote:
> I wrote the documentation, added a genex test that checks it the
> given path is converted as expected on different platforms, and
> added another ExternalProject test for Windows that invokes
> pushd, which is is command sensitive to the path style.

Thanks.  I needed to fix a typo to get the latter test to run:

-add_test(ExternalProjectShellPathGenex ${CMAKE_TEST_COMMAND}
+add_test(ExternalProjectShellPathGenex ${CMAKE_CTEST_COMMAND}

However, it fails when there is a space in the path because the
conversion result ends up as something like

  "\"c:\path with space\...\""

The problem is that the genex evaluates and adds the quotes and
then the custom command generator escapes the argument for the
shell again.  The problem is that ConvertToOutputFormat is meant
as the final conversion step when writing a path into a shell
command in the generator, so it quotes values with spaces and may
add other escapes ad needed for the build system script (e.g. the
Makefile).  The custom command generator will then repeat all that
with another layer.  Therefore ConvertToOutputFormat is not the
right implementation for SHELL_PATH.  I think we want just the
slash conversion to be done by the genex.

Unfortunately the proper sequence of path escaping steps depends
on the context in which the path will be written.  When using
$ inside add_custom_command we want it to do
just the slash conversion because add_custom_command will take
care of the rest of the layers of escaping.  However, in case of
using file(GENERATE) for a .cmd file then we would want the
quoting too.  Perhaps we can defer that use case to later work
with a separate $ genex.

> I wasn't sure about the VERSION I am supposed to write into the
> cmake_minimum_required() line in
> Tests/ExternalProjectShellPathGenex/CMakeLists.txt, so I chose
> 3.3.20150923.

That's fine.

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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-21 Thread Kislinskiy, Stefan
Ah, thank you very much! I was confused as the distinction between WIN32 and 
UNIX worked nevertheless.

-Original Message-
From: Brad King [mailto:brad.k...@kitware.com] 
Sent: Montag, 21. September 2015 16:17
To: Kislinskiy, Stefan
Cc: CHEVRIER, Marc; cmake-developers@cmake.org; James Johnston
Subject: Re: [cmake-developers] generator expression for path slash conversion

On 09/21/2015 10:05 AM, Kislinskiy, Stefan wrote:
> if(MSYS)
>   check(test_shell_path "/c/shell/path")
> elseif(WIN32)
>   check(test_shell_path "c:shellpath")
> elseif(UNIX)
>   check(test_shell_path "c:/shell/path")
> endif()
> 
> No matter what I'm doing, it always ends up in the WIN32 branch with 
> FORWARD slashes. Additionally the drive letter is NOT converted to a posix 
> path as it should be the case for MSYS. I tried MSYS from the official MinGW 
> package, and I tried the MSYS2 installer. In both cases I called cmake from 
> MinGW-sh, MSYS-sh, and even cmd.exe. I used the "MSYS Makefiles" Generator. 
> In addition I tried the "MinGW Makefiles" generator just to check if 
> "if(MINGW)" is working... which also fails. The configuring/generating itself 
> is working.. Any ideas?

The code in the check-part4.cmake script runs in a cmake script (via "cmake 
-P").  That does not have any information about the configuration of the 
project, generator used, or target platform.
If you need this information it needs to be passed in through additional 
"-Dvar=val" arguments prior to the -P argument.

-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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-21 Thread Kislinskiy, Stefan
I wrote the documentation and extended the GeneratorExpression tests for the 
SHELL_PATH genex. It works fine for WIN32 and UNIX. However, I'm having some 
trouble to test for MSYS. The check looks like:

if(MSYS)
  check(test_shell_path "/c/shell/path")
elseif(WIN32)
  check(test_shell_path "c:shellpath")
elseif(UNIX)
  check(test_shell_path "c:/shell/path")
endif()

No matter what I'm doing, it always ends up in the WIN32 branch with FORWARD 
slashes. Additionally the drive letter is NOT converted to a posix path as it 
should be the case for MSYS. I tried MSYS from the official MinGW package, and 
I tried the MSYS2 installer. In both cases I called cmake from MinGW-sh, 
MSYS-sh, and even cmd.exe. I used the "MSYS Makefiles" Generator. In addition I 
tried the "MinGW Makefiles" generator just to check if "if(MINGW)" is 
working... which also fails. The configuring/generating itself is working.. Any 
ideas?

Stefan

-Original Message-
From: Brad King [mailto:brad.k...@kitware.com] 
Sent: Donnerstag, 17. September 2015 15:56
To: Kislinskiy, Stefan
Cc: CHEVRIER, Marc; cmake-developers@cmake.org; James Johnston
Subject: Re: [cmake-developers] generator expression for path slash conversion

On 09/17/2015 09:51 AM, Kislinskiy, Stefan wrote:
> I wrote a SHELL_PATH genex which uses
> cmOutputConverter->ConvertToOutputFormat(..., SHELL) for the conversion.
> I decided to name the genex SHELL_PATH instead of TO_SHELL_PATH for 
> the sake of consistency to other genexes like LOWER_CASE. What do you think?

LGTM.

> I would write some documentation as well of course.

Yes, please.  Also please look at extending the test suite to cover it.
See Tests/GeneratorExpression for genex unit test examples.  If possible we 
should also have a case that uses it in practice in a way that fails on 
invocation of an actual native tool if the slashes are wrong.  That will 
confirm not only that the genex does what we expect but that it also solves the 
problem we're trying to solve.

Thanks,
-Brad



shell_path_genex_v2.patch
Description: shell_path_genex_v2.patch
-- 

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

Re: [cmake-developers] generator expression for path slash conversion

2015-09-21 Thread Brad King
On 09/21/2015 10:05 AM, Kislinskiy, Stefan wrote:
> if(MSYS)
>   check(test_shell_path "/c/shell/path")
> elseif(WIN32)
>   check(test_shell_path "c:shellpath")
> elseif(UNIX)
>   check(test_shell_path "c:/shell/path")
> endif()
> 
> No matter what I'm doing, it always ends up in the WIN32 branch
> with FORWARD slashes. Additionally the drive letter is NOT converted to a 
> posix path as it should be the case for MSYS. I tried MSYS from the official 
> MinGW package, and I tried the MSYS2 installer. In both cases I called cmake 
> from MinGW-sh, MSYS-sh, and even cmd.exe. I used the "MSYS Makefiles" 
> Generator. In addition I tried the "MinGW Makefiles" generator just to check 
> if "if(MINGW)" is working... which also fails. The configuring/generating 
> itself is working.. Any ideas?

The code in the check-part4.cmake script runs in a cmake script
(via "cmake -P").  That does not have any information about the
configuration of the project, generator used, or target platform.
If you need this information it needs to be passed in through
additional "-Dvar=val" arguments prior to the -P argument.

-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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-17 Thread Brad King
On 09/17/2015 09:51 AM, Kislinskiy, Stefan wrote:
> I wrote a SHELL_PATH genex which uses
> cmOutputConverter->ConvertToOutputFormat(..., SHELL) for the conversion.
> I decided to name the genex SHELL_PATH instead of TO_SHELL_PATH for the
> sake of consistency to other genexes like LOWER_CASE. What do you think?

LGTM.

> I would write some documentation as well of course.

Yes, please.  Also please look at extending the test suite to cover it.
See Tests/GeneratorExpression for genex unit test examples.  If possible
we should also have a case that uses it in practice in a way that fails
on invocation of an actual native tool if the slashes are wrong.  That
will confirm not only that the genex does what we expect but that it
also solves the problem we're trying to solve.

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


Re: [cmake-developers] generator expression for path slash conversion

2015-09-17 Thread Kislinskiy, Stefan
Sorry for the late answer, I was on vacation. I wrote a SHELL_PATH genex which 
uses cmOutputConverter->ConvertToOutputFormat(..., SHELL) for the conversion. I 
decided to name the genex SHELL_PATH instead of TO_SHELL_PATH for the sake of 
consistency to other genexes like LOWER_CASE. What do you think? If it is okay 
I would write some documentation as well of course.

- Stefan


-Original Message-
From: Brad King [mailto:brad.k...@kitware.com] 
Sent: Montag, 31. August 2015 21:33
To: Kislinskiy, Stefan
Cc: CHEVRIER, Marc; cmake-developers@cmake.org; James Johnston
Subject: Re: [cmake-developers] generator expression for path slash conversion 
(was: ExternalProject: Use native paths as substitute for directory tokens)

On 08/31/2015 09:35 AM, Kislinskiy, Stefan wrote:
> As there is already a patch for such a genex in bug 15509 and the 
> discussion in 5939 (both linked below in Brad's reply) started 7 years 
> ago... It would be a great pity to let this issue seep away again. 
> What can I do to help fixing this finally?

Someone will need to think through and propose a specific genex that does the 
path conversion that makes sense in this context.  I think something like 
$ may be appropriate.

For referencing command line tools (as argv[0]) the C++ side uses code like 
this now:

 this->ConvertToOutputFormat(ccg.GetCommand(i), SHELL)

This genex should map to the same conversion internally.

-Brad



shell_path_genex.patch
Description: shell_path_genex.patch
cmake_minimum_required(VERSION 3.3.20150917 FATAL_ERROR)

project(Test VERSION 0.0.0.0 LANGUAGES NONE)

include(ExternalProject)

ExternalProject_Add(CMakeStyle
  SOURCE_DIR ${CMAKE_BINARY_DIR}
  CONFIGURE_COMMAND echo 
  BUILD_COMMAND echo 
  INSTALL_COMMAND echo 
)

ExternalProject_Add_Step(CMakeStyle custom
  COMMAND echo 
  DEPENDERS configure
)

ExternalProject_Add(ShellStyle
  SOURCE_DIR ${CMAKE_BINARY_DIR}
  CONFIGURE_COMMAND echo $<SHELL_PATH:>
  BUILD_COMMAND echo $<SHELL_PATH:>
  INSTALL_COMMAND echo $<SHELL_PATH:>
)

ExternalProject_Add_Step(ShellStyle custom
  COMMAND echo $<SHELL_PATH:>
  DEPENDERS configure
)
-- 

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

Re: [cmake-developers] generator expression for path slash conversion (was: ExternalProject: Use native paths as substitute for directory tokens)

2015-08-31 Thread Brad King
On 08/31/2015 09:35 AM, Kislinskiy, Stefan wrote:
> As there is already a patch for such a genex in bug 15509 and the
> discussion in 5939 (both linked below in Brad's reply) started 7
> years ago... It would be a great pity to let this issue seep away
> again. What can I do to help fixing this finally?

Someone will need to think through and propose a specific genex that
does the path conversion that makes sense in this context.  I think
something like $ may be appropriate.

For referencing command line tools (as argv[0]) the C++ side uses
code like this now:

 this->ConvertToOutputFormat(ccg.GetCommand(i), SHELL)

This genex should map to the same conversion internally.

-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


Re: [cmake-developers] generator expression for path slash conversion (was: ExternalProject: Use native paths as substitute for directory tokens)

2015-08-28 Thread Brad King
On 08/28/2015 04:06 AM, CHEVRIER, Marc wrote:
 Offering generator-expressions is a very good idea because it offers
 a global solution to this problem.
 
 Now regarding the name of the generator, may be TO_NATIVE_PATH is
 not judicious, (even if problems explained in
 http://www.cmake.org/Bug/view.php?id=5939 are, in my point of view,
 linked to platforms not well handled rather than wrong semantic of
 TO_NATIVE_PATH) but PATH_FOR_SHELL is, as well, ambiguous at least
 for two reasons:
 * commands defined in add_custom_command, for example, are directly
   executed without any shell evolved

No, add_custom_command results in a generated build system rule for
the specified command, and that always runs in a shell at build time.
One can see the conversions done properly internally to CMake for
generating references to source and object files on toolchain command
lines, for example.

 * A system can have multiple shells supporting different paths syntax.
   For example, on windows, my shell is tcsh which handle paths with '/'
   rather than '\'

It would be defined as the shell in which the build system will run
the commands.  We should choose a name accordingly.

-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


Re: [cmake-developers] generator expression for path slash conversion (was: ExternalProject: Use native paths as substitute for directory tokens)

2015-08-28 Thread CHEVRIER, Marc

Sorry for the false assertion.
I assumed, wrongly, that add_custom_command had same behaviour as 
execute_process for which the doc clearly explains that System API are used (no 
shell used).
So, adding some precisions on how add_custom_command (and add_custom_target I 
presume) launch specified commands should be a nice enhancement.

Marc





On 28/08/15 15:59, cmake-developers on behalf of Brad King 
cmake-developers-boun...@cmake.org on behalf of brad.k...@kitware.com wrote:

On 08/28/2015 04:06 AM, CHEVRIER, Marc wrote:
 Offering generator-expressions is a very good idea because it offers
 a global solution to this problem.
 
 Now regarding the name of the generator, may be TO_NATIVE_PATH is
 not judicious, (even if problems explained in
 http://www.cmake.org/Bug/view.php?id=5939 are, in my point of view,
 linked to platforms not well handled rather than wrong semantic of
 TO_NATIVE_PATH) but PATH_FOR_SHELL is, as well, ambiguous at least
 for two reasons:
 * commands defined in add_custom_command, for example, are directly
   executed without any shell evolved

No, add_custom_command results in a generated build system rule for
the specified command, and that always runs in a shell at build time.
One can see the conversions done properly internally to CMake for
generating references to source and object files on toolchain command
lines, for example.

 * A system can have multiple shells supporting different paths syntax.
   For example, on windows, my shell is tcsh which handle paths with '/'
   rather than '\'

It would be defined as the shell in which the build system will run
the commands.  We should choose a name accordingly.

-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
-- 

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