On Thu, Jan 28, 2016 at 7:17 PM, Stephen Kelly <steve...@gmail.com> wrote:
> > Has some kind of namespacing been considered for add_subdirectory? > > > > E. g. > > > > add_subdirectory(QtZeroConf NAMESPACE QTZEROCONF) > > And what if someone builds your project with -DBUILD_SHARED=ON? Are you > going to use > > set(QTZEROCONF_BUILD_SHARED ${BUILD_SHARED}) > add_subdirectory(QtZeroConf NAMESPACE QTZEROCONF) > > for every variable you're wrapping? Or do you want cmake to do that for > every variable in scope when the directory is added? How would cmake decide > which variables to namespace? > > CMake should wrap every variable defined under the directory added with add_subdirectory(QtZeroConf NAMESPACE QTZEROCONF), no need for me to manually wrap anything. > You should use ExternalProject instead, or fork the buildsystem of those > projects to integrate them into your project. Not that I recommend the > latter for you though :). That's what cmake does when integrating 3rd party > code. > > Unfortunately ExternalProject does not work well with find_package, e. g. this fill fail: CMakeLists.txt | \--- 3rdparty/CMakeLists.txt \--- server/CMakeLists.txt Where: 3rdparty/CMakeLists.txt contains ExternalProject_Add(QtZeroConf ...) and server/CMakeLists.txt contains find_package(QtZeroConf) This can be alleviated by using Hunter ( https://github.com/ruslo/hunter ), by modifying the third-party CMakeLists.txt ( https://coderwall.com/p/y3zzbq ) or by manually setting the imported library location ( http://mirkokiefer.com/blog/2013/03/cmake-by-example/) but it's cumbersome. My solution is much, much easier and requires no modification at all to the third-party. In fact, I think in addition to add_subdirectory( ... NAMESPACE ... ), there should be something like find_package( QtZeroConf EXTERNAL_PROJECT QtZeroConf), indicating the package is built by means of ExternalProject and therefore, finding the package should be delayed until after that external project has been built. That would make the tricks above unnecessary. -- Pau Garcia i Quiles http://www.elpauer.org (Due to my workload, I may need 10 days to answer)
-- 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-developers