ThePhD / infoware

C++ Library for pulling system and hardware information, without hitting the command line.
Creative Commons Zero v1.0 Universal
410 stars 84 forks source link

Support cross-compiling with MinGW #72

Closed nthirtyone closed 6 months ago

nthirtyone commented 6 months ago

Fixes: #71

Toolchains and everything around them is primarily there to support CI. If you don't want that, changes in _src/system/displays/displayswindows.cpp and CMakeLists.txt:148,171ff are enough to support MinGW.

nabijaczleweli commented 6 months ago

Wait, is pci_generator being compiled for the target and then run via wine? Does CMake really not support compiling build-step generators for the host instead?

nthirtyone commented 6 months ago

Yep, it does not. I can try switching to use ExternalProject hack (for the lack of better term) instead (e.g., vtkiOS.cmake:62-77, tl;dr self import as external project, run entire cmake cycle, and get the binary back to main project), but that would not help get rid off wine entirely, unless we do not run tests for built library.

nabijaczleweli commented 6 months ago

Okay well that kinda fucking sucks, what's the point of CMake. Yes, if you could build the generator for the host through the "hack", that'd be much more palatable; I don't think explicitly supporting running foreign tests is necessary (I'd call it a nice-to-have, and it should probably work with wine as a binfmt?).

nthirtyone commented 6 months ago

It won't work with just binfmt sadly, because Wine does not use MinGW bin directories (or Ubuntu custom paths for runtime) by default and CMake does not propagete environmental variables (e.g., ENV{WINEPATH}) to custom target processes. Alternatives to the current solution with wrapping script are: prepending COMMAND ${CMAKE_COMMAND} -E env ... to custom target (and tests) or offloading all the work to system provided wrappers for toolchains (e.g., i686-w64-mingw-{cmake,wine} commands; Ubuntu does not have such hence, again, own toolchain and wrapper).

nthirtyone commented 6 months ago

Rebase might be done to hastily, I don't know what's your preferred workflow, sorry. I removed wine dependency altogether and switched to use ExternalProject as discussed. The conditions are made to not be MinGW dependent, so naively it should work in other cross-compilation environments, too. The good news is that the jobs are down to sub-30-second times. If we remove MinGW CI jobs, I could remove the toolchains, too. I walked through the changes only once this time, so there might be more clean-up chances I missed.

nabijaczleweli commented 6 months ago

Looks fine, CI passes, works for me on native builds; thanks!

nthirtyone commented 6 months ago

Cheers!