<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Apr 19, 2016 at 1:15 PM, Chaos Zhang <span dir="ltr"><<a href="mailto:zcsd2012@gmail.com" target="_blank">zcsd2012@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
Is there a way to use Linux command 'if' like this :<br>
<<a href="http://cmake.3232098.n2.nabble.com/file/n7593278/2016-04-19_113005.png" rel="noreferrer" target="_blank">http://cmake.3232098.n2.nabble.com/file/n7593278/2016-04-19_113005.png</a>><br>
For i need to execute 'if condition' in make phase rather than cmake phase.<br></blockquote><div><br></div><div>Try like this:<br><br>% cat CMakeLists.txt<br>add_custom_target(foo ALL)<br>add_custom_command(TARGET foo<br>    PRE_BUILD<br>    COMMAND if [ -f bar ]\; then echo yes\; else echo no\; fi)<br>% cmake .<br>% make<br>no<br>Built target foo<br>% touch bar<br>% make<br>yes<br>Built target foo<br>% <br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks a lot<br>
Chaos Zhang<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://cmake.3232098.n2.nabble.com/CMake-how-to-use-if-condition-in-command-add-custom-command-tp7593278.html" rel="noreferrer" target="_blank">http://cmake.3232098.n2.nabble.com/CMake-how-to-use-if-condition-in-command-add-custom-command-tp7593278.html</a><br>
Sent from the CMake mailing list archive at Nabble.com.<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div></div>