<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">Le 16 oct. 2017 23:54, "J. Paul Reed" <<a href="mailto:preed@releng-approaches.com">preed@releng-approaches.com</a>> a écrit :<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hey all,<br>
<br>
I have a (potentially?) odd situation: I need to generate multiple packages<br>
using CPack from the same CMake project.<br>
<br>
I'm aware of the component-based installers and methodology, but I don't<br>
believe that's what I want here: I want entirely different package<br>
names/versions/etc., containing different artifacts created from a single<br>
CMake project.<br>
<br>
I have currently implemented this by setting the various CPack<br>
configuration variables, and then include()ing CPack in different<br>
directories. I then have custom targets that call cpack with --config,<br>
pointed to a non-default-named CPack configuration file.<br>
<br>
This seems to work just fine, except during the cmake configuration run, we<br>
get warnings about CPack.cmake having already been included.<br>
<br>
I see where this message() gets emitted<br>
(<a href="https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/CPack.cmake#L298-302" rel="noreferrer" target="_blank">https://gitlab.kitware.com/<wbr>cmake/cmake/blob/master/<wbr>Modules/CPack.cmake#L298-302</a>);<br>
perusing that file, it seems to do things I basically want/need (setting<br>
various defaults, etc.) if I want to use cpack with a different config<br>
file.<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Hi there,</div><div dir="auto">As you already discovered I was the author of this warning some years ago when I was actively working on CPack. The reason for this was to make it clear that even include(CPack) may look (and somehow behave) like a function call creating a CPack config set of files. It is not. It wasn't designed for that usage and it may generate weird content on a second (or more) inclusion. </div><div dir="auto">Some people were occasionally bitten by that.</div><div dir="auto">e.g. since it inspects variable (in the current scope which was initially global) beginning with CPACK_ prefix for doing its work, when you use it twice it does not ensure or cleanup variables that may be there due to the first inclusion. This would be up to the user to clean leftover before successive inclusion.</div><div dir="auto"><br></div><div dir="auto">To summarize, this is a pure macro processing, not a function call.</div><div dir="auto"><br></div><div dir="auto">It would be nice to have a cpack_xxx function which safely implements the behaviour you seek. That was on my wishlist some time  but I never get the time to implement it. (There may be some old mantis bug report for that wish, I'll dig into it and come back here if I find something interesting).</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I can suppress the warning by unsetting CPack_CMake_INCLUDED, which is what<br>
I'm planning to do... but I wanted to ask:<br>
<br>
a) whether there are any technical problems or concerns by subverting that<br>
warning message and including CPack.cmake multiple times, and<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">You can now that you know the story. If I would have to do that I would:</div><div dir="auto"><br></div><div dir="auto">1. Delete **all** CPACK_ variable from current scope</div><div dir="auto"><br></div><div dir="auto">2. Unset CPack_CMake_INCLUDED</div><div dir="auto"><br></div><div dir="auto">3. setup the new CPACK_xxx value set</div><div dir="auto"><br></div><div dir="auto">4. include(CPack)</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
b) if there's another solution entirely that is better suited. (Again, I'm<br>
aware of component based installs; I don't think they'll do what I want<br>
here.)<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">Yep, contribute a "real" CMake function that do the right job.</div><div dir="auto">Ideally this function should replace current include(CPack) usage.</div><div dir="auto"><br></div><div dir="auto">CPack.cmake should be kept for backward compatibility legacy reason but it's content should be replaced by the appropriate new function call.</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
thanks,<br>
preed<br>
--<br>
J. Paul Reed<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><br>
</blockquote></div><br></div></div></div>