# Exporting a CTest Project

**URL:** https://discourse.cmake.org/t/exporting-a-ctest-project/10468
**Category:** Usage
**Tags:** tool:ctest
**Created:** [March 25, 2024, 9:42am UTC](https://discourse.cmake.org/t/exporting-a-ctest-project/10468 "2024-03-25T09:42:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![KUGA2](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kuga2/32/4968_2.png) [@KUGA2](https://discourse.cmake.org/u/KUGA2)
#### Post date: [March 25, 2024, 9:42am UTC](https://discourse.cmake.org/t/exporting-a-ctest-project/10468/1 "2024-03-25T09:42:53Z")

</div>

Hi,

I have the following use case:

- Multiarch product (x64, arm64)
- Testcases that need to run on real arch cpus (QEMU fails)
- arm cpus are sparse

Therefore we build both on x64 with cross compiler. We execute the x64 unit tests directly and the arm64 ones later in a separate step.  
We duplicate all add\_test()/ set\_tests\_properties() settings into a skript that runs on arm64.

We would like to remove that duplication. We could build on arm64, but as I said, we are limited in machines there.

Therefore I want to know if there is a way to export the CMake or CTest configuration to run VTest on the other machine? CMake generated files generally contain absolute paths, so this is not possible (can it be set to use relative paths?) But looking at the CTestTestfile.cmake files, it looks like they are relative (subdirs(…)).  
What would I need for the to CTest-Export to work:

- \*\*/CTestTestfile.cmake
- other CMake generated files for CTest?
- all so/executable files (gladly they are all in one dir as we use CMAKE\_RUNTIME\_OUTPUT\_DIRECTORY etc.)
- Other test resources (like xml files that are parsed during test)

---

<div class="post-metadata">

### Author: ![KUGA2](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kuga2/32/4968_2.png) [@KUGA2](https://discourse.cmake.org/u/KUGA2)
#### Post date: [March 25, 2024, 12:24pm UTC](https://discourse.cmake.org/t/exporting-a-ctest-project/10468/2 "2024-03-25T12:24:02Z")

</div>

I have had a deeper look into the CTestTestfile.cmake files.

The test executable is full path and not relative ☹  
The properties e.g. `ENVIRONMENT`, `WORKING_DIRECTORY` is also full path. However, that is probably the users fault.  
There also is `_BACKTRACE_TRIPLES` with full path to some CMakeLists.txt. This looks like some kind of internal property What is that?

Any Ideas how to solve my use case?

---

<div class="post-metadata">

### Author: ![KUGA2](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kuga2/32/4968_2.png) [@KUGA2](https://discourse.cmake.org/u/KUGA2)
#### Post date: [April 9, 2024, 7:03am UTC](https://discourse.cmake.org/t/exporting-a-ctest-project/10468/3 "2024-04-09T07:03:07Z")

</div>

The solution:  
`ctest [OPTIONS] --show-only=json-v1`

It exports all properties (but not `_BACKTRACE_TRIPLES`) in a way I can read it back. Many paths are still absolute, but I can work around this.

---

<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: [April 11, 2024, 12:59am UTC](https://discourse.cmake.org/t/exporting-a-ctest-project/10468/4 "2024-04-11T00:59:54Z")

</div>

Another solution is to have a project that runs the test suite given an installed package. For example, see [this project](https://gitlab.kitware.com/vtk/vtk/-/tree/master/Testing/External) which runs VTK’s test suite given a `find_package(VTK)`.
