<div dir="ltr">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><br></div><div><a href="https://crascit.com/2016/04/09/using-ccache-with-cmake/">https://crascit.com/2016/04/09/using-ccache-with-cmake/</a><br></div><div><br></div><div>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">clcache</a>, but I haven't tried that yet.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 20, 2017 at 5:00 AM, David Lind <span dir="ltr"><<a href="mailto:davidklind@gmail.com" target="_blank">davidklind@gmail.com</a>></span> wrote:<br><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>
<br>
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>
<br>
Has anyone encountered this kind of situation?<br>
<br>
—Dave<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/<wbr>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/<wbr>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>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/<wbr>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/<wbr>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/<wbr>mailman/listinfo/cmake</a></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div>