DescentDevelopers / Descent3

Descent 3 by Outrage Entertainment
GNU General Public License v3.0
2.73k stars 231 forks source link

Enable cross-compiling of HogMaker #465

Open tophyr opened 1 week ago

tophyr commented 1 week ago

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

tophyr commented 1 week ago

@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 HogMakerConfig.cmake file) and then the second, using the target toolchain, gets pointed to the first build.

# creates HogMakerConfig.cmake
cmake -B builds/host
# creates the host HogMaker binary
cmake --build builds/host --target HogMaker

# now, do the actual android (or target) build
cmake -B builds/target -DCMAKE_TOOLCHAIN_FILE=/path/to/android/toolchain.cmake -DHogMaker_DIR=$(pwd)/builds/host
cmake --build builds/target

So -

HogMakerConfig.cmake was not included in this PR. Where is the HogMaker package created in case we're building for Android

That file gets created by the first CMake invocation

in this else(), we're not targeting Android, which means that HogMaker will not be looked up using find_package. So why exporting the target?

correct. we have to export it from this one, so that the android build can subsequently reference it.

tophyr commented 1 week ago

Conditionals improved and README updated.

tophyr commented 5 days ago

ping @Lgt2x for re-review