Skip to content
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

Don't set NO_CMAKE_FIND_ROOT_PATH in find_xxx #379

Closed
herbrechtsmeier opened this issue Mar 12, 2013 · 7 comments
Closed

Don't set NO_CMAKE_FIND_ROOT_PATH in find_xxx #379

herbrechtsmeier opened this issue Mar 12, 2013 · 7 comments
Labels

Comments

@herbrechtsmeier
Copy link

Don't set NO_CMAKE_FIND_ROOT_PATH in find_xxx functions to enable the cross compiler to set the system roots to the target system root and host system root. Additionally don't assume that the CMAKE_PREFIX_PATH contains absolute paths (IS_DIRECTORY) as they are relative to a system root.

@herbrechtsmeier
Copy link
Author

At the moment you have to set CMAKE_PREFIX_PATH to the absolute path (/path/to/machine/sysroot/path/to/ros;/path/to/native/sysroot/path/to/ros) but normally it should only contain the local prefix (/path/to/ros) and the system root paths (/path/to/machine/sysroot; /path/to/native/sysroot) are passed via CMAKE_FIND_ROOT_PATH. This allows the cross compiler framework to install cross compiled libraries and headers into the machine system root and binaries and scripts into the native system root. Additionally the cross compiler framework installs the CMake files into the correspondent system root.

@tfoote
Copy link
Member

tfoote commented Mar 14, 2013

Can you point to docs that we can read more about the best practices?

On Wed, Mar 13, 2013 at 3:43 AM, herbrechtsmeier
[email protected]:

At the moment you have to set CMAKE_PREFIX_PATH to the absolute path
(/path/to/machine/sysroot/path/to/ros;/path/to/native/sysroot/path/to/ros)
but normally it should only contain the local prefix (/path/to/ros) and the
system root paths (/path/to/machine/sysroot; /path/to/native/sysroot) are
passed via CMAKE_FIND_ROOT_PATH. This allows the cross compiler framework
to install cross compiled libraries and headers into the machine system
root and binaries and scripts into the native system root. Additionally the
cross compiler framework installs the CMake files into the correspondent
system root.


Reply to this email directly or view it on GitHubhttps://github.com//issues/379#issuecomment-14834546
.

@herbrechtsmeier
Copy link
Author

At first you could take a look at the http://www.vtk.org/Wiki/CMake_Cross_Compiling but OpenEmbedded (Yocto) have simplify the usage of executables in the build process. They first build all buildtool_depends as native version and install them into a native sysroot. As next they cross compile all depends and install all header, libraries and CMake files into the cross sysroot. The native sysroot is append to the cross sysroot in the CMAKE_FIND_ROOT_PATH and CMAKE_FIND_ROOT_PATH_MODE_PROGRAM is set to ONLY. This allows the find_program function to find the native programs in the native sysroot. I will try to find a documentation about the OpenEmbedded internals.

@herbrechtsmeier
Copy link
Author

@tfoote This is the common cmake configuration of yocto: http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/cmake.bbclass

@herbrechtsmeier
Copy link
Author

All paths in the CMake files should be generated by the find_xxx macro and don't set NO_CMAKE_FIND_ROOT_PATH outside of the develspace. This allows the CMake files to work with different DESTDIR (sysroots) for programs and libraries.

pkgConfig.cmake.in:

if(@DEVELSPACE@)
  set(CATKIN_FIND_ROOT_PATH_MODE NO_CMAKE_FIND_ROOT_PATH)
else()
  set(CATKIN_FIND_ROOT_PATH_MODE "")
endif()

Example (genpy-extras.cmake.em):

-set(GENMSG_PY_BIN ${GENPY_BIN_DIR}/genmsg_py.py)
+find_program(GENMSG_PY_BIN genmsg_py.py PATHS ${GENPY_BIN_DIR} NO_DEFAULT_PATH @(CATKIN_FIND_ROOT_PATH_MODE))

@dirk-thomas
Copy link
Member

Most other packages in ROS (e.g. genmsg, gencpp, etc.) explicitly don't use find_* but expose the known paths of their files using variables defined in their CMake extra files. That seems to me much more stable and addresses all the use cases defined so far.

By now catkin generates output which should be completely relocatable and supports using DESTDIR during (isolated) compilation. Is there any other specific use case which currently does not work?

@dirk-thomas
Copy link
Member

Without any specific feedback this can not be acted on. I will close it for now and mark it "wontfix". Please feel free to provide further information and the ticket might be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants