Best practice for modifying search path for find_package()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Best practice for modifying search path for find_package()

Robert Dailey-2
So I have a "super build" CMake script that runs a series of
ExternalProject_Add() functions to execute builds of various third
party libraries and install them to a path relative to the parent
project's CMAKE_BINARY_DIR.

Once the parent project generation occurs, it is expected to do a
series of find_package() commands to locate the packages installed by
the previous super build.

What is the best way to intercept the find_package() search paths to
prioritize searching to the custom relative root directory managed by
the super build? Based on the documentation for find_package()[1],
seems like CMAKE_PREFIX_PATH might be the best way (set it as a normal
variable, not a cache variable) inside the CMake scripts prior to the
find_package() invocations (which are done indirectly by other CMake
scripts I do not manage and cannot change). Although, the usage intent
for CMAKE_PREFIX_PATH seems to be documented differently than how I
plan to use it.

Any advice?

[1]: https://cmake.org/cmake/help/v3.6/command/find_package.html
--

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
Reply | Threaded
Open this post in threaded view
|

Re: Best practice for modifying search path for find_package()

Alexander Neundorf-3
On 2017 M08 24, Thu 13:36:45 CEST Robert Dailey wrote:

> So I have a "super build" CMake script that runs a series of
> ExternalProject_Add() functions to execute builds of various third
> party libraries and install them to a path relative to the parent
> project's CMAKE_BINARY_DIR.
>
> Once the parent project generation occurs, it is expected to do a
> series of find_package() commands to locate the packages installed by
> the previous super build.
>
> What is the best way to intercept the find_package() search paths to
> prioritize searching to the custom relative root directory managed by
> the super build? Based on the documentation for find_package()[1],
> seems like CMAKE_PREFIX_PATH might be the best way (set it as a normal
> variable, not a cache variable) inside the CMake scripts prior to the
> find_package() invocations (which are done indirectly by other CMake
> scripts I do not manage and cannot change). Although, the usage intent
> for CMAKE_PREFIX_PATH seems to be documented differently than how I
> plan to use it.

You have one install dir for your external-package libraries and then want to
use them ?
IMO using CMAKE_PREFIX_PATH is just fine for this.

Alex

--

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