<div dir="ltr">That only gets me part way - there's also the issue of the options & extra functions defined in <a href="http://protobuf-config.in">protobuf-config.in</a>. My best guess ATM would be to do something simmilar and create namespaced aliases, then just not include the protobuf-targets.cmake file from protobuf-config.cmake if CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_BINARY_DIR.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 2, 2016 at 6:16 PM Nicholas Braden <<a href="mailto:nicholas11braden@gmail.com">nicholas11braden@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Although not ideal, you could alias the targets to the names they<br>
would have when imported with find_package() by using<br>
add_library(ALIAS), and then use if(TARGET) to conditionally call<br>
find_package(). This also is a step toward supporting using the<br>
library via add_subdirectory(), if that ever becomes a goal.<br>
<br>
On Thu, Jun 2, 2016 at 8:06 PM, Walter Gray <<a href="mailto:chrysalisx@gmail.com" target="_blank">chrysalisx@gmail.com</a>> wrote:<br>
> I'm currently working on protobuf-3.0.0's cmake scripts, and I've hit a bit<br>
> of a chicken and egg problem.<br>
><br>
> There is an examples directory containing a CMakeLists.txt which we would<br>
> like to work as both a standalone examples directory and include as a sub<br>
> directory of the full build. For obvious reasons, the CMakeLists.txt file<br>
> contains a call to find_package(protobuf).<br>
><br>
> I can call find_package(protobuf HINTS ${CMAKE_BINARY_DIR}) outside of the<br>
> examples/CMakeLists.txt file to ensure that we've already found the correct<br>
> version, but the problem is that the protobuf-config.cmake file includes the<br>
> export-generated file protobuf-targets.cmake, as well as implementing some<br>
> custom functions that we want to show off as part of the examples.<br>
><br>
> The obvious solution to me was to use the export command to generate<br>
> protobuf-targets.cmake, but there are 2 problems. First, export(EXPORT)<br>
> doesn't create a file until generation time, but I can get around this using<br>
> export(TARGETS). The second is that, reading CMP0024, this appears to be not<br>
> garunted behavior, and actively discouraged.<br>
><br>
> What would be the suggested way to handle this?<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:<br>
> <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
><br>
> Kitware offers various services to support the CMake community. For more<br>
> 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/support.html</a><br>
> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/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/training.html</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/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/mailman/listinfo/cmake</a><br>
</blockquote></div>