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?
--

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 via email to