conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.97k stars 952 forks source link

[bug] CMAKE_SYSTEM_NAME is set to Macos instead of Darwin when settings.os = Macos #7694

Closed Erlkoenig90 closed 3 years ago

Erlkoenig90 commented 3 years ago

Environment Details

Steps to reproduce

Install osxcross on Linux, create a profile with os=Macos and attempt to build a CMake-based package such as glfw.

Logs

CMake complains that it doesn't know CMAKE_SYSTEM_NAME=Macos:

glfw/3.3.2: Copying sources to build folder
glfw/3.3.2: Building your package in /home/niklas.guertler/.conan/data/glfw/3.3.2/_/_/build/0c813457898f15d49f81cdfc3b93cb779967df65
glfw/3.3.2: Generator cmake created conanbuildinfo.cmake
glfw/3.3.2: Calling build()
-- The C compiler identification is Clang 10.0.0
System is unknown to cmake, create:
Platform/Macos to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working C compiler: /home/niklas.guertler/programs/osxcross/target/bin/x86_64-apple-darwin19-clang
System is unknown to cmake, create:
Platform/Macos to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working C compiler: /home/niklas.guertler/programs/osxcross/target/bin/x86_64-apple-darwin19-clang -- works
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/Macos to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
System is unknown to cmake, create:
Platform/Macos to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
System is unknown to cmake, create:
Platform/Macos to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
CMake Error at CMakeLists.txt:152 (message):
  No supported platform was detected

I'd suggest translating the settins.os value Macos to Darwin in the cmake_flags.py file like this:

definitions["CMAKE_SYSTEM_NAME"] = {"Macos": "Darwin",
    "iOS": "Darwin",
    "tvOS": "Darwin",
    "watchOS": "Darwin",
    "Neutrino": "QNX"}.get(os_, os_)
jgsogo commented 3 years ago

Thanks... yes, I think that change is needed. I didn't know about osxcross, probably an interesting project to try some cross-building approaches in a Mac machine.

Have you tried other recipes from ConanCenter? Are most of them working out-of-the-box?


... and thanks for the PR!

Erlkoenig90 commented 3 years ago

Yes osxcross is awesome, it allows you to e.g. build Mac OS applications on Linux CI servers. Some packages like volk or openssl work OOTB. libwebp and glfw both need this patch to compile because they use CMake. Unfortunately some other packages (like fribidi, dependency of pango) don't work yet because they use Meson and cross-compiling via conan+meson isn't implemented (#4529).

jgsogo commented 3 years ago

We are trying to provide better integration with Meson (https://github.com/conan-io/conan/pull/7662), but we also need Meson to stabilize a little bit as seen in that PR. Too many things, step by step 😃

memsharded commented 3 years ago

7695, this will be released in Conan 1.30