CMake relocation / cross compile support is broken
The current CMake implementation doesn’t support cross compile via Yocto. CMake supports the relocation of its installation by default. The generated CMake build files breaks this feature because they contaminate the CMake targets with absolute paths. The find package modules should provide targets to forward the include directories and libraries to the CMake build targets. The CMake build targets should use these imported targets and the CMake package config should call find package on all required external libraries to provide all needed targets.
- Create imported libraries in ‘Find$(use.project:c).cmake’ files
- Add ‘find_package($(use.project) REQUIRED)’ calls for all ‘use’ items to the ‘Config.cmake.in’ file guarded by ‘@$(PROJECT.PREFIX)WITH$(USE.PROJECT)@’ if ‘use.optional’ is not 0
- Use targets inside OPTIONAL_LIBRARIES variable
Could you please send a PR to fix it?
@bluca Could we update CMake minimum required version to 3.6 or higher? Many distributions have a higher version as 3.6. This version will allow use to use the IMPORTED_TARGET argument of pkg_check_modules to create a target per dependency.
that's quite a big jump from 2.8 - can it be made optional by checking which version of cmake is being used? Then users with old versions won't have support removed
The list of not supported distributions between 3.0 and 3.5 isn't that big. The 3.6 is a problem and CentOS is restricted to 2.8.12.
We have to check the code from the FindPkgConfig module and try to backport it.
couldn't there simply be a check for the CMAKE version to use that feature? if it's new enough use it, if not don't
Do you mean we should fix the issue only for newer CMake versions and otherwise fall back to the current behaviour?
Yes - the problem in Yocto will be fixed, and we avoid breaking compatibility with CentOS/RHEL