Re: [CMake] Superbuild subprojects and find_package()
Hi John, the primary tool for superbuilds in CMake's arsenal is ExternalProject_Add from module ExternalProject. I don't have much experience with it, but you can read its docs to see if it could help you. Petr On Thu, Apr 18, 2013 at 5:38 AM, John Gallagher johnkgallagher+cm...@gmail.com wrote: Hello all, Some Googling has led me to questions that have been asked that are similar to this one but I haven't seen a definitive answer. I'm trying to set up a CMake superbuild where there are dependencies between the subprojects, and some of the subprojects use find_package() to import targets from their dependencies (other subprojects, from the superbuild's point of view). For a stripped down example, suppose I have proj1 and proj2. proj1 can be built and installed on its own, and it writes out a Proj1Config.cmake file (with targets and such). proj2 uses find_package(Proj1 REQUIRED) to import those targets. So independent of a CMake superbuild, things work just fine if I configure, build, and install proj1, *then* configure, build, and install proj2. Is there a way to do this using a CMake superbuild? Some ideas (mostly gleaned from the aforementioned googling): 1. Use add_subdirectory() from the superproject. I think the REQUIRED on find_package() would fail though? In my case I can modify the subprojects, but I would like for them to continue to build correctly standalone (not inside the superbuild), as they really are separate projects. Is there a way to make add_subdirectory() work without exploding on find_package? 2. Don't use CMake for the superbuild - a shell script or plain Makefile could accomplish this pretty easily, but that seems a little hokey. 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). Appreciate any advice! John -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Superbuild subprojects and find_package()
Hi, On Thu, Apr 18, 2013 at 5:38 AM, John Gallagher johnkgallagher+cm...@gmail.com wrote: Hello all, Some Googling has led me to questions that have been asked that are similar to this one but I haven't seen a definitive answer. I'm trying to set up a CMake superbuild where there are dependencies between the subprojects, and some of the subprojects use find_package() to import targets from their dependencies (other subprojects, from the superbuild's point of view). For a stripped down example, suppose I have proj1 and proj2. proj1 can be built and installed on its own, and it writes out a Proj1Config.cmake file (with targets and such). proj2 uses find_package(Proj1 REQUIRED) to import those targets. So independent of a CMake superbuild, things work just fine if I configure, build, and install proj1, *then* configure, build, and install proj2. Is there a way to do this using a CMake superbuild? Some ideas (mostly gleaned from the aforementioned googling): I haven't used it yet, but this sounds like you should look into the ExternalProject module of CMake. See http://cmake.org/cmake/help/v2.8.10/cmake.html#module:ExternalProject Andreas -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Superbuild subprojects and find_package()
Hello John, Maybe I am missing something but can't you do something like this in proj2s cmakelists.txt? if( TARGET proj1 ) list_of_libraries_to_link_against( ${ list_of_libraries_to_link_against} proj1 ) else( TARGET proj1 ) find( proj1 required ) list_of_libraries_to_link_against( ${ list_of_libraries_to_link_against} proj1_libraries or whatever) endif(TARGET proj1 ) Message: 2 Date: Wed, 17 Apr 2013 23:38:36 -0400 From: John Gallagher johnkgallagher+cm...@gmail.com Subject: [CMake] Superbuild subprojects and find_package() To: cmake cmake@cmake.org Message-ID: CAFoDJR-oQxjdNgDh020SWRX0_pdcJ8E=+8meewhnvyjwxvu...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hello all, Some Googling has led me to questions that have been asked that are similar to this one but I haven't seen a definitive answer. I'm trying to set up a CMake superbuild where there are dependencies between the subprojects, and some of the subprojects use find_package() to import targets from their dependencies (other subprojects, from the superbuild's point of view). For a stripped down example, suppose I have proj1 and proj2. proj1 can be built and installed on its own, and it writes out a Proj1Config.cmake file (with targets and such). proj2 uses find_package(Proj1 REQUIRED) to import those targets. So independent of a CMake superbuild, things work just fine if I configure, build, and install proj1, *then* configure, build, and install proj2. Is there a way to do this using a CMake superbuild? Some ideas (mostly gleaned from the aforementioned googling): 1. Use add_subdirectory() from the superproject. I think the REQUIRED on find_package() would fail though? In my case I can modify the subprojects, but I would like for them to continue to build correctly standalone (not inside the superbuild), as they really are separate projects. Is there a way to make add_subdirectory() work without exploding on find_package? 2. Don't use CMake for the superbuild - a shell script or plain Makefile could accomplish this pretty easily, but that seems a little hokey. 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). Appreciate any advice! John -- next part -- An HTML attachment was scrubbed... URL: http://www.cmake.org/pipermail/cmake/attachments/20130417/3745c678/attachment-0001.htm -- -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Superbuild subprojects and find_package()
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 -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Superbuild subprojects and find_package()
Hello John, I made some generic scripts to answer has those kind of problem. There is an example in the folder Examples/FrameworkTest. You can find the scripts on GitHub: https://github.com/Athius/FrameworkCMakeToolkit I hope this is helpful. Best regards, Romain Le 18/04/13 05:38, John Gallagher a écrit : Hello all, Some Googling has led me to questions that have been asked that are similar to this one but I haven't seen a definitive answer. I'm trying to set up a CMake superbuild where there are dependencies between the subprojects, and some of the subprojects use find_package() to import targets from their dependencies (other subprojects, from the superbuild's point of view). For a stripped down example, suppose I have proj1 and proj2. proj1 can be built and installed on its own, and it writes out a Proj1Config.cmake file (with targets and such). proj2 uses find_package(Proj1 REQUIRED) to import those targets. So independent of a CMake superbuild, things work just fine if I configure, build, and install proj1, *then* configure, build, and install proj2. Is there a way to do this using a CMake superbuild? Some ideas (mostly gleaned from the aforementioned googling): 1. Use add_subdirectory() from the superproject. I think the REQUIRED on find_package() would fail though? In my case I can modify the subprojects, but I would like for them to continue to build correctly standalone (not inside the superbuild), as they really are separate projects. Is there a way to make add_subdirectory() work without exploding on find_package? 2. Don't use CMake for the superbuild - a shell script or plain Makefile could accomplish this pretty easily, but that seems a little hokey. 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). Appreciate any advice! John -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake