> -----Original Message----- > From: rcdai...@gmail.com [mailto:rcdai...@gmail.com] On Behalf Of Robert > Dailey > Sent: Sunday, August 23, 2015 02:43 > To: James Johnston > Cc: CMake > Subject: Re: [CMake] How to depend on external cmake projects? > > On Mon, Aug 17, 2015 at 10:17 AM, James Johnston > <jam...@motionview3d.com> wrote: > > Well, you'd do this in conjunction with ExternalProject_Add. A > > well-written CMake external project will provide a > > <project>Config.cmake file which you will then find using find_package. > > After toying around with this idea for a bit, I've found out that > ExternalProject_Add() actually builds the project from a custom target within > Visual Studio (I'm using VS as my generator). However, > find_package() works at CMake configure time, so this is a chicken & egg > problem. find_package() won't work because the external project has not > been built yet. > > How do you solve this problem?
By following the following suggestion from earlier: > > > A high-level CMake project that does nothing but call > > ExternalProject_Add; this is called a superbuild. Your own CMake > > projects will be ExternalProjects to this high-level project and the > > superbuild would pass the location to your project via > > -D<project>_DIR=<location> so that find_package can locate the Config > file. > > I'm not sure I understand this. This smells related to my question above, > maybe an answer even. Can you clarify/go into more detail? > Thanks a bunch. Here is an example: https://github.com/InsightSoftwareConsortium/ITKWikiExamples/tree/master/Superbuild This CMakeLists.txt is the root CMakeLists.txt for the superbuild. Notice that: 1. It calls ExternalProject_Add to build VTK/ITK, **as well as** its own project. 2. find_package is not called from the superbuild, thus avoiding the chicken and egg problem. Best regards, James Johnston -- 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