[CMake] export() vs. install(export...)

Michael Wild themiwi at gmail.com
Mon Sep 19 02:29:47 EDT 2011


On 09/19/2011 01:14 AM, Tim Gallagher wrote:
> Hi,
> 
> I've been trying to figure out the exact differences between the 
> export() and install(export ...) functions and I have some questions 
> still.
> 
> From the documentation, EXPORT() makes available the build tree for
> a given target and puts the path to the build tree in the 
> ~/.cmake/packages/<project> directory while INSTALL(EXPORT ...)
> makes the install tree available.
> 
> What I don't understand is what happens with EXPORT() if you have 
> multiple builds of the same project. For example, we often build (in 
> two different directories) the same project with two compilers
> (Intel and GNU) and install them in two different locations. But the
> entries in the registry just show path names. How would
> find_package() work in that instance?

the ~/.cmake/packages/<project> registry is only queried if you don't
specify a <project>_DIR variable which points to a directory containing
the <lower-project>-config.cmake (or <project>Config.cmake) file. If not
specified, find_package() will use the latest build tree registered in
~/.cmake/package/<project>.

> 
> When using INSTALL(EXPORT ...), I can get the information I need by 
> INCLUDE'ing the file, but I cannot find that file without the user's 
> input. Is there a way to put the path to the install tree in the 
> registry? If so, how would find_package() behave with multiple 
> installs?

See the documentation of the find_package() command for information on
where CMake looks for <project>Config.cmake files.

> 
> If anybody has any suggestions, I would appreciate it.
> 
> Tim

Does this help?

Michael


More information about the CMake mailing list