Closed jasal82 closed 4 years ago
Just to be sure are you suggesting?
if cross_building(self._conanfile): # We are cross building
if os_ != os_build:
if os_: # the_os is the host (regular setting)
definitions["CMAKE_SYSTEM_NAME"] = {"Macos": "Darwin",
"iOS": "Darwin",
"tvOS": "Darwin",
"watchOS": "Darwin",
"Neutrino": "QNX"}.get(os_, os_)
else:
definitions["CMAKE_SYSTEM_NAME"] = "Generic"
else:
definitions["CMAKE_SYSTEM_NAME"] = "Generic"
Or why not something like:
if cross_building(self._conanfile): # We are cross building
if os_ != os_build and arch != arch_build:
if os_: # the_os is the host (regular setting)
definitions["CMAKE_SYSTEM_NAME"] = {"Macos": "Darwin",
"iOS": "Darwin",
"tvOS": "Darwin",
"watchOS": "Darwin",
"Neutrino": "QNX"}.get(os_, os_)
else:
definitions["CMAKE_SYSTEM_NAME"] = "Generic"
It seems that CMAKE_SYSTEM_NAME should not be set unless you are cross-building, so I would say the second.
Ah I'm sorry, that was wrong. What I meant was
if cross_building(self._conanfile): # We are cross building
if os_ != os_build:
if os_: # the_os is the host (regular setting)
definitions["CMAKE_SYSTEM_NAME"] = {"Macos": "Darwin",
"iOS": "Darwin",
"tvOS": "Darwin",
"watchOS": "Darwin",
"Neutrino": "QNX"}.get(os_, os_)
else:
definitions["CMAKE_SYSTEM_NAME"] = "Generic"
else:
definitions["CMAKE_SYSTEM_NAME"] = "Generic"
I'll fix the description. I'd say that the solution with if os_ != os_build or arch != arch_build
would technically be the same because that's probably what cross_building()
is checking for, isn't it?
Ok, that makes more sense, indeed. Pushed review.
Hi, @jasal82
According to CMake docs, cross-compiling to Linux ARM
should use set(CMAKE_SYSTEM_NAME Linux)
, why are you suggesting to assign Generic
to it? According to this link, using Generic
is basically a way to avoid a warning (or not to use the CMake distributed files).
@jgsogo If you can set Linux
, even better, but it doesn't matter for my specific problem because any value in CMAKE_SYSTEM_NAME
will enable the cross-compilation logic in CMake. In the current state it is completely broken, so I was suggesting the minimal viable fix. Feel free to adjust. The correct approach would probably be to map the value of os_
to the available CMake platform names.
Thanks for the answer, I was confused about it. 👍
1.30.1
. It will add the CMAKE_SYSTEM_NAME
when cross-compiling to arm
using a Linux
machine to build.Thanks for reporting the issue.
Conan has an auto-detection feature for
CMAKE_SYSTEM_NAME
which is enabled by default if a value is not set explicitly. I found the method_cmake_cross_build_defines()
inCMakeDefinitionsBuilder
which seems to perform that auto-detection:So if
os_ == os_build
the variable is never set which is clearly wrong. A typical cross-toolchain for arm would haveos = Linux
andos_build = Linux
butarch
andarch_build
are different. My suggestion would be to add anotherelse:
block on theif os_ != os_build
level that also setsCMAKE_SYSTEM_NAME
toGeneric
.