That only gets me part way - there's also the issue of the options & extra functions defined in protobuf-config.in. 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.
On Thu, Jun 2, 2016 at 6:16 PM Nicholas Braden <nicholas11bra...@gmail.com> wrote: > Although not ideal, you could alias the targets to the names they > would have when imported with find_package() by using > add_library(ALIAS), and then use if(TARGET) to conditionally call > find_package(). This also is a step toward supporting using the > library via add_subdirectory(), if that ever becomes a goal. > > On Thu, Jun 2, 2016 at 8:06 PM, Walter Gray <chrysal...@gmail.com> wrote: > > I'm currently working on protobuf-3.0.0's cmake scripts, and I've hit a > bit > > of a chicken and egg problem. > > > > There is an examples directory containing a CMakeLists.txt which we would > > like to work as both a standalone examples directory and include as a sub > > directory of the full build. For obvious reasons, the CMakeLists.txt file > > contains a call to find_package(protobuf). > > > > I can call find_package(protobuf HINTS ${CMAKE_BINARY_DIR}) outside of > the > > examples/CMakeLists.txt file to ensure that we've already found the > correct > > version, but the problem is that the protobuf-config.cmake file includes > the > > export-generated file protobuf-targets.cmake, as well as implementing > some > > custom functions that we want to show off as part of the examples. > > > > The obvious solution to me was to use the export command to generate > > protobuf-targets.cmake, but there are 2 problems. First, export(EXPORT) > > doesn't create a file until generation time, but I can get around this > using > > export(TARGETS). The second is that, reading CMP0024, this appears to be > not > > garunted behavior, and actively discouraged. > > > > What would be the suggested way to handle this? > > > > -- > > > > Powered by www.kitware.com > > > > Please keep messages on-topic and check the CMake FAQ at: > > http://www.cmake.org/Wiki/CMake_FAQ > > > > Kitware offers various services to support the CMake community. For more > > information on each offering, please visit: > > > > CMake Support: http://cmake.org/cmake/help/support.html > > CMake Consulting: http://cmake.org/cmake/help/consulting.html > > CMake Training Courses: http://cmake.org/cmake/help/training.html > > > > Visit other Kitware open-source projects at > > http://www.kitware.com/opensource/opensource.html > > > > Follow this link to subscribe/unsubscribe: > > http://public.kitware.com/mailman/listinfo/cmake >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake