conan-io / cmake-conan

CMake wrapper for conan C and C++ package manager
MIT License
824 stars 250 forks source link

Raspbian - Apt package manager selects wrong architecture #675

Closed DevAGCO closed 5 days ago

DevAGCO commented 6 days ago

Trying to consume a package on Raspbian, but it seems that the architecture is not forwarded properly. When an apt package has to be installed, it tries to install the amd64 version instead of armhf. E.g. dpkg-query: no packages found matching libx11-dev:amd64

I think you will be able to reproduce/understand this issue. But if not, I'll be happy to provide more details on my setup.

auto-detected profile:

[settings]
arch=armv8
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=10
os=Linux
memsharded commented 6 days ago

Hi @DevAGCO

Thanks for your report.

The main error would be that the detected profile is not correct? What arch it should be?

Also, can you please report on what CMAKE_SYSTEM_PROCESSOR would CMake report on a CMakeLists.txt built in that Raspbian?

DevAGCO commented 6 days ago

I'm not sure the issue is about the detected profile. More about which architecture the Apt manager will select. These are the options for apt:

In this case the Apt Manager tries to download "amd64" packages, instead of "arm64" or "armhf".

As for your question: CMAKE_SYSTEM_PROCESSOR = x86_64

memsharded commented 6 days ago

CMAKE_SYSTEM_PROCESSOR = x86_64

In the raspbian? something seems off, the code is:

if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "")
        set(host_arch ${CMAKE_OSX_ARCHITECTURES})
    elseif(MSVC)
        set(host_arch ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID})
    else()
        set(host_arch ${CMAKE_SYSTEM_PROCESSOR})
    endif()
    if(host_arch MATCHES "aarch64|arm64|ARM64")
        set(_arch armv8)
    elseif(host_arch MATCHES "armv7|armv7-a|armv7l|ARMV7")
        set(_arch armv7)
    elseif(host_arch MATCHES armv7s)
        set(_arch armv7s)
    elseif(host_arch MATCHES "i686|i386|X86")
        set(_arch x86)
    elseif(host_arch MATCHES "AMD64|amd64|x86_64|x64")
        set(_arch x86_64)
    endif()

So for cmake-conan to detect the armv8 architecture that you reported above, this doesn't seem possible.

Are you sure you are passing the right toolchain to cmake ... invocation? The auto-detected profile above is the Conan one? Because that one wouldn't be valid, with cmake-conan the important one is the one that CMake detects, and that depends on the CMake toolchain you use.

DevAGCO commented 5 days ago

You are right. That doesn't make sense. And yes somehow the wrong toolchain file had slipped into the build.

It's working as expected now! Sorry for using your time on an unrelated issue. But a big thanks anyway! :)

memsharded commented 5 days ago

No prob, happy to help! 🙂

So I am closing the ticket as solved then, but don't hesitate to open new tickets if necessary. Thanks for the feedback!