Re: [CMake] Passing options into COMMAND inside of add_custom_target() or add_custom_command()

2014-06-28 Thread Kornel Benko
Am Samstag, 28. Juni 2014 um 19:21:50, schrieb Hendrik Sattler 

> >So 'ls' got '-l -h' as one paramater.
> >I would use
> >1.) -DMYTOOL_FLAGS="-lh"
> >
> >or
> >2.) -DMYTOOL_FLAGS="-l;-h"
> 
> Or maybe escaping on the shell as
> "-DMYTOOL_FLAGS=-l -h"
> also works?

This is identical to -DMYTOOL_FLAGS="-l -h". The shell simply removes quotes. 
The command
(in this case cmake) get this (as one) parameter '-DMYTOOL_FLAGS=-l -h' 
including the blank.
So it should not work.

Kornel

signature.asc
Description: This is a digitally signed message part.
-- 

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

Re: [CMake] Passing options into COMMAND inside of add_custom_target() or add_custom_command()

2014-06-28 Thread Hendrik Sattler


On 28. Juni 2014 18:00:52 MESZ, Kornel Benko  wrote:
>Am Samstag, 28. Juni 2014 um 12:06:56, schrieb Martin Mitáš
>
>> 
>> Hello,
>> 
>> I'm trying to pass multiple options from outside to a command in
>add_custom_target() 
>> or add_custom_command(). I am new to CMake and I don't know whether
>the observed
>> behavior is bug or I do it in a wrong way.
>> 
>> I am doing all this with CMake 3.0 on Windows within MSYS environment
>if it
>> plays some role.
>> 
>> A test demonstrating the issue follows (using 'ls' as the command and
>'-l -h' 
>> as the options):
>> 
>> #  CMakeLists.txt 
>> cmake_minimum_required(VERSION 3.0)
>> project(test_project)
>> 
>> set(MYTOOL "ls")
>> 
>> add_custom_target(
>> x ALL
>> COMMAND ${MYTOOL} ${MYTOOL_FLAGS}
>> COMMENT "test"
>> VERBATIM
>> )
>> #  End of CMakeLists.txt 
>> 
>> 
>> Using the CMakeLists.txt above, I get this:
>> 
>> $ mkdir build  &&  cd build
>> $ cmake -G "MSYS Makefiles" -DMYTOOL_FLAGS="-l -h" ..
>> ... (unimportant output censored)
>> $ make VERBOSE=1
>> ... (unimportant output censored)
>> [100%] test
>> ls "-l -h"
>> ls: invalid option --
>
>So 'ls' got '-l -h' as one paramater.
>I would use
>1.) -DMYTOOL_FLAGS="-lh"
>
>or
>2.) -DMYTOOL_FLAGS="-l;-h"

Or maybe escaping on the shell as
"-DMYTOOL_FLAGS=-l -h"
also works?

>> Try `ls --help' for more information.
>> make[2]: *** [CMakeFiles/x] Error 2
>> make[2]: Leaving directory `/prj/pok/build'
>> make[1]: *** [CMakeFiles/x.dir/all] Error 2
>> make[1]: Leaving directory `/prj/pok/build'
>> make: *** [all] Error 2
>> 
>> 
>> As can be seen, CMake propagates the contents of ${MYTOOL_FLAGS} as a
>single 
>> option into 'ls', i.e. generated Makefile attempts to execute
>> 
>>  ls "-l -h"
>> 
>> instead of
>> 
>>  ls -l -h
>> 
>> Any ideas how to do this correctly?
>> 
>> Thanks,
>> Martin
>> 
>
>   Kornel
>
>

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
-- 

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

Re: [CMake] Passing options into COMMAND inside of add_custom_target() or add_custom_command()

2014-06-28 Thread Kornel Benko
Am Samstag, 28. Juni 2014 um 12:06:56, schrieb Martin Mitáš 
>
> Hello,
>
> I'm trying to pass multiple options from outside to a command in 
> add_custom_target()
> or add_custom_command(). I am new to CMake and I don't know whether the 
> observed
> behavior is bug or I do it in a wrong way.
>
> I am doing all this with CMake 3.0 on Windows within MSYS environment if it
> plays some role.
>
> A test demonstrating the issue follows (using 'ls' as the command and '-l -h'
> as the options):
>
> #  CMakeLists.txt ===> cmake_minimum_required(VERSION 3.0)
> project(test_project)
>
> set(MYTOOL "ls")
>
> add_custom_target(
> x ALL
> COMMAND ${MYTOOL} ${MYTOOL_FLAGS}
> COMMENT "test"
> VERBATIM
> )
> #  End of CMakeLists.txt ===>
>
> Using the CMakeLists.txt above, I get this:
>
> $ mkdir build  &&  cd build
> $ cmake -G "MSYS Makefiles" -DMYTOOL_FLAGS="-l -h" ..
> ... (unimportant output censored)
> $ make VERBOSE=1
> ... (unimportant output censored)
> [100%] test
> ls "-l -h"
> ls: invalid option --

So 'ls' got '-l -h' as one paramater.
I would use
1.) -DMYTOOL_FLAGS="-lh"

or
2.) -DMYTOOL_FLAGS="-l;-h"

> Try `ls --help' for more information.
> make[2]: *** [CMakeFiles/x] Error 2
> make[2]: Leaving directory `/prj/pok/build'
> make[1]: *** [CMakeFiles/x.dir/all] Error 2
> make[1]: Leaving directory `/prj/pok/build'
> make: *** [all] Error 2
>
>
> As can be seen, CMake propagates the contents of ${MYTOOL_FLAGS} as a single
> option into 'ls', i.e. generated Makefile attempts to execute
>
>   ls "-l -h"
>
> instead of
>
>   ls -l -h
>
> Any ideas how to do this correctly?
>
> Thanks,
> Martin
>

Kornel

signature.asc
Description: This is a digitally signed message part.
-- 

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