[CMake] Spaces in a command
Bill Newcomb
bnewcomb at nvidia.com
Tue Jul 29 15:57:32 EDT 2014
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
>
>
More information about the CMake
mailing list