# How to use host tools using find\_package when cross-compiling (eg. Qt5LinguistTools)

**URL:** https://discourse.cmake.org/t/how-to-use-host-tools-using-find-package-when-cross-compiling-eg-qt5linguisttools/4224
**Category:** Usage
**Tags:** os:linux
**Created:** [October 7, 2021, 7:40pm UTC](https://discourse.cmake.org/t/how-to-use-host-tools-using-find-package-when-cross-compiling-eg-qt5linguisttools/4224 "2021-10-07T19:40:18Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![amurzeau](https://discourse.cmake.org/user_avatar/discourse.cmake.org/amurzeau/32/1859_2.png) [@amurzeau](https://discourse.cmake.org/u/amurzeau)
#### Post date: [October 10, 2021, 9:26pm UTC](https://discourse.cmake.org/t/how-to-use-host-tools-using-find-package-when-cross-compiling-eg-qt5linguisttools/4224/3 "2021-10-10T21:26:22Z")

</div>

The issue is that the Qt5LinguistTools package provides functions like `qt_add_translation`.

So the proposed solution would be to this ?

- Add a package in the project for example in `cmake/Qt5LinguistHostTools.cmake`
- In this file, use find\_program to find host tools (`lrelease` and `lupdate` programs)
- In this file, implement the `qt_add_translation` macro that uses host tools with the same behavior as the original `/usr/lib/x86_64-linux-gnu/cmake/Qt5LinguistTools/Qt5LinguistToolsMacros.cmake`

Currently, I’m doing this (join is a function that concat all glob results):  
`CMAKE_PREFIX_PATH="/usr/lib/cmake;$(join ';' /usr/{lib/$(gcc -print-multiarch),lib*,share}/cmake)"`

to match the find\_package [documentation](https://cmake.org/cmake/help/v3.16/command/find_package.html#search-procedure) where it is said to search paths matching this:

```auto
<prefix>/(lib/<arch>|lib*|share)/cmake/<name>*/
<prefix>/(lib/<arch>|lib*|share)/<name>*/
<prefix>/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/

```

To me this bash solution seems to be less maintenance as I don’t need to maintain a copy of Qt’s cmake macros like qt\_add\_translation (but requires bash …)

---

_[View the full topic](https://discourse.cmake.org/t/how-to-use-host-tools-using-find-package-when-cross-compiling-eg-qt5linguisttools/4224)._
