Re: [CMake] Super builds and export with Namespace

2016-08-12 Thread Ed Branch

We do it like this:

- in projectA/CMakeLists.txt:

set( ProjectA_IN_TREE TRUE CACHE INTERNAL "" )


- in projectA/ProjectA-config.cmake.in (which is converted to 
ProjectA-config.cmake by a call to configure_package_config_file from 
the CMakePackageConfigHelpers module):


if( ProjectA_IN_TREE )
add_library( ProjectA_LibraryName ALIAS LibraryName )
else()
include("${CMAKE_CURRENT_LIST_DIR}/ProjectA-targets.cmake")
endif()


The superbuild then just add_subdirectory(projectA) before 
add_subdirectory(pojectB), and projectB uses libraries from projectA 
just like it would if there was no superbuild.

--

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


[CMake] Super builds and export with Namespace

2016-08-11 Thread Miller Henry
I have a few different cmake based projects that depend on each other (as a 
tree, no circular dependencies).  Mostly this works great, but a few people 
have expressed interested in a superbuild which builds everything together for 
various purposes.  I can make this work with ExternalProject, but that isn't a 
useful solution for IDE users.  I'm trying to use add_subdirectory and running 
into a problem with namespaces in my export files

Currently projectA has
   EXPORT(projectA NameSpace ProjectA_)
Which works great, when projectB wants to link to a library in projectA it is 
just FIND_PACKAGE(ProjectA) then TARGET_LINK_LIBRARIES(lib 
ProjectA_LibraryName).  Simple enough without superbuilds.

When I get to a superbuild though I don't know how to handle this.  It is easy 
to do write some sort of FindProjectA.cmake or ProjectAConfig.cmake file to 
make the FIND_PACKAGE work in projectB. However I don't know how to get a 
ProjectA_LibraryName target that I can link to, the superbuild only knows about 
LibraryName without the namespace.

The only idea I can think of is in the superbuild have a bunch of ADD_LIBRARY 
(ProjectA_LibraryName ALIAS LibraryName) lines hard coded. This means I have to 
maintain that file though which I don't like. Does anyone have a better idea?


-- 

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