[CMake] Spaces in a command
Glenn Coombs
glenn.coombs at gmail.com
Sun Aug 3 16:30:28 EDT 2014
Not for me it doesn't:
$ make VERBOSE=yes
/usr/bin/cmake -H/home/glenn/src/cmake-test
-B/home/glenn/src/cmake-test/build --check-build-system
CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start
/home/glenn/src/cmake-test/build/CMakeFiles
/home/glenn/src/cmake-test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/glenn/src/cmake-test/build'
make -f CMakeFiles/do-foo.dir/build.make CMakeFiles/do-foo.dir/depend
make[2]: Entering directory `/home/glenn/src/cmake-test/build'
cd /home/glenn/src/cmake-test/build && /usr/bin/cmake -E cmake_depends
"Unix Makefiles" /home/glenn/src/cmake-test /home/glenn/src/cmake-test
/home/glenn/src/cmake-test/build /home/glenn/src/cmake-test/build
/home/glenn/src/cmake-test/build/CMakeFiles/do-foo.dir/DependInfo.cmake
--color=
make[2]: Leaving directory `/home/glenn/src/cmake-test/build'
make -f CMakeFiles/do-foo.dir/build.make CMakeFiles/do-foo.dir/build
make[2]: Entering directory `/home/glenn/src/cmake-test/build'
/usr/bin/cmake -E cmake_progress_report
/home/glenn/src/cmake-test/build/CMakeFiles 1
[100%] Generating foo
generate-foo || echo \"no big deal\"
make[2]: Leaving directory `/home/glenn/src/cmake-test/build'
/usr/bin/cmake -E cmake_progress_report
/home/glenn/src/cmake-test/build/CMakeFiles 1
[100%] Built target do-foo
make[1]: Leaving directory `/home/glenn/src/cmake-test/build'
/usr/bin/cmake -E cmake_progress_start
/home/glenn/src/cmake-test/build/CMakeFiles 0
I'm seeing the || outside of the double quotes. This is on Kubuntu 14.10
with cmake 2.8.12.2.
--
Glenn
On 29 July 2014 20:57, Bill Newcomb <bnewcomb at nvidia.com> wrote:
> On linux, at least, this results in there being double quotes around the
> ||, which causes it to not be interpreted by the shell.
>
> B.
>
>
> On 07/29/2014 12:25 PM, Glenn Coombs wrote:
>
>> I think this works like you want:
>>
>> cmake_minimum_required(VERSION 2.6)
>>
>> set(DO_RELAX 1)
>> if(DO_RELAX)
>> set(OR_RELAX || echo \"no big deal\")
>> else()
>> set(OR_RELAX)
>> endif()
>>
>> add_custom_command(OUTPUT foo COMMAND generate-foo ${OR_RELAX} VERBATIM)
>> add_custom_target(do-foo ALL DEPENDS foo)
>>
>>
>> --
>> Glenn
>>
>>
>> On 29 July 2014 19:19, J Decker <d3ck0r at gmail.com
>> <mailto:d3ck0r at gmail.com>> wrote:
>>
>> can try removing the quotes and subst space for semicolon?
>>
>>
>> On Tue, Jul 29, 2014 at 11:13 AM, Bill Newcomb <bnewcomb at nvidia.com
>> <mailto:bnewcomb at nvidia.com>> wrote:
>>
>> That doesn't work either:
>>
>> foo:
>> $(CMAKE_COMMAND) -E cmake_progress_report
>> /home/bnewcomb/tmp/cmake-tests/custom-or/CMakeFiles
>> $(CMAKE_PROGRESS_1)
>> @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR)
>> --blue --bold "Generating foo"
>> generate-foo "|| echo \"no big deal\""
>>
>> The whole string gets passed as the first argument to
>> generate-foo.
>>
>> B.
>>
>> On 07/25/2014 09:43 AM, Iosif Neitzke wrote:
>> > "If VERBATIM is given then all arguments to the commands will
>> be
>> > escaped properly for the build tool so that the invoked command
>> > receives each argument unchanged. Note that one level of
>> escapes is
>> > still used by the CMake language processor before
>> add_custom_command
>> > even sees the arguments. Use of VERBATIM is recommended as it
>> enables
>> > correct behavior. When VERBATIM is not given the behavior is
>> platform
>> > specific because there is no protection of tool-specific
>> special
>> > characters."
>> >
>> >
>> http://www.cmake.org/cmake/help/v3.0/command/add_custom_
>> command.html
>> >
>> > On Fri, Jul 25, 2014 at 11:20 AM, Bill Newcomb
>> <bnewcomb at nvidia.com <mailto:bnewcomb at nvidia.com>> wrote:
>> >> I want to add stuff to a custom command based on some
>> definition:
>> >>
>> >> cmake_minimum_required(VERSION 2.6)
>> >>
>> >> set(DO_RELAX 1)
>> >> if(DO_RELAX)
>> >> set(OR_RELAX "|| echo \"no big deal\"")
>> >> else()
>> >> set(OR_RELAX "")
>> >> endif()
>> >>
>> >> add_custom_command(OUTPUT foo COMMAND generate-foo
>> ${OR_RELAX})
>> >> add_custom_target(do-foo ALL DEPENDS foo)
>> >>
>> >>
>> >> However, this produces the following rule in the generated
>> makefile:
>> >>
>> >> foo:
>> >> $(CMAKE_COMMAND) -E cmake_progress_report
>> /home/bnewcomb/tmp/cmake-tests/custom-or/CMakeFiles
>> $(CMAKE_PROGRESS_1)
>> >> @$(CMAKE_COMMAND) -E cmake_echo_color
>> --switch=$(COLOR) --blue --bold "Generating foo"
>> >> generate-foo ||\ echo\ "no\ big\ deal"
>> >>
>> >> Is there some way I can get cmake to not escape all of the
>> >> spaces in the value of OR_RELAX?
>> >>
>> >> Thanks,
>> >> B.
>> >>
>> >>
>> ------------------------------------------------------------
>> -----------------------
>> >> This email message is for the sole use of the intended
>> recipient(s) and may contain
>> >> confidential information. Any unauthorized review, use,
>> disclosure or distribution
>> >> is prohibited. If you are not the intended recipient,
>> please contact the sender by
>> >> reply email and destroy all copies of the original message.
>> >>
>> ------------------------------------------------------------
>> -----------------------
>> >> --
>> >>
>> >> Powered by www.kitware.com <http://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
>> --
>>
>> Powered by www.kitware.com <http://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
>>
>>
>>
>> --
>>
>> Powered by www.kitware.com <http://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
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140803/3cac4d3a/attachment-0001.html>
More information about the CMake
mailing list