Thanks for the discussion guys! And thanks Marcus for the CMAKE_CACHE_ARGS tip. I'll try that out.<br><br><br>In fact,
the current design could be problematic because if you *do* specify a
different toolchain file, cmake will ignore it instead of sending you a warning like it does if you change the CMAKE_CXX_COMPILER. Would it be straightforward to compare the passed in value of CMAKE_TOOLCHAIN_FILE against the cached version? That would prevent the "noisy" warning message, and afford the opportunity to send a legitimate warning or error if it does not match. <br>
<br>Pat<br><br><div class="gmail_quote">On Wed, Feb 6, 2013 at 11:56 PM, David Cole <span dir="ltr"><<a href="mailto:dlrdave@aol.com" target="_blank">dlrdave@aol.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<font color="black" face="arial">-----Original Message-----<br>
</font><div style="font-size:10pt;font-family:arial,helvetica"><font color="black" face="arial"><div><div class="h5"><font color="black" face="arial">
From: Pat Marion <<a href="mailto:pat.marion@kitware.com" target="_blank">pat.marion@kitware.com</a>><br>
To: David Cole <<a href="mailto:dlrdave@aol.com" target="_blank">dlrdave@aol.com</a>><br>
Cc: themiwi <<a href="mailto:themiwi@gmail.com" target="_blank">themiwi@gmail.com</a>>; cmake <<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>><br>
Sent: Wed, Feb 6, 2013 8:34 am<br>
Subject: Re: [CMake] Passing CMAKE_TOOLCHAIN_FILE on command line causes CMake warning<br>
<br>
</font>
</div></div></font><div><font color="black" face="arial"></font><div><font color="black" face="arial"></font><div class="h5"><font color="black" face="arial"><font color="black" face="arial">
I'd like you to try pasting the following text into a google search, so you can appreciate how widespread the warning is, 257 results from lots of different projects:<br>
<br>
<br>
CMake Warning: Manually-specified variables were not used by the project: CMAKE_TOOLCHAIN_FILE<br>
<br>
<br>
Most of these projects are not going to incorporate workarounds. The warning is confusing to lots of users, and they're already unsure of the while crosscompiling thing, so seeing a warning adds uncertainty that they're doing it right. Adding a workaround into the target project is not always possible since you might not have commit access or are compiling a previously released, stable version.<br>
<br>
Pat<br>
<br>
<br>
<br>
</font>
</font><div class="gmail_quote"><font color="black" face="arial"><font color="black" face="arial">On Wed, Feb 6, 2013 at 10:51 PM, David Cole <span dir="ltr"><<a href="mailto:dlrdave@aol.com" target="_blank">dlrdave@aol.com</a>></span> wrote:<br>
</font></font><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font color="black" face="arial"><font color="black" face="arial">
<font color="black" face="arial">If you don't want to see the warning, then <font>also pass in --no-warn-unused-cl<font>i on the command line.<br>
<br>
</font><font> --no-warn-unused-cli = Don't warn about command line options.</font><br>
</font><font color="black" face="arial">
</font></font>
</font>
</font><div><font color="black" face="arial"><font color="black" face="arial"><font color="black" face="arial"><font color="black" face="arial"> <br>
<font>But that suppresses the warning <font>for all unreferenced variables.<br>
<br>
<font>Or... add<font>:<br>
<br>
</font> message<font>(STATUS "CMAKE_TOOLCHAIN<font>_FILE='${CMAKE_TOOLCHAIN_FILE}'</font>")</font></font><br>
</font></font></font></font></font></font>
</div>
<div> <br>
<font>to the project<font>'s CMakeLists.txt file so </font></font>the <font>v<font>ariable is always referenced.</font></font><br>
</div>
<div> <br>
<font>The point is: CMAKE_<font>TOOLCHAI<font>N_FILE is only read on the first configure. After that point, all toolchain stuff is cached and the file is unnecessary for subsequent configures.<br>
<br>
</font></font></font><font>That bu<font>g should just be closed as "won<font>'t fix" because it's not a bug. It's the intended behavior, and there are multiple ways to avoid the legitimate warning.<br>
<br>
<br>
<font>Just my opinion,<br>
<font>D<br>
<br>
<br>
</font></font></font></font></font><br>
</div>
<div style="font-size:10pt;font-family:arial,helvetica">
<div>
<div>-----Original Message-----<br>
From: Pat Marion <<a href="mailto:pat.marion@kitware.com" target="_blank">pat.marion@kitware.com</a>><br>
To: Michael Wild <<a href="mailto:themiwi@gmail.com" target="_blank">themiwi@gmail.com</a>><br>
Cc: cmake <<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>><br>
Sent: Wed, Feb 6, 2013 7:23 am<br>
Subject: Re: [CMake] Passing CMAKE_TOOLCHAIN_FILE on command line causes CMake warning<br>
<br>
<div>
That's a pretty messy workaround though, I think. ExternalProject_Add passes in lots of variables, including ones that do not typically change, like CMAKE_CXX_COMPILER. Why impose a special requirement on the CMAKE_TOOLCHAIN_FILE variable? Would a patch to avoid the warning be a welcome change, or is there a reason the warning should remain?<br>
<br>
Pat<br>
<br>
<div class="gmail_quote">On Wed, Feb 6, 2013 at 9:52 PM, Michael Wild <span dir="ltr"><<a href="mailto:themiwi@gmail.com" target="_blank">themiwi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi<br>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">
<div>On Wed, Feb 6, 2013 at 11:59 AM, Pat Marion <span dir="ltr"><<a href="mailto:pat.marion@kitware.com" target="_blank">pat.marion@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm emailing about <a href="http://public.kitware.com/Bug/view.php?id=13093" target="_blank">bug 13093</a> in the backlog. I found <a href="http://www.cmake.org/pipermail/cmake/2011-February/042556.html" target="_blank">comments by Brad</a> that suggest it's a legitimate warning, but I'm not sure how a project could avoid the warning.</blockquote>
</div>
<div><br>
By not specifying the toolchain file, for instance? If you have the problem in conjunction with ExternalProject_Add, check whether the CMakeCache.txt file exists in the build tree of the external project. If not, include the flag, otherwise drop it. <br>
<br>
My 2c<span><font color="#888888"><br>
<br>
Michael<br>
</font></span></div>
</div>
</div>
</div>
</blockquote></div>
<br>
</div>
</div>
</div>
<div style="font-size:12px;font-family:Tahoma,Verdana,Arial,Sans-Serif;margin:0px">
<pre style="font-size:9pt"><tt>--
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a>
</tt></pre>
</div>
</div>
</blockquote></div>
<br>
<br>
</div></div><font>I appreciate the widesp<font>read nature of "the problem." Re<font>ally, I do. (If you do the same sear<font>ch, but without CMAKE_TOOLCHAIN_FILE, you get 20,000+ results.)</font><br>
<br>
</font></font></font><font>The intent of the warning <font>feature is to point out that you may have <font>misspelled a vari<font>able name, since usually, variables specified on the command line *are* in fact, <font>referenced during the configure or generate steps.<br>
<br>
<font>Unfortunately, the text of the warning does not say "you may have misspelled this, double-check your spelling". Nor does it say<font> the more clear "this variable was no<font>t referenced at all by <font>any of t<font>he CMakeLists code use<font>d <font>during configuration or generation</font></font></font></font></font>". It could even say "reference the v<font>ariable, or use --no<font>-warn-unused-cli<font> to eliminate this warning" -- but it doesn't.</font></font></font></font><br>
<br>
<font>T<font>he other positive effect here is that it may point out that you're not using all the variables that you think you're using. Therefore, you may be able to simplify your command line, or your CMakeLists files.<br>
<br>
<br>
<font>I'm not a big fan of special<font>-casing variable names for code like this. But if CMAKE_TOOLCHAIN_FILE is really "special", then maybe that's the right <font>call here.</font> You could certainly check if it's the same as the cached value<font>, and only warn<font> if it's different. If you do add such <font>a warning, use text something like "<font>start with a<font> completely clean<font> build tree if you are chan<font>ging toolchain files" when a difference is detected.</font></font></font></font></font></font></font><br>
<br>
</font></font><br>
<font>Cheers,<br>
<font>D<br>
<br>
</font></font></font></font></font></font></font></font></font></font>
</div>
</div>
</blockquote></div><br>