[CMake] Running find_package after dependencies are built

Micha Hergarden micha.hergarden at gmail.com
Fri Oct 18 07:55:38 EDT 2013


Hello Olaf,

The problem is that find_package is done at configuration time of the
project, and building the external project is done during buildtime
(after configuration time that is). This is the reason why most projects
that want to use third party / external software create a so called
superproject. A super project puts your project in a externalproject as
well en thus runs cmake twice: once for all the external projects, and
once when building your project. Take a look at the structure of
openchemistry (git://github.com/OpenChemistry/openchemistry.git) which
demonstrates this principle.

HTH,
Micha

On 10/18/2013 01:34 PM, Olaf Ryder wrote:
> Here's the problem I'm trying to solve:
>
> * External Project A has no dependencies and generates LibraryA
> * External Project B is dependent on LibraryA
>
> Root CMakeLists.txt:
> add_subdirectory(external_project_a)
> add_subdirectory(external_project_b)
>
> External Project A CMakeLists.txt:
> ExternalProject_Add(projectA ...)
>
> External Project B CMakeLists.txt:
> find_package(LibraryA)
> ExternalProject_Add(projectB ...)
>
>
> When I configure CMake, it finds an old, locally installed version of
> LibraryA. When cross-compiling, I want External Project B's
> find_package(LibraryA) to find the newly cross-compiled LibraryA. 
>
> It feels like I need to somehow "run find_package again" at that point
> so it finds the right one. Right now I can manually make it work by
> building/installing External Project A then manually clearing my build
> folder and re-running CMake.
>
> How do I get External Project B to see the new cross-compiled LibraryA?
>
> Thanks
>
>
>
> --
>
> 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://www.cmake.org/mailman/listinfo/cmake

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20131018/e3073610/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20131018/e3073610/attachment-0001.pgp>


More information about the CMake mailing list