Hi,

when installing an export-file cmake has the nice feature to calculate the 
CMAKE_INSTALL_PREFIX from the current location:

-------------8<------------------8<----------8<----------------
# Compute the installation prefix relative to this file.
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)

# Import target "bar" for configuration ""
SET_PROPERTY(TARGET bar APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
...

# Cleanup temporary variables.
SET(_IMPORT_PREFIX)
-------------8<------------------8<----------8<----------------


I can't do this in cmake-script in a FooConfig.cmake file myself, there I 
simply must assume that if I go four levels up that I have reached my install 
prefix. This will usually be correct, but it would be nicer if I could reuse 
this knowledge which cmake generates into the per-configuration files.

So, I'd like to do from my FooConfig.cmake file something like:

include(${CMAKE_CURRENT_LIST_DIR}/FooExports.cmake)
set(FOO_INCLUDE_DIR ${FooExports_IMPORT_PREFIX}/include )

Related to this, why is this location computed in the configuration-specific 
file, and not once in the "parent" exports-file, which includes all the 
export-files for the different configurations ?
The files which will be included are collected with this call:
FILE(GLOB CONFIG_FILES "${_DIR}/BarTargets-*.cmake")

I.e. it is guaranteed that they are all in the same directory as the including 
file.
Doesn't that mean that they are also in the same directory relative to their 
respective install prefix ?

If so, would it be ok if I move the code for calculating the IMPORT_PREFIX 
into the "parent" exports file ?

Or should I add basically the same code in the generated "parent" exports-file 
?

Alex
_______________________________________________
cmake-developers mailing list
cmake-developers@cmake.org
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to