mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Cross compilation working, does not actually run and crashes somewhere in miles sound system, probably the abi blowing up
This commit is contained in:
parent
a544e968fb
commit
bdeec50d33
|
|
@ -1,44 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.24)
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
|
||||||
project(MinecraftConsoles LANGUAGES C CXX ASM_MASM)
|
project(MinecraftConsoles LANGUAGES C CXX)
|
||||||
|
|
||||||
#if(NOT WIN32)
|
|
||||||
# message(FATAL_ERROR "This CMake build currently supports Windows only.")
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
message(NOTICE "LCE is cross-compiling a Windows binary using clang-cl.
|
|
||||||
This expects your system has `clang-cl` and `llvm-ml` installed and in PATH.
|
|
||||||
You must also install MinGW and set the variable LCE_WINDOWS_SDK to your Windows SDK (provided by MinGW)")
|
|
||||||
|
|
||||||
message(WARNING "Skipping compiler check")
|
|
||||||
|
|
||||||
set(CMAKE_C_COMPILER_WORKS True)
|
|
||||||
|
|
||||||
if(NOT DEFINED LCE_WINDOWS_SDK)
|
|
||||||
#message(FATAL_ERROR "LCE_WINDOWS_SDK is unset!")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CROSSCOMPILING True)
|
|
||||||
set(CMAKE_SYSTEM_NAME Windows)
|
|
||||||
|
|
||||||
#find_program(clang-cl REQUIRED)
|
|
||||||
#find_program(llvm-ml REQUIRED)
|
|
||||||
|
|
||||||
set(CMAKE_C_COMPILER clang-cl)
|
|
||||||
set(CMAKE_CXX_COMPILER clang-cl)
|
|
||||||
set(CMAKE_ASM_MASM_COMPILER llvm-ml)
|
|
||||||
set(CMAKE_LINKER lld-link)
|
|
||||||
|
|
||||||
add_compile_options(/winsysroot /opt/msvc /clang:--target=x86_64-pc-windows-msvc)
|
|
||||||
add_link_options(/winsysroot /opt/msvc /clang:--target=x86_64-pc-windows-msvc)
|
|
||||||
|
|
||||||
set(MSVC True)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
message(NOTICE "CMake detecting MSVC")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8 AND WIN32) # This check is broken on linux+clang-cl
|
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8 AND WIN32) # This check is broken on linux+clang-cl
|
||||||
message(FATAL_ERROR "Use a 64-bit generator/toolchain (x64).")
|
message(FATAL_ERROR "Use a 64-bit generator/toolchain (x64).")
|
||||||
|
|
@ -95,8 +57,8 @@ set_target_properties(MinecraftClient PROPERTIES
|
||||||
target_link_libraries(MinecraftClient PRIVATE
|
target_link_libraries(MinecraftClient PRIVATE
|
||||||
MinecraftWorld
|
MinecraftWorld
|
||||||
d3d11
|
d3d11
|
||||||
XInput9_1_0
|
xinput9_1_0 # Changed capitalization to fix builds on case-sensitive filesystems
|
||||||
Shcore
|
shcore # ditto
|
||||||
wsock32
|
wsock32
|
||||||
legacy_stdio_definitions
|
legacy_stdio_definitions
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/lib/iggy_w64.lib"
|
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/lib/iggy_w64.lib"
|
||||||
|
|
|
||||||
24
Compile.md
24
Compile.md
|
|
@ -39,7 +39,29 @@ cd .\build\Debug
|
||||||
.\MinecraftClient.exe
|
.\MinecraftClient.exe
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## CMake (Linux)
|
||||||
|
|
||||||
|
MinecraftConsoles does not support Linux but can cross-compile a Windows build from Linux.
|
||||||
|
|
||||||
|
You will need a Windows MSVC SDK. You can get one from [msvc-wine](https://github.com/mstorsjo/msvc-wine).
|
||||||
|
|
||||||
|
Configure:
|
||||||
|
```
|
||||||
|
MinecraftConsoles $ mkdir build && cd build
|
||||||
|
MinecraftConsoles/build $ cmake .. -B . -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrosscompile.cmake -DCMAKE_BUILD_TYPE=<Debug or Release>
|
||||||
|
```
|
||||||
|
|
||||||
|
Build:
|
||||||
|
```
|
||||||
|
MinecraftConsoles/build $ ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
Run:
|
||||||
|
```
|
||||||
|
MinecraftConsoles/build $ wine MinecraftClient.exe
|
||||||
|
```
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- The CMake build is Windows-only and x64-only.
|
- The CMake build will only compile a Windows binary, and non-win32 systems will cross-compile one.
|
||||||
- Post-build asset copy is automatic for `MinecraftClient` in CMake (Debug and Release variants).
|
- Post-build asset copy is automatic for `MinecraftClient` in CMake (Debug and Release variants).
|
||||||
- The game relies on relative paths (for example `Common\Media\...`), so launching from the output directory is required.
|
- The game relies on relative paths (for example `Common\Media\...`), so launching from the output directory is required.
|
||||||
|
|
|
||||||
16
cmake/LinuxCrosscompile.cmake
Normal file
16
cmake/LinuxCrosscompile.cmake
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER clang-cl)
|
||||||
|
set(CMAKE_CXX_COMPILER clang-cl)
|
||||||
|
set(CMAKE_LINKER lld-link)
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER_FRONTEND_VARIANT MSVC)
|
||||||
|
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MSVC)
|
||||||
|
|
||||||
|
add_compile_options(/winsysroot /opt/msvc --target=x86_64-pc-windows-msvc)
|
||||||
|
add_link_options(/winsysroot:/opt/msvc)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
Loading…
Reference in a new issue