# CMake wrongly chooses multiarch architecture

**URL:** https://discourse.cmake.org/t/cmake-wrongly-chooses-multiarch-architecture/2562
**Category:** Usage
**Created:** [January 17, 2021, 4:48pm UTC](https://discourse.cmake.org/t/cmake-wrongly-chooses-multiarch-architecture/2562 "2021-01-17T16:48:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tgq](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/87869e/32.png) [@tgq](https://discourse.cmake.org/u/tgq)
#### Post date: [January 17, 2021, 4:48pm UTC](https://discourse.cmake.org/t/cmake-wrongly-chooses-multiarch-architecture/2562/1 "2021-01-17T16:48:15Z")

</div>

Hello. Despite the information in toolchain file, CMake chooses host libraries instead of the target ones.  
My toolchain looks like that:

```auto
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(triple arm-linux-gnueabihf)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

```

I invoke the configuration command as:

```auto
CC=arm-linux-gnueabihf-gcc-10 CXX=arm-linux-gnueabihf-g++-10 cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$(realpath ../toolchain.cmake)"

```

The process starts, and at some point i see  
`-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1i")`  
which is obviously wrong. I have installed libssl-dev with:  
`sudo apt install libssl-dev:armhf`  
and indeed it lives alongside the host libssl:

```auto
$ find /usr/ -name libcrypto.so
/usr/lib/x86_64-linux-gnu/libcrypto.so
/usr/lib/arm-linux-gnueabihf/libcrypto.so

```

Why is CMake picking the wrong triplet even tho it is explicitly set, and it’s the default compiler triplet? I am a debian user, from what I’ve read CMake is adapted to the way debian multiarch works. Where is a mistake?

---

<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: [January 19, 2021, 7:45pm UTC](https://discourse.cmake.org/t/cmake-wrongly-chooses-multiarch-architecture/2562/2 "2021-01-19T19:45:07Z")

</div>

If you pass `--debug-find` to CMake’s command line, it should tell you why various paths end up being searched.
