<div dir="ltr"><div>Hi Bram.</div><div><br></div><div>Wild idea: could you also define a non-namespaced target `foo` and craft it such that linking against it generates a linker warning? Something like "Warning: symbol `Using_just_foo_is_deprecated_use_Foo_foo_instead` defined twice, ignoring weak definition."</div><br><div>Petr<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 2 July 2018 at 00:11, Bram de Greve <span dir="ltr"><<a href="mailto:bram@cocamware.com" target="_blank">bram@cocamware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That is unfortunate ... do you know any not-so-nice ways?<br>
<br>
So, what would you recommend here?<br>
<br>
I'm deprecating the old ways to use the Foo package (using Foo_LIBRARIES and Foo_INCLUDE_DIRS. You know, the cmake 2.x way of things). I can do that nicely with variable watches.<br>
<br>
But what about the target names?  If I want to guarantee a seamless transition period, I should opt to keep using the "foo" target names.  But then there's no way to "upgrade" to "Foo::foo" targets without breakage, since there's no deprecation strategy. And I can't use target aliases, since that is not allowed on imported targets.<br>
<br>
To answer my own question, I think the best thing is to move to the "Foo::foo" targets right now.  There's at least one downstream package that will be hurt by this, but the damage is less than waiting for everyone to have moved to the "foo" target first.<br>
<br>
Best,<br>
<br>
Bram.<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 6/29/2018 20:22, Robert Maynard wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am not aware of a nice way to setup CMake to error out if a user<br>
links to `foo` instead of `Foo::foo`.<br>
On Fri, Jun 29, 2018 at 2:05 AM Bram de Greve <<a href="mailto:bram@cocamware.com" target="_blank">bram@cocamware.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
Consider this situation.  I'm building a Foo packaged, to be used by a<br>
Bar project.<br>
<br>
Foo used to export its target as simply foo.<br>
Now it exports its target as Foo::foo.<br>
<br>
Bar contains this:<br>
add_library(bar ...)<br>
target_link_libraries(bar foo)<br>
<br>
This of course must now be:<br>
add_library(bar ...)<br>
target_link_libraries(bar Foo::foo)<br>
<br>
But if bar still links to the foo instead of Foo::foo, then CMake<br>
doesn't really complain.  foo doesn't exist, but configures and<br>
generates just fine.  Of course, you'll face strange build errors, from<br>
which it isn't immediately apparent what's causing this ...<br>
<br>
How can I make sure CMake will complain loudly when bar still links to foo?<br>
<br>
Thanks,<br>
Bram.<br>
<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/CMak<wbr>e_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/su<wbr>pport.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/co<wbr>nsulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/tr<wbr>aining.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/opensou<wbr>rce/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/list<wbr>info/cmake</a><br>
</blockquote></blockquote>
<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/CMak<wbr>e_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/su<wbr>pport.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/co<wbr>nsulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/tr<wbr>aining.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/opensou<wbr>rce/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/list<wbr>info/cmake</a><br>
</div></div></blockquote></div><br></div>