mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Enable cross-compile environment for HogMaker
Add CMAKE_CROSSCOMPILING conditional for HogMaker that makes it "external" tool in cross-compile environment, so we can use native HogMaker for cross-compiled targets.
This commit is contained in:
parent
39b205b957
commit
46c6b55f5c
25
BUILD.md
25
BUILD.md
@ -40,7 +40,7 @@ The build process uses [**CMake**](https://cmake.org/) and, by default, [**Ninja
|
||||
git clone --recurse-submodules https://github.com/DescentDevelopers/Descent3
|
||||
```
|
||||
|
||||
4. **Build Descent3.**
|
||||
3. **Build Descent3.**
|
||||
|
||||
```batch
|
||||
cd Descent3
|
||||
@ -149,6 +149,29 @@ Once CMake finishes, the built files will be put in `builds/mac/Descent3/Debug`
|
||||
|
||||
Once CMake finishes, the built files will be put in `builds/linux/Descent3/Debug` or `builds/linux/Descent3/Release`.
|
||||
|
||||
## Cross-compilation
|
||||
|
||||
In order to cross-compile Descent3 to another platform (for example, Linux ARM64), you'll need to build auxiliary
|
||||
tools which needed to build data files. First create build-native directory and configure project in it:
|
||||
|
||||
```shell
|
||||
mkdir build-native
|
||||
cd build-native
|
||||
cmake ..
|
||||
make HogMaker
|
||||
```
|
||||
|
||||
Now you ready for cross-compilation. Create cross-compile directory and configure project in it, but this time add
|
||||
`-DCMAKE_TOOLCHAIN_FILE=MyToolchain.cmake` and `-DHogMaker_DIR=<path-to-Descent3/build-native/` options. This enables
|
||||
cross-compilation environment.
|
||||
|
||||
```shell
|
||||
mkdir build-cross
|
||||
cd build-cross
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=MyToolchain.cmake -DHogMaker_DIR=~/src/build-native/ ..
|
||||
make
|
||||
```
|
||||
|
||||
## Build Options
|
||||
|
||||
The Descent3 build can be customized by [setting CMake variables on the command line](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-D) during its "Configuration" phase (the command without the `--build` option). To set a variable, you prepend the variable name with `-D` and then append the value, all as one single parameter. For example:
|
||||
|
@ -1,7 +1,12 @@
|
||||
add_executable(
|
||||
HogMaker
|
||||
HogMaker/HogFormat.cpp
|
||||
HogMaker/HogMaker.cpp
|
||||
)
|
||||
add_dependencies(HogMaker get_git_hash)
|
||||
target_include_directories(HogMaker PRIVATE ${PROJECT_BINARY_DIR}/lib)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
find_package(HogMaker)
|
||||
else()
|
||||
add_executable(
|
||||
HogMaker
|
||||
HogMaker/HogFormat.cpp
|
||||
HogMaker/HogMaker.cpp
|
||||
)
|
||||
add_dependencies(HogMaker get_git_hash)
|
||||
target_include_directories(HogMaker PRIVATE ${PROJECT_BINARY_DIR}/lib)
|
||||
export(TARGETS HogMaker FILE "${CMAKE_BINARY_DIR}/HogMakerConfig.cmake")
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user