<div dir="ltr">I have read the description of PRE_BUILD before in CMake doc, but when i use it, i found something confuesed.<div>(1) In CMakeLists.txt, the content as below:<br><div><img src="http://cmake.3232098.n2.nabble.com/attachment/7593283/0/1.png" width="358" height="211"><br>​(2)After i make the makefile generated by this CMakeLists.txt, i get result as below:<br></div></div><div><img src="http://cmake.3232098.n2.nabble.com/attachment/7593283/1/2.png" width="414" height="125"></div><div>"3_pre_build" is behind "1_pre_link", if POST_BUILD gets treated as PRE_LINK, why "3_pre_build" was printed before "1_pre_link"?</div><div><br></div><div>Thanks for you reply,</div><div>Chaos Zhang</div><div>​<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-19 15:50 GMT+08:00 Craig Scott-3 [via CMake] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=7593283&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>></span>:<br><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">

        <div dir="ltr">In case it matters, in Clark's suggested code, note that PRE_BUILD is only fully honoured with Visual Studio generators. For everything else, it gets treated as PRE_LINK, which occurs later (i.e. after compiling all the sources rather than before). So it depends on what your "if" test is trying to do whether or not this matters in your case.</div></span><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 19, 2016 at 5:24 PM, Clark Wang <span dir="ltr"><<a href="http:///user/SendEmail.jtp?type=node&node=7593281&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>></span> wrote:<div><div class="h5"><br><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" class="gmail_quote"><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="http:///user/SendEmail.jtp?type=node&node=7593281&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>></span> wrote:<br><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" class="gmail_quote">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="nofollow" link="external" 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 style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" class="gmail_quote">
<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="nofollow" link="external" 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="nofollow" link="external" 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="nofollow" link="external" 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="nofollow" link="external" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="nofollow" link="external" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="nofollow" link="external" 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="nofollow" link="external" 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="nofollow" link="external" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="nofollow" link="external" 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="nofollow" link="external" 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="nofollow" link="external" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="nofollow" link="external" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="nofollow" link="external" 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="nofollow" link="external" 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="nofollow" link="external" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div></div></div><br><br clear="all"><span class=""><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="http://crascit.com" rel="nofollow" link="external" target="_blank">http://crascit.com</a><br></div></div></div></div></div>
</span></div><span class="">
<br>-- 
<br><br>Powered by <a href="http://www.kitware.com" target="_blank" rel="nofollow" link="external">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="nofollow" link="external" 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="nofollow" link="external" target="_blank">http://cmake.org/cmake/help/support.html</a><br>CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="nofollow" link="external" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="nofollow" link="external" 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="nofollow" link="external" 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="nofollow" link="external" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a>

        
        
        
        <br>
        <br>
        </span><hr noshade size="1" color="#cccccc">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif"><span class="">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                </span><a href="http://cmake.3232098.n2.nabble.com/CMake-how-to-use-if-condition-in-command-add-custom-command-tp7593278p7593281.html" target="_blank" rel="nofollow" link="external">http://cmake.3232098.n2.nabble.com/CMake-how-to-use-if-condition-in-command-add-custom-command-tp7593278p7593281.html</a>
        </div><div class="HOEnZb"><div class="h5">
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from CMake: how to use 'if condition' in command add_custom_command(...), <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>
                <a href="http://cmake.3232098.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
        </div></div></div></blockquote></div><br></div>


        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://cmake.3232098.n2.nabble.com/CMake-how-to-use-if-condition-in-command-add-custom-command-tp7593278p7593283.html">Re: CMake: how to use 'if condition' in command add_custom_command(...)</a><br/>
Sent from the <a href="http://cmake.3232098.n2.nabble.com/">CMake mailing list archive</a> at Nabble.com.<br/>