-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable cross-compiling of HogMaker #465
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the motivation behind this PR: HogMaker's target arch is not necessarily the same as the game's target arch. With CMake, you can only ever load a single compiler toolchain at a time in a project, so you've decided to create a separate project for HogMaker that uses a separate toolchain, not cross-compiling this time.
Why not make HogMaker a separate project for all archs, and find it in the top-level CMakeLists? This way, the target is available to all subdirectories, without find_package in each one, and without conditionals for Android.
@Lgt2x ah, from your comments it's clear I needed to add some documentation about the process. When cross-compiling, there have to be two CMake invocations: the first builds HogMaker using the host toolchain (and exports the
So -
That file gets created by the first CMake invocation
correct. we have to export it from this one, so that the android build can subsequently reference it. |
b473f48
to
139e04a
Compare
Conditionals improved and README updated. |
0da903d
to
90224b4
Compare
ping @Lgt2x for re-review |
e4b6113
to
715a4e9
Compare
On a second thought, this solution of running cmake twice with different options to load the native toolchain to build HogMaker, and then running the cross-compilation toolchain for the game adds complexity to our build system. I experimented with a solution using Do you think this could work for Android too? |
715a4e9
to
098104c
Compare
Reworked PR to use @Lgt2x's idea of |
@Lgt2x @winterheart how's this one looking review-wise? I'll get the merge conflicts updated tonight, but are there any other structural/functional/stylistic changes you'd like to see? |
Well I'm fine with the change as I mostly wrote the patch. Is it fine for you @winterheart ? |
Look good for me, but I'm not tested it. |
Can we try this approach for cross-compile purposes? if(CMAKE_CROSSCOMPILING)
find_package(HogMaker)
else()
# Build HogMaker executable
add_executable(HogMaker ...)
# Export executable as target
export(TARGETS HogMaker FILE
"${CMAKE_BINARY_DIR}/HogMakerConfig.cmake")
endif()
# Call add_custom_command with HogMaker involved
... And then first build native tools, after that configure cross-compiled environment: # Build native tools
mkdir build-native; cd build-native
cmake ..
make HogMaker
# Cross-platform build
cd ..
mkdir build-cross; cd build-cross
cmake -DCMAKE_TOOLCHAIN_FILE=MyToolchain.cmake \
-DHogMaker_DIR=~/src/build-native/ ..
make With this approach you'll need to first build host tools and then reuse them on cross-compile environment. |
This was the original approach with this PR, a few months ago. See above: #465 (comment) It worked alright, but @Lgt2x noted:
The currently-proposed solution adds no complexity to the build process. |
098104c
to
e4c5327
Compare
@Lgt2x this is blocked on your changes requested btw; seems like you're ok with it so just flagging that |
sorry, all good :) |
Pull Request Type
Description
HogMaker is a build tool that must run on the host. It must not, then, be compiled as part of the overall target build. For builds that must cross-compile, like Android (and eventually iOS/visionOS), we need to be able to reference an already-built HogMaker project.
Checklist