[CMake] install DESTINATION parameter - why can't be empty? Workarounds don't work.

drgutek@o2.pl drgutek at o2.pl
Fri Aug 18 03:29:19 EDT 2017


Hi,  In general, relative parameters of type PATH, like "lib" or "source/include" are resolved to an absolute path using current value of variables, like for instance: ${CMAKE_INSTALL_PREFIX} in case of command INSTALL(). This, however, does not work if I would like to use empty relative path (or not set it at all), so that the resulting absolute path was equal to ${CMAKE_INSTALL_PREFIX} - cmake generator would complain about non existing DESTINATION, although there is no reason why it couldn't be resolved.    I know two workarounds to this issue, but the both have their flaws which prevent me from achieving my goal:  1. Use ${CMAKE_INSTALL_PREFIX} as the DESTINATION value. This correctly resolved the path, but in case of INSTALL(EXPORT), paths in generated Target.cmake are absolute, which makes the package not relocatable.  2. Use '.' as the DESTINATION. This at least generates relative paths inside Target.cmake, but the paths are incorrect. '.' is apparently considered as a regular folder, and in the process of Target.cmake generation, when _IMPORT_PREFIX is determined, cmake strips one folder component too much:   # Compute the installation prefix relative to this file.  get_filename_component(_IMPORT "${CMAKE_CURRENT_LIST_FILE}" PATH)  get_filename_component(_IMPORT "${_IMPORT_PREFIX}" PATH)   Do you know any other workaround? Do you think that lack of empty relative paths could be considered a bug?   Piotr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170818/cb8c5a19/attachment-0001.html>


More information about the CMake mailing list