[CMake] Possible bug install(EXPORT ...) and 'DIRECTORY .' & questions regarding Config file authoring

Walter Gray chrysalisx at gmail.com
Mon Aug 4 18:54:00 EDT 2014


I've been trying to figure out how to correctly author install steps for 
a library that will generate a self-contained folder that can be 
distributed and used by others, including a good <package>Config.cmake 
file and I ran into what seems like a bug.  If you say

install(EXPORT <package> DESTINATION .)

Then the resulting file will, when generating the _IMPORT_PREFIX will 
produce the following:

get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)

Which for an install directory of C:\libraries\mypackage will produce an 
import prefix of C:\libraries.

I can work around this for now by installing to the cmake subdirectory, 
but I thought someone should be aware of this.  Is this a known issue? 
Also, what are the expected best practices regarding the authoring of 
good <package>Config.cmake files? The tutorial on 
http://www.cmake.org/cmake/help/git-master/manual/cmake-packages.7.html#creating-packages 
is somewhat lacking.  For example, while it mentions that cmake does not 
provide a way to register installed packages with the package registry, 
it does say you can do this yourself.  Is that the recommended thing to 
do? If so, how? providing a .bat or .sh file in your distributed 
folder's root that sets that up?


More information about the CMake mailing list