<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Scott,</div><div class=""><br class=""></div><div class="">I have find_program implemented to find ccache, as shown below.</div><div class=""><br class=""></div><div class=""><div class="">    find_program(CCACHE ccache)</div><div class="">    if(CCACHE)</div><div class="">        set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})</div><div class="">        set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})</div><div class="">    endif()</div></div><div class=""><br class=""></div><div class="">That’s not the issue. The issue is telling ccache where to place it’s cache files. If I compiles for toolchain X, Y and X, I need to set CCACHE_DIR accordingly. Otherwise the cache will be useless.</div><div class=""><br class=""></div><div class="">—Dave</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 19, 2017, at 12:57 PM, Craig Scott <<a href="mailto:craig.scott@crascit.com" class="">craig.scott@crascit.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Rather than relying on environment variables, you can use CMake's find_program() command to find ccache on your path and then tell CMake to use that as a launcher. You can find an article with a detailed explanation of how to set this up here: <div class=""><br class=""></div><div class=""><a href="https://crascit.com/2016/04/09/using-ccache-with-cmake/" class="">https://crascit.com/2016/04/09/using-ccache-with-cmake/</a><br class=""></div><div class=""><br class=""></div><div class="">An advantage of this approach is that the build will work with or without ccache installed. We've been using this in production for some time now and it works very smoothly. The technique can probably also be extended to support Windows too with <a href="https://github.com/frerich/clcache" class="">clcache</a>, but I haven't tried that yet.</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Jan 20, 2017 at 5:00 AM, David Lind <span dir="ltr" class=""><<a href="mailto:davidklind@gmail.com" target="_blank" class="">davidklind@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am porting existing makefiles to cmake. One of the key features of these makefiles is setting the CCACHE_DIR environment variable based upon the tool chain selected.<br class="">
<br class="">
I have TC_<toolchain>.cmake files created. Ideally, I would add a line to these files to set the CCACHE_DIR. But, CMake doesn’t have the ability to set environment variables during the build step. So, I’m stuck.<br class="">
<br class="">
Has anyone encountered this kind of situation?<br class="">
<br class="">
—Dave<br class="">
--<br class="">
<br class="">
Powered by <a href="http://www.kitware.com/" rel="noreferrer" target="_blank" class="">www.kitware.com</a><br class="">
<br class="">
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank" class="">http://www.cmake.org/Wiki/<wbr class="">CMake_FAQ</a><br class="">
<br class="">
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br class="">
<br class="">
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank" class="">http://cmake.org/cmake/help/<wbr class="">support.html</a><br class="">
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank" class="">http://cmake.org/cmake/help/<wbr class="">consulting.html</a><br class="">
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank" class="">http://cmake.org/cmake/help/<wbr class="">training.html</a><br class="">
<br class="">
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank" class="">http://www.kitware.com/<wbr class="">opensource/opensource.html</a><br class="">
<br class="">
Follow this link to subscribe/unsubscribe:<br class="">
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank" class="">http://public.kitware.com/<wbr class="">mailman/listinfo/cmake</a></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class="">Craig Scott<br class=""><div class="">Melbourne, Australia</div><div class=""><a href="https://crascit.com/" target="_blank" class="">https://crascit.com</a><br class=""></div></div></div></div></div></div></div>
</div>
</div></blockquote></div><br class=""></body></html>