Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
2026-03-20 21:47:46 +03:00
3 changed files with 41 additions and 39 deletions

View File

@@ -6,7 +6,6 @@ include(cmake/CPM.cmake)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_POLICY_VERSION_MINIMUM 3.10) set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal") set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
endif() endif()
@@ -23,26 +22,15 @@ enum_option(PLATFORM "Desktop;Web" "Platform to build for.")
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(OpenSSL) find_package(OpenSSL)
if (${PLATFORM} STREQUAL "Desktop") if(EMSCRIPTEN)
set(PLATFORM_CPP "PLATFORM_DESKTOP") set(AL_LIBTYPE "STATIC")
else()
if (WIN32) set(AL_LIBTYPE "SHARED")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(EXTRA_LIBS ws2_32)
elseif(UNIX)
find_library(pthread NAMES pthread)
set(EXTRA_LIBS pthread m)
endif()
elseif (${PLATFORM} STREQUAL "Web")
set(PLATFORM_CPP "PLATFORM_WEB")
set(EXTRA_LIBS "idbfs.js")
endif() endif()
# I totally shocked # I totally shocked
if(${PLATFORM} MATCHES "Web") if(EMSCRIPTEN)
set(PNG_LIB png) set(PNG_LIB png)
set(AL_LIBTYPE "STATIC")
add_library(zlib INTERFACE IMPORTED) add_library(zlib INTERFACE IMPORTED)
set_target_properties(zlib PROPERTIES set_target_properties(zlib PROPERTIES
@@ -60,7 +48,6 @@ if(${PLATFORM} MATCHES "Web")
) )
else() else()
set(PNG_LIB png_shared) set(PNG_LIB png_shared)
set(AL_LIBTYPE "SHARED")
CPMAddPackage( CPMAddPackage(
NAME "zlib" NAME "zlib"
@@ -281,32 +268,49 @@ file(GLOB CLIENT_SOURCES
"src/SharedConstants.cpp" "src/SharedConstants.cpp"
"src/main.cpp" "src/main.cpp"
"src/NinecraftApp.cpp" "src/NinecraftApp.cpp"
"src/AppPlatform_glfw.cpp"
"src/main.cpp"
) )
if (${PLATFORM} STREQUAL "Desktop") if(NOT DEFINED PLATFORM)
list(APPEND CLIENT_SOURCES glad/src/glad.c) set(PLATFORM "PLATFORM_GLFW")
endif()
if(PLATFORM STREQUAL "PLATFORM_WIN32")
list(APPEND CLIENT_SOURCES "src/AppPlatform_win32.cpp" "glad/src/glad.c")
endif()
if(PLATFORM STREQUAL "PLATFORM_GLFW")
list(APPEND CLIENT_SOURCES "src/AppPlatform_glfw.cpp" "glad/src/glad.c")
endif()
if(EMSCRIPTEN)
list(APPEND CLIENT_SOURCES "glad/src/glad.c")
endif() endif()
# Server # Server
if(UNIX) if(UNIX)
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES}) add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER") target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
target_include_directories("${PROJECT_NAME}-server" PUBLIC target_include_directories("${PROJECT_NAME}-server" PUBLIC
"${CMAKE_SOURCE_DIR}/src/" "${CMAKE_SOURCE_DIR}/src/"
"project/lib_projects/raknet/jni/RaknetSources" "project/lib_projects/raknet/jni/RaknetSources"
) )
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES}) add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PLATFORM_CPP}) if(WIN32)
set(EXTRA_LIBS "ws2_32")
target_compile_definitions(${PROJECT_NAME} PUBLIC "_CRT_SECURE_NO_WARNINGS")
endif()
if(PLATFORM STREQUAL "PLATFORM_WIN32" OR PLATFORM STREQUAL "PLATFORM_GLFW")
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLATFORM_DESKTOP")
endif()
target_include_directories(${PROJECT_NAME} PUBLIC target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_SOURCE_DIR}/glad/include/" "${CMAKE_SOURCE_DIR}/glad/include/"
@@ -316,7 +320,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
"lib/include" "lib/include"
) )
if(${PLATFORM} MATCHES "Web") if(EMSCRIPTEN)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
# uuuh i hate it # uuuh i hate it
set(EM_FLAGS "-pthread -sUSE_PTHREADS=1 -sSHARED_MEMORY=1") set(EM_FLAGS "-pthread -sUSE_PTHREADS=1 -sSHARED_MEMORY=1")
@@ -357,6 +361,7 @@ if(${PLATFORM} MATCHES "Web")
endif() endif()
target_compile_definitions(${PROJECT_NAME} PUBLIC "__EMSCRIPTEN__" "NO_SOUND" "NO_NETWORK") target_compile_definitions(${PROJECT_NAME} PUBLIC "__EMSCRIPTEN__" "NO_SOUND" "NO_NETWORK")
set(EXTRA_LIBS "idbfs.js")
endif() endif()
# Client # Client
@@ -377,7 +382,7 @@ if (NOT UNIX)
) )
endif() endif()
if(NOT ${PLATFORM} MATCHES "Web") if(NOT EMSCRIPTEN)
add_custom_command( add_custom_command(
TARGET ${PROJECT_NAME} TARGET ${PROJECT_NAME}
POST_BUILD POST_BUILD
@@ -389,7 +394,4 @@ else()
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/misc/web/index.html" $<TARGET_FILE_DIR:${PROJECT_NAME}> COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/misc/web/index.html" $<TARGET_FILE_DIR:${PROJECT_NAME}>
) )
endif() endif()
message(STATUS "Compiling with the flags:")
message(STATUS " PLATFORM=" ${PLATFORM_CPP})

View File

@@ -7,7 +7,7 @@
<!-- This is the platform API where NativeActivity was introduced. --> <!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="19" <uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="36" /> android:targetSdkVersion="30" />
<!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ --> <!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ -->

View File

@@ -6,7 +6,7 @@
<uses-sdk <uses-sdk
android:minSdkVersion="19" android:minSdkVersion="19"
android:targetSdkVersion="36"/> android:targetSdkVersion="30"/>
<uses-feature <uses-feature
android:name="android.hardware.touchscreen.multitouch" android:name="android.hardware.touchscreen.multitouch"