[CMake] Super builds and export with Namespace

Ed Branch branch at arlut.utexas.edu
Fri Aug 12 13:02:13 EDT 2016


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.


More information about the CMake mailing list