[CMake] Superbuild subprojects and find_package()
Benjamin Eikel
cmake at eikel.org
Thu Apr 18 04:00:56 EDT 2013
Hello John,
On Wednesday 17 April 2013 23:38:36 John Gallagher wrote:
> 3. (This one is unclear.) Somehow build proj1 before configuring proj2, and
> point proj2 at proj1's build directory so it can find Proj1Config.cmake.
> This seems fragile at best (prefix, RPATH, etc issues).
when using ExternalProject, dependencies between projects can look like this (small excerpt from a superbuild project that I wrote):
…
include(ExternalProject)
# Build ZLIB first
ExternalProject_Add(EP_ZLIB
URL http://download.sourceforge.net/project/libpng/zlib/1.2.7/zlib-1.2.7.tar.gz
URL_MD5 "60df6a37c56e7c1366cca812414f7b85"
PATCH_COMMAND patch -p0 < ${CMAKE_CURRENT_LIST_DIR}/zlib-CMakeLists.txt-OUTPUT_NAME.patch && patch -p0 < ${CMAKE_CURRENT_LIST_DIR}/zlib-CMakeLists.txt-version-script.patch
INSTALL_DIR ${INSTALL_DIR}
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_BUILD_TYPE:STRING=Release
)
…
# For building CURL, use ZLIB that has been built before
ExternalProject_Add(EP_LIBCURL
DEPENDS EP_ZLIB
URL http://curl.haxx.se/download/curl-7.27.0.tar.gz
URL_MD5 "f0e48fdb635b5939e02a9291b89e5336"
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --host=${ARCH_TRIPLET} --disable-static --disable-manual --with-zlib=<INSTALL_DIR> CC=${CMAKE_C_COMPILER} LD=${CMAKE_LINKER}
INSTALL_DIR ${INSTALL_DIR}
)
Kind regards
Benjamin
More information about the CMake
mailing list