<div>Hi,<br></div><div>I have created cmake target, say <code>A</code>, and want to install it and create a Config file, so that the installed package could be relocatable. My code is:<br></div><div><br></div><pre><code>install(EXPORT ${PROJECT_NAME}Targets
    FILE ${PROJECT_NAME}Targets.cmake
    NAMESPACE ${PROJECT_NAME}::
    DESTINATION ??? )</code><br></pre><div><code>Here, I am having a problem with the proper destination. I want the Config file to be installed where <code>${CMAKE_INSTALL_PREFIX}</code> points to. But when I put <code>${CMAKE_INSTALL_PREFIX}</code> at <code>???</code>, my resulting <code>ATargets.cmake</code> file contains the line:</code><br></div><div><br></div><pre><code>set(_IMPORT_PREFIX "C:/Libraries/...")</code><br></pre><p>which is the actual value of <code>${CMAKE_INSTALL_PREFIX}</code>. This <code>_IMPORT_PREFIX</code> is later prepended to the parameters of <code>set_target_properties()</code> command inside the auto-generated <code>ATargets.cmake</code>, resulting in hard coded paths, valid only on the installation system.<br></p><p>I tried to use some generator expressions like <code><$IMPORT_PREFIX></code> in place of <code>???</code>, but this gave me an error at cmake generation. I also tried to omit <code>DESTINATION</code> which in my opinion should place the file in the location relative to <code>${CMAKE_INSTALL_PREFIX}</code>, but cmake complained about it too.<br></p><div>I
 got a suggesion on StackOverflow to use . (a dot) as my DESTINATION. 
This worked partially, in the way that I no longer have absolute 
_IMPORT_PREFIX. Unfortunately, the produced paths are still invalid: The
 generated ATargets.cmake contains:<br></div><div><br></div><div>get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)<br></div><div>get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)<br></div><div><br></div><div>and the second line above is not necessary, it trims the path too much by one folder.<br></div><div><br></div><div>Do you have any ideas how to solve it?<br></div><div><br></div><div>Best regards,<br></div><div>Piotr<br></div>