# Building Compile-time Tools When Cross-compiling

**URL:** https://discourse.cmake.org/t/building-compile-time-tools-when-cross-compiling/601
**Category:** Usage
**Created:** [February 7, 2020, 6:28pm UTC](https://discourse.cmake.org/t/building-compile-time-tools-when-cross-compiling/601 "2020-02-07T18:28:49Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 16, 2020, 12:55am UTC](https://discourse.cmake.org/t/building-compile-time-tools-when-cross-compiling/601/5 "2020-02-16T00:55:51Z")

</div>

VTK handles it this way:

- Create an option which makes just the tools used on the host during a build ([https://gitlab.kitware.com/vtk/vtk/blob/a5f938b2fdfefa522439065e040cb42f65d88444/CMakeLists.txt#L231](https://gitlab.kitware.com/vtk/vtk/blob/a5f938b2fdfefa522439065e040cb42f65d88444/CMakeLists.txt#L231)) and install a package with a different namespace than normal builds
- If cross compiling without an emulator, require that host tools package ([https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtkCrossCompiling.cmake](https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtkCrossCompiling.cmake))
- If the host tools are found, use them in the `add_custom_command` call ([https://gitlab.kitware.com/vtk/vtk/blob/a5f938b2fdfefa522439065e040cb42f65d88444/CMake/vtkModule.cmake#L3047](https://gitlab.kitware.com/vtk/vtk/blob/a5f938b2fdfefa522439065e040cb42f65d88444/CMake/vtkModule.cmake#L3047)), using `CMAKE_CROSSCOMPILING_EMULATOR` if available

---

_[View the full topic](https://discourse.cmake.org/t/building-compile-time-tools-when-cross-compiling/601)._
