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