CMake support

This commit is contained in:
BendedWills 2026-03-02 04:08:43 -06:00
parent 1945f72a86
commit 287a060695
9 changed files with 1278 additions and 5 deletions

11
.gitignore vendored
View file

@ -28,6 +28,17 @@ ipch/
*.ilk
*.exp
# ===========================================
# CLion files
# ===========================================
.idea
# ===========================================
# CMake
# ===========================================
cmake-build-debug
cmake-build-release
# ===========================================
# Archives & packaged binaries
# ===========================================

68
CMakeLists.txt Normal file
View file

@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.10)
project("LCEMP")
set(CMAKE_CXX_STANDARD 11)
add_subdirectory(Vendor)
if(NOT WIN32)
message(FATAL_ERROR "Windows is currently the only supported OS")
endif()
# Fix linking errors with other libs compiled with an older CRT
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Sources.cmake")
list(TRANSFORM MINECRAFT_WORLD_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.World/")
list(TRANSFORM MINECRAFT_CLIENT_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/")
add_library(MinecraftWorld STATIC ${MINECRAFT_WORLD_SOURCES})
add_executable(MinecraftClient WIN32 ${MINECRAFT_CLIENT_SOURCES})
if(MSVC)
# /MT and /MTd options set the CRT version to multi-threaded static mode
# which is what the 4J libs were compiled with
target_compile_options(MinecraftWorld PRIVATE /W3 /MP $<$<CONFIG:Debug>:/MTd> $<$<NOT:$<CONFIG:Debug>>:/MT> /EHsc)
target_compile_options(MinecraftClient PRIVATE /W3 /MP $<$<CONFIG:Debug>:/MTd> $<$<NOT:$<CONFIG:Debug>>:/MT> /EHsc)
endif()
target_compile_definitions(MinecraftWorld PRIVATE
$<$<CONFIG:Debug>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_LIB;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64>
$<$<NOT:$<CONFIG:Debug>>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_LIB;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64>
)
target_compile_definitions(MinecraftClient PRIVATE
$<$<CONFIG:Debug>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64>
$<$<NOT:$<CONFIG:Debug>>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64>
)
target_include_directories(MinecraftWorld PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.World"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.World/x64headers"
)
target_include_directories(MinecraftClient PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/include"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Xbox/Sentient/Include"
)
target_link_libraries(MinecraftClient PRIVATE
MinecraftWorld
d3d11
XInput9_1_0
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/lib/iggy_w64.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Miles/lib/mss64.lib"
$<$<CONFIG:Debug>:
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC_d.lib"
>
$<$<NOT:$<CONFIG:Debug>>:
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_r.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_r.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile_r.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC.lib"
>
)

View file

@ -0,0 +1,28 @@
// CRT compatibility shim for linking VS2012-era libraries with VS2022
// Provides symbols removed in the Universal CRT (VS2015+)
#include <cstdio>
#include <cstring>
// __iob_func was removed in VS2015. Old code (e.g. libpng) references it.
// Provide a shim that returns the stdio file pointers.
extern "C" FILE* __iob_func(void)
{
// The old __iob_func returned an array of {stdin, stdout, stderr}.
// In the Universal CRT, these are functions, not a contiguous array.
// We return a static array mimicking the old layout.
static FILE iob[3];
iob[0] = *stdin;
iob[1] = *stdout;
iob[2] = *stderr;
return iob;
}
// std::_Winerror_map was an internal MSVC runtime function used by
// std::system_category::message(). Old .lib files compiled with VS2012
// may reference it. Provide a minimal stub.
namespace std {
const char* _Winerror_map(int) {
return "";
}
}

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include <xhash>
#include <functional>
#include "Hasher.h"
@ -19,7 +20,7 @@ wstring Hasher::getHash(wstring &name)
//return new BigInteger(1, m.digest()).toString(16);
// TODO 4J Stu - Will this hash us with the same distribution as the MD5?
return _toString( hash_value( s ) );
return _toString( std::hash<wstring>{}( s ) );
//}
//catch (NoSuchAlgorithmException e)
//{

View file

@ -3,14 +3,15 @@
#include "I18n.h"
Language *I18n::lang = Language::getInstance();
wstring I18n::get(const wstring& id, ...)
{
wstring I18n::get(const wstring& id, ...) {
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L"";
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
return id;
#else
va_list va;
va_start(va, id);
return I18n::get(id, va);
return I18n::get(id, va);
#endif
}

View file

@ -24,6 +24,8 @@ wstring Language::getElement(const wstring& elementId, ...)
{
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L"";
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
return elementId;
#else
va_list args;
va_start(args, elementId);

View file

@ -2561,7 +2561,7 @@ int Player::hash_fnct(const shared_ptr<Player> k)
#ifdef __PS3__
return (int)boost::hash_value( k->name ); // 4J Stu - Names are completely unique?
#else
return (int)std::hash_value( k->name ); // 4J Stu - Names are completely unique?
return (int)std::hash<wstring>{}( k->name ); // 4J Stu - Names are completely unique?
#endif //__PS3__
}

0
Vendor/CMakeLists.txt vendored Normal file
View file

1162
cmake/Sources.cmake Normal file

File diff suppressed because it is too large Load diff