Hi Carlo, The answer is already right in front of you: "a && b" executes b only if a returns positive (zero exit code). This is already done for the mkdir.
And to answer the other question: no, you cannot assume a POSIX shell in a Makefile. HS Am 27. März 2020 05:53:39 MEZ schrieb Carlo Wood <ca...@alinoe.com>: >Hello! > >I'm writing a patch for cmake to address >https://gitlab.kitware.com/cmake/cmake/issues/19703 > >but I need a little help; I'm only familiar with >GNU/Linux and single target generator Makefile. > >In terms of a Makefile, if one uses ExternalProject_Add_Step, see > >https://cmake.org/cmake/help/latest/module/ExternalProject.html#explicit-step-management > >then something like this is generated: > > /path/to/stamp_dir/myname-mystep: /path/to/some/dependency > @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) \ > --blue --bold \ > --progress-dir=/path/to/buildir/CMakeFiles \ > --progress-num=$(CMAKE_PROGRESS_9) "My Comment" > cd /path/to/workingdir && \ > my_COMMAND my_arg1 my_arg2 ... \ > cd /path/to/workingdir && \ > cmake -E touch /path/to/stamp_dir/myname-mystep > >Now, I'm not sure about the portability of the COMMAND that >is passed to ExternalProject_Add_Step. Are we assuming that >every operating system supports a POSIX (unix) shell, like bash? > >Otherwise it seems that the only way to be portable is to run >cmake in script mode there. > >Note how the last command does this: it runs cmake in order to portably >'touch' the target file (a stamp file). > >What I need is way to generate a rule where depending on a >condition (to be decided by the COMMAND (my_COMMAND)) that >touch is or is not done. > >In the single target target POSIX Makefile case this could look like >this (I'm leaving out the COMMENT here for brevity), > > /path/to/stamp_dir/myname-mystep: /path/to/some/dependency > (cd /path/to/workingdir && \ > if my_COMMAND my_arg1 my_arg2 ...; then \ > cmake -E touch /path/to/stamp_dir/myname-mystep; \ > fi) > >which uses the return value of my_COMMAND to decide whether or >not to touch the stamp file. > >However, this is pure shell coding: using a '(' to open a sub shell >and then using 'if ...; then ... fi'. > >I'm looking for ideas on how to implement this in a portable way. > >How can I extract a boolean from a user defined COMMAND and then >use that to conditionally execute the touch? -- Powered by kitware.com/cmake Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services Visit other Kitware open-source projects at https://www.kitware.com/platforms Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake This mailing list is deprecated in favor of https://discourse.cmake.org