Skip to content

Conversation

hyyoxhk
Copy link

@hyyoxhk hyyoxhk commented Sep 24, 2025

Building fcitx5-qt () in Yocto/OpenEmbedded failed during the do_configre step due to search-time path handling. The generated install interfaces used non-absolute include paths, and LIBDATADIR resolution conflicted with DESTDIR/sysroot staging.

This patch ensures installed targets expose absolute include directories in their INTERFACE properties.
In the top-level CMakeLists.txt, set the default for CMAKE_INSTALL_LIBDATADIR to ${CMAKE_INSTALL_LIBDIR} (non-full), and then let GNUInstallDirs_get_absolute_install_dir compute the absolute CMAKE_INSTALL_FULL_LIBDATADIR. This avoids double-prefix issues under DESTDIR.

Rationale: Yocto relocates installs into a staged sysroot, and absolute include directories in installed target interfaces avoid incorrect or non-relocatable paths. Deferring LIBDATADIR to the non-full variant prevents incorrect path composition when the absolute path is computed later, fixing the do_configure error.

Impact: No behavior change for standard builds. Fixes installation in Yocto/OE environments; aligns with common CMake packaging practices for exported targets.

Motivation: This fix was made because software that depends on fcitx5 failing to do_configure in Yocto.

@wengxt
Copy link
Member

wengxt commented Sep 24, 2025

@hyyoxhk can you provide log?

@hyyoxhk hyyoxhk changed the title cmake: fix install interface include dirs and libdatadir to resolve Yocto do_install failure CMake: Fix LIBDATADIR default and use FULL_INCLUDEDIR for installed targets Sep 25, 2025
@hyyoxhk
Copy link
Author

hyyoxhk commented Sep 25, 2025

Sorry for the unclear description, I revised the title and content

here is the log for building fcitx5-qt in yocto

ERROR: fcitx5-qt-5.1.5-r0 do_configure: ExecutionError('/home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/temp/run.do_configure.4176167', 1, None, None)
ERROR: Logfile of failure stored in: /home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/temp/log.do_configure.4176167
Log data follows:
| DEBUG: Executing python function extend_recipe_sysroot
| NOTE: Direct dependencies are ['/home/complile/ymsbcrk3588/yocto_kernel5/layers/meta-fcitx5/recipes-support/extra-cmake-modules/extra-cmake-modules_5.103.0.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/meta-fcitx5/recipes-support/fcitx5/fcitx5_5.0.17.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/meta-qt5/recipes-qt/qt5/qtbase-native_git.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/meta-qt5/recipes-qt/qt5/qtbase_git.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-core/gettext/gettext_0.21.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-core/glibc/glibc_2.35.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-devtools/cmake/cmake-native_3.22.3.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-devtools/gcc/gcc-cross_11.4.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-devtools/gcc/gcc-runtime_11.4.bb:do_populate_sysroot', '/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-devtools/quilt/quilt-native_0.67.bb:do_populate_sysroot', 'virtual:native:/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-core/gettext/gettext_0.21.bb:do_populate_sysroot', 'virtual:native:/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-devtools/ninja/ninja_1.10.2.bb:do_populate_sysroot', 'virtual:native:/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-devtools/patch/patch_2.7.6.bb:do_populate_sysroot', 'virtual:native:/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot', 'virtual:native:/home/complile/ymsbcrk3588/yocto_kernel5/layers/poky/meta/recipes-extended/xz/xz_5.2.6.bb:do_populate_sysroot']
| NOTE: Installed into sysroot: []
| NOTE: Skipping as already exists in sysroot: ['extra-cmake-modules', 'fcitx5', 'qtbase-native', 'qtbase', 'gettext', 'glibc', 'cmake-native', 'gcc-cross-aarch64', 'gcc-runtime', 'quilt-native', 'gettext-native', 'ninja-native', 'patch-native', 'pseudo-native', 'xz-native', 'zlib-native', 'dbus-native', 'wayland', 'iso-codes', 'gdk-pixbuf', 'dbus', 'enchant2', 'cairo', 'wayland-protocols', 'xkeyboard-config', 'fmt', 'json-c', 'systemd', 'util-linux-libuuid', 'pango', 'libxkbcommon', 'libcroco', 'glib-2.0', 'libxml2', 'libtool-native', 'attr-native', 'ncurses-native', 'bzip2-native', 'zstd-native', 'curl-native', 'linux-libc-headers', 'libgcc', 'openssl', 'rockchip-libmali', 'rockchip-librga', 'vulkan-headers', 'libpcre2', 'libinput', 'freetype', 'libpng', 'libdrm', 'fontconfig', 'sqlite3', 'libjpeg-turbo', 'zlib', 'cups', 're2c-native', 'gettext-minimal-native', 'texinfo-dummy-native', 'gnu-config-native', 'libmpc-native', 'gmp-native', 'binutils-cross-aarch64', 'flex-native', 'mpfr-native', 'glib-2.0-native', 'expat-native', 'libffi', 'expat', 'shared-mime-info', 'gobject-introspection', 'base-passwd', 'shadow', 'shadow-sysroot', 'autoconf-archive', 'base-files', 'shadow-native', 'aspell', 'pixman', 'opkg-utils', 'util-macros', 'zstd', 'libcap', 'acl', 'util-linux', 'kmod', 'libpam', 'bash-completion', 'fribidi', 'harfbuzz', 'libpcre', 'python3', 'openssl-native', 'bzip2', 'mtdev', 'libcheck', 'libevdev', 'libpciaccess', 'libpthread-stubs', 'avahi', 'libusb1', 'm4-native', 'python3-native', 'libffi-native', 'libpcre-native', 'util-linux-native', 'attr', 'libxcrypt', 'ncurses', 'libcap-ng', 'xz', 'cracklib', 'flex', 'icu', 'readline', 'libnsl2', 'gdbm', 'libtirpc', 'perl-native', 'libdaemon', 'sqlite3-native', 'libnsl2-native', 'readline-native', 'util-linux-libuuid-native', 'libtirpc-native', 'gdbm-native', 'libpcre2-native', 'libcap-ng-native', 'make-native']
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_configure
| -- The C compiler identification is GNU 11.4.0
| -- The CXX compiler identification is GNU 11.4.0
| -- Detecting C compiler ABI info
| -- Detecting C compiler ABI info - done
| -- Check for working C compiler: /home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/recipe-sysroot-native/usr/bin/aarch64-smart-linux/aarch64-smart-linux-gcc - skipped
| -- Detecting C compile features
| -- Detecting C compile features - done
| -- Detecting CXX compiler ABI info
| -- Detecting CXX compiler ABI info - done
| -- Check for working CXX compiler: /home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/recipe-sysroot-native/usr/bin/aarch64-smart-linux/aarch64-smart-linux-g++ - skipped
| -- Detecting CXX compile features
| -- Detecting CXX compile features - done
| -- Found XKBCommon_XKBCommon: /home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/recipe-sysroot/usr/lib/libxkbcommon.so (found version "")
| -- Found XKBCommon: /home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/recipe-sysroot/usr/lib/libxkbcommon.so (Required is at least version "0.5.0") found components: XKBCommon
| -- Installing in the same prefix as Fcitx, adopting their path scheme by default
| -- Found Gettext: /home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/recipe-sysroot-native/usr/bin/msgmerge (found version "0.21")
| -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
| -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
| -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
| -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
| -- Performing Test COMPILER_HAS_DEPRECATED_ATTR
| -- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
| -- The following REQUIRED packages have been found:
| 
|  * ECM (required version >= 1.4.0)
|  * XKBCommon (required version >= 0.5.0), Keyboard handling library using XKB data, <http://xkbcommon.org>
|  * Fcitx5Utils (required version >= 5.0.16)
|  * Gettext
|  * Qt5DBus
|  * Qt5Widgets
|  * Qt5 (required version >= 5.7.0)
|  * Qt5Gui (required version >= 5.7.0)
|  * Qt5Core
|  * Qt5Concurrent
| 
| -- Configuring done
| CMake Error in qt5/guiwrapper/CMakeLists.txt:
|   Imported target "Fcitx5::Utils" includes non-existent path
| 
|     "/usr/include/Fcitx5/Utils"
| 
|   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
| 
|   * The path was deleted, renamed, or moved to another location.
| 
|   * An install or uninstall procedure did not complete successfully.
| 
|   * The installation package was faulty and references files it does not
|   provide.
| 
| 
| 
| CMake Error in qt5/widgetsaddons/CMakeLists.txt:
|   Imported target "Fcitx5::Utils" includes non-existent path
| 
|     "/usr/include/Fcitx5/Utils"
| 
|   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
| 
|   * The path was deleted, renamed, or moved to another location.
| 
|   * An install or uninstall procedure did not complete successfully.
| 
|   * The installation package was faulty and references files it does not
|   provide.
| 
| 
| 
| CMake Error in qt5/quickphrase-editor/CMakeLists.txt:
|   Imported target "Fcitx5::Utils" includes non-existent path
| 
|     "/usr/include/Fcitx5/Utils"
| 
|   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
| 
|   * The path was deleted, renamed, or moved to another location.
| 
|   * An install or uninstall procedure did not complete successfully.
| 
|   * The installation package was faulty and references files it does not
|   provide.
| 
| 
| 
| CMake Error in qt5/guiwrapper/CMakeLists.txt:
|   Imported target "Fcitx5::Utils" includes non-existent path
| 
|     "/usr/include/Fcitx5/Utils"
| 
|   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
| 
|   * The path was deleted, renamed, or moved to another location.
| 
|   * An install or uninstall procedure did not complete successfully.
| 
|   * The installation package was faulty and references files it does not
|   provide.
| 
| 
| 
| CMake Error in qt5/widgetsaddons/CMakeLists.txt:
|   Imported target "Fcitx5::Utils" includes non-existent path
| 
|     "/usr/include/Fcitx5/Utils"
| 
|   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
| 
|   * The path was deleted, renamed, or moved to another location.
| 
|   * An install or uninstall procedure did not complete successfully.
| 
|   * The installation package was faulty and references files it does not
|   provide.
| 
| 
| 
| CMake Error in qt5/quickphrase-editor/CMakeLists.txt:
|   Imported target "Fcitx5::Utils" includes non-existent path
| 
|     "/usr/include/Fcitx5/Utils"
| 
|   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
| 
|   * The path was deleted, renamed, or moved to another location.
| 
|   * An install or uninstall procedure did not complete successfully.
| 
|   * The installation package was faulty and references files it does not
|   provide.
| 
| 
| 
| -- Generating done
| CMake Warning:
|   Manually-specified variables were not used by the project:
| 
|     CMAKE_EXPORT_NO_PACKAGE_REGISTRY
|     FETCHCONTENT_FULLY_DISCONNECTED
|     LIB_SUFFIX
|     OE_QMAKE_PATH_ARCHDATA
|     OE_QMAKE_PATH_BINS
|     OE_QMAKE_PATH_DATA
|     OE_QMAKE_PATH_DOCS
|     OE_QMAKE_PATH_EXAMPLES
|     OE_QMAKE_PATH_HEADERS
|     OE_QMAKE_PATH_HOST_BINS
|     OE_QMAKE_PATH_HOST_DATA
|     OE_QMAKE_PATH_HOST_LIBS
|     OE_QMAKE_PATH_HOST_PREFIX
|     OE_QMAKE_PATH_LIBEXECS
|     OE_QMAKE_PATH_LIBS
|     OE_QMAKE_PATH_PLUGINS
|     OE_QMAKE_PATH_PREFIX
|     OE_QMAKE_PATH_QML
|     OE_QMAKE_PATH_QT_ARCHDATA
|     OE_QMAKE_PATH_QT_BINS
|     OE_QMAKE_PATH_QT_DATA
|     OE_QMAKE_PATH_QT_DOCS
|     OE_QMAKE_PATH_QT_EXAMPLES
|     OE_QMAKE_PATH_QT_HEADERS
|     OE_QMAKE_PATH_QT_SETTINGS
|     OE_QMAKE_PATH_QT_TESTS
|     OE_QMAKE_PATH_QT_TRANSLATIONS
|     OE_QMAKE_PATH_SETTINGS
|     OE_QMAKE_PATH_TESTS
|     OE_QMAKE_PATH_TRANSLATIONS
|     PYTHON_EXECUTABLE
|     Python3_EXECUTABLE
|     Python_EXECUTABLE
| 
| 
| CMake Generate step failed.  Build files cannot be regenerated correctly.
| WARNING: exit code 1 from a shell command.
ERROR: Task (/home/complile/ymsbcrk3588/yocto_kernel5/layers/meta-fcitx5/recipes-support/fcitx5-qt/fcitx5-qt_5.1.5.bb:do_configure) failed with exit code '1'

patch-1 fixed this bug

patch-2 fixes the problem that I cannot find FCITX_INSTALL_LIBDATADIR correctly in the board

cat /usr/lib/cmake/Fcitx5Utils/Fcitx5UtilsConfig.cmake

...
if (FCITX_INSTALL_USE_FCITX_SYS_PATHS)
    set(FCITX_INSTALL_PREFIX "/usr")
    set(FCITX_INSTALL_INCLUDEDIR "/usr/include")
    set(FCITX_INSTALL_LIBDIR "/usr/lib")
    set(FCITX_INSTALL_LIBDATADIR "/home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5/5.0.17-r0/fcitx5-5.0.17/lib")
    set(FCITX_INSTALL_LIBEXECDIR "/usr/libexec")
    set(FCITX_INSTALL_DATADIR "/usr/share")
...

@wengxt
Copy link
Member

wengxt commented Sep 26, 2025

Ok, what you really want to do is:

  1. when build, the install prefix=/prefix/a
  2. but you install it to prefix=/prefix/b with whatever mechanism e.g. DESTDIR=/...

The reason that you need to do this is you want to cross compile or whatever, the final install prefix will be /prefix/a, but you have to build it under a different prefix

@hyyoxhk
Copy link
Author

hyyoxhk commented Sep 26, 2025

Ok, what you really want to do is:

  1. when build, the install prefix=/prefix/a
  2. but you install it to prefix=/prefix/b with whatever mechanism e.g. DESTDIR=/...

The reason that you need to do this is you want to cross compile or whatever, the final install prefix will be /prefix/a, but you have to build it under a different prefix

Yes, that's it.

@wengxt
Copy link
Member

wengxt commented Sep 30, 2025

I can't reproduce the double path thing for libdatadir. What's the exact parameter you used?

And also, the first thing you hit isn't "couldn't find Fcitx5CompilerSettings?" how did you avoid that? I have my own solution here but I wonder if you have already done anything?

@hyyoxhk
Copy link
Author

hyyoxhk commented Sep 30, 2025

I can't reproduce the double path thing for libdatadir. What's the exact parameter you used?

fcitx5's Compilation parameters (from yocto do_configure)
cmake
-G 'Ninja' -DCMAKE_MAKE_PROGRAM=ninja
$oecmake_sitefile
/home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5/5.0.17-r0/fcitx5-5.0.17
-DCMAKE_INSTALL_PREFIX:PATH=/usr
-DCMAKE_INSTALL_BINDIR:PATH=bin
-DCMAKE_INSTALL_SBINDIR:PATH=sbin
-DCMAKE_INSTALL_LIBEXECDIR:PATH=libexec
-DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc
-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=../com
-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=/var
-DCMAKE_INSTALL_LIBDIR:PATH=lib
-DCMAKE_INSTALL_INCLUDEDIR:PATH=include
-DCMAKE_INSTALL_DATAROOTDIR:PATH=share
-DPYTHON_EXECUTABLE:PATH=/usr/bin/python3
-DPython_EXECUTABLE:PATH=/usr/bin/python3
-DPython3_EXECUTABLE:PATH=/usr/bin/python3
-DLIB_SUFFIX=
-DCMAKE_INSTALL_SO_NO_EXE=0
-DCMAKE_TOOLCHAIN_FILE=/home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5/5.0.17-r0/toolchain.cmake
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=1
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
-DFETCHCONTENT_FULLY_DISCONNECTED=ON
-DENABLE_TEST=Off -DENABLE_DBUS=On -DENABLE_EMOJI=Off -DENABLE_ENCHANT=On -DENABLE_KEYBOARD=On -DENABLE_SERVER=On -DUSE_SYSTEMD=On -DENABLE_LIBUUID=On -DENABLE_WAYLAND=On -DENABLE_X11=Off -DENABLE_XDGAUTOSTART=Off
-Wno-dev

fcitx5-qt's Compilation parameters (from yocto do_configure)
cmake
-G 'Ninja' -DCMAKE_MAKE_PROGRAM=ninja
$oecmake_sitefile
/home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/fcitx5-qt-5.1.5
-DCMAKE_INSTALL_PREFIX:PATH=/usr
-DCMAKE_INSTALL_BINDIR:PATH=bin
-DCMAKE_INSTALL_SBINDIR:PATH=sbin
-DCMAKE_INSTALL_LIBEXECDIR:PATH=libexec
-DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc
-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=../com
-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=/var
-DCMAKE_INSTALL_LIBDIR:PATH=lib
-DCMAKE_INSTALL_INCLUDEDIR:PATH=include
-DCMAKE_INSTALL_DATAROOTDIR:PATH=share
-DPYTHON_EXECUTABLE:PATH=/usr/bin/python3
-DPython_EXECUTABLE:PATH=/usr/bin/python3
-DPython3_EXECUTABLE:PATH=/usr/bin/python3
-DLIB_SUFFIX=
-DCMAKE_INSTALL_SO_NO_EXE=0
-DCMAKE_TOOLCHAIN_FILE=/home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/toolchain.cmake
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=1
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
-DFETCHCONTENT_FULLY_DISCONNECTED=ON
-DCMAKE_SYSROOT=/home/complile/ymsbcrk3588/yocto_kernel5/build-ym-sbc-rk3588/tmp-glibc/work/armv8a-smart-linux/fcitx5-qt/5.1.5-r0/recipe-sysroot -DCMAKE_INSTALL_QT5PLUGINDIR=/usr/lib/plugins -DENABLE_QT4=Off -DENABLE_QT5=On -DENABLE_QT6=Off -DENABLE_X11=Off
-Wno-dev

And also, the first thing you hit isn't "couldn't find Fcitx5CompilerSettings?" how did you avoid that? I have my own solution here but I wonder if you have already done anything?

I just add CMAKE_SYSROOT to find additional Fcitx5CompilerSettings.cmake
like this

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,7 +59,7 @@ if (BUILD_ONLY_PLUGIN)
 # Dup a little bit option here.
 include(CompilerSettings)
 else()
-include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
+include("${CMAKE_SYSROOT}${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
 find_package(Gettext REQUIRED)
 endif()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants