[CMake] Confusion regarding usage of find_package and PATHS or HINTS

Nils Gladitz nilsgladitz at gmail.com
Tue Jun 10 14:00:47 EDT 2014


On 10.06.2014 19:48, jmerkow wrote:
> Basically, the scenario I'm using this is when libraries are in some unknown
> location, but the location can be set during the configure step.
> In our case we have a number of external libraries that aren't  (and
> shouldn't be) installed, so there not going to be in any of the standard
> locations (I.e they won't be in /usr/bin etc).  We provide precompiled
> versions of these libraries for convenience, or the user can compile them.
> In the case where they use our precompiled libs, we have a standard
> directory structure for the externals.  I.e,
> externals/bin/lib-name/sub-dir-structure/. The externals directory can be
> anywhere, and we provide FindXxx.cmake files to locate them (given the
> location of the external dir).  So, with this, as long as the external dir
> location is known (and the follow the structure), we can find the libraries
> easily. We do it this way so the FindXxx.cmake files can be edited easily if
> we want to update them, or use fallback locations for some of the libraries.

If you are the author of those libraries maybe you could have them 
install/provide project configuration files[1] (FooConfig.cmake) instead 
of writing FindFoo.cmake find modules.
These can be generated by CMake (or other build systems ... or even 
handwritten if need be) for build directories and/or installations and 
for them the find_package() signature that you initially tried would work.

The existing find modules with CMAKE_PREFIX_PATH should work too though 
I'd try to keep it out of the project files and specify it manually with 
-D on the cmake command line or set it in the build system's environment.

Nils

[1] 
http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#config-file-packages


More information about the CMake mailing list