On 2/14/2012 5:34 AM, Yury G. Kudryashov wrote:
Another way to achieve the same result:

set(INCLUDE_INSTALL_DIR "include") # relative
set(MYPKGDATA_INSTALL_DIR ${CMAKE_PREFIX_PATH}/share/mypkg) # absolute

cmake_package_config_for_install(Bar
   DESTINATION lib/cmake/Bar
   INPUT BarConfig-install.cmake.in
   PATH_VARS
     INCLUDE_INSTALL_DIR   # interpreted as relative to install prefix
     MYPKGDATA_INSTALL_DIR # absolute
   )

will substitute @PACKAGE_INCLUDE_INSTALL_DIR@ by "../../../include" and
@PACKAGE_MYPKGDATA_INSTALL_DIR@ by "../../../share/mypkg" (both transformed
to be relative to DESTINATION).

The main advantage of this solution is that the relative path is calculated
only once (when package is installed), not every time Config.cmake file is
sourced. The main drawback is that one has to specify all required path
variables explicitly.

That's an interesting interface idea.  In my proposal the paths are also
computed only during the initial generation of the file.  What needs to
be computed every time the file is loaded is the current installation
prefix relative to the file's location.  This cannot be precomputed,
but once it is known the other paths can all be made relative to that
(so would not contain ../).

What your suggestion adds is custom variable mapping that is very
convenient.  If the input value of INCLUDE_INSTALL_DIR is a relative
path it can be used verbatim as relative to the install prefix.  If
it is a full path that sits under the install prefix the macro can
handle conversion to a relative path automatically.  This is the part
that can be tedious to get right by hand.

Thanks,
-Brad
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to