-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make installed CMake files relocatable #369
Make installed CMake files relocatable #369
Conversation
Signed-off-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
Signed-off-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
How do you think you want to address other files which contain absolute paths i.e. the generated env/setup/_setup_util files in the root of the devel/install space? Do you require all of them to contain relative paths only? |
I disable the env/setup/_setup_util files because I install everything into the system root. At the moment I don't see a reason why they should use relative paths. |
Can you explain a little bit about why you need things to be relocatable? It is standard to cross compile or compile in chroots using DESTDIR and CMAKE_INSTALL_PREFIX, (PREFIX in make style systems. ) Such that everything is referenced to CMAKE_INSTALL_PREFIX, but the installation goes inside DESTDIR before being deployed to a different filesystem. DESTDIR reference: http://www.gnu.org/prep/standards/html_node/DESTDIR.html Using DESTDIR with cmake: http://www.cmake.org/pipermail/cmake/2009-April/029017.html |
The problem is not the installation but the usage of other packages during cross compile. The other packages files (dependencies) are copied from the DESTDIR to a cross compile system root somewhere on the system. Additionally the same package files are copied to the cross compiler toolchain installation directory or the system root on the machine which is /. Therefore all the paths in the files must be relative to the DESTDIR and dynamic prepend with the current system root. In pkg-config you can set the PKG_CONFIG_SYSROOT_DIR to the system root and it update all include and lib paths. In cmake you can use CMAKE_FIND_ROOT_PATH therefore but only if the software don't set NO_CMAKE_FIND_ROOT_PATH and if the software always use find_xxx. So you can always use find_file to find the file in the system root or you can calculate the current path in your projectConfig.cmake and use this in all cmake files. |
NO_CMAKE_FIND_ROOT_PATH was ticketed to be added to support cross compiling here: https://code.ros.org/trac/ros/ticket/2994 I believe this is where the usage started from. @snorridj can you comment on the relevancy? |
If you search files in the source of your project (from your devel space) or in the devel space itself you have to use NO_CMAKE_FIND_ROOT_PATH. |
The second use case could be avoid when you add the the devel spaces to the CMAKE_FIND_ROOT_PATH. This have the advantage that you have full control over the usage of the devel spaces and you could deactivated the local devel space of the current compiled package. |
I have open ros/catkin:379 and ros/catkin:380 to discuss the other topics there. Back to the main topic of this issue what argues again adding a dynamic calculated @PROJECT_NAME@_EXTRAS_DIR to the @PROJECT_NAME@Config.cmake and use this as base for all local extra files. The files in the source directory could be passed via absolute path. |
That is a good idea. I can look into making the necessary changes to pass some of the cmake files with absolute paths and some with relative paths. That way we should be able to achieve the original goal of making the installed files relocatable. |
…o make the generated code relocatable (#369)
@herbrechtsmeier Can you please test the branch |
@dirk-thomas It works as expected. |
Thank you for your patch. Closing in favor of modified version in #385. |
@dirk-thomas Does a dynamic variable exists which points to the data directory (@PROJECT_NAME@_DIR/..)? The path in the pkg-msg-paths.cmake.in need to be updated to the current absolute path. |
@PROJECT_NAME@_DIR is set when you do a find_package() call. There is no generic variable which points to the parent folder. Can you please clarify what you mean with "pkg-msg-paths.cmake.in need to be updated"? |
modify extra file handling to reference them relatively if possible to make the generated code relocatable (#369)
At the moment genmsg save the path to the msg directory in the
|
First the assumption that the root of a package is one level above pkgname_DIR is not very safe. |
The cmake path and msg path have both the same prefix ( Maybe I shouldn't use the words relative and absolute in this context. The path in the current |
The local version was replaced by a solution from a catkin maintainer. Signed-off-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
This pull request makes the installed CMake files relocatable. This function is needed to cross compiling ros via yocto project. It adds @PROJECT_NAME@_EXTRAS_DIR to the pkgConfig.cmake.in and set it to the CMAKE_CURRENT_LIST_DIR. This directory is used to include the PKG_CFG_EXTRAS files.