fix: -p0 & new stb_image.h patch

This commit is contained in:
collecting
2025-10-07 05:09:39 +00:00
parent 339b8fbc1f
commit 5ffcc35011

View File

@@ -399,7 +399,7 @@ if(USE_DISCORD_PRESENCE)
# Check if the target directory exists before trying to patch # Check if the target directory exists before trying to patch
if(EXISTS "${PATCH_TARGET_DIR}") if(EXISTS "${PATCH_TARGET_DIR}")
execute_process( execute_process(
COMMAND git apply --ignore-whitespace "${PATCH_FILE}" COMMAND git apply -p0 --ignore-whitespace "${PATCH_FILE}"
WORKING_DIRECTORY "${PATCH_TARGET_DIR}" WORKING_DIRECTORY "${PATCH_TARGET_DIR}"
RESULT_VARIABLE PATCH_RESULT RESULT_VARIABLE PATCH_RESULT
OUTPUT_QUIET OUTPUT_QUIET
@@ -422,7 +422,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(EXISTS "${MCL_PATCH_TARGET_DIR}") if(EXISTS "${MCL_PATCH_TARGET_DIR}")
execute_process( execute_process(
COMMAND git apply --ignore-whitespace "${MCL_PATCH_FILE}" COMMAND git apply -p0 --ignore-whitespace "${MCL_PATCH_FILE}"
WORKING_DIRECTORY "${MCL_PATCH_TARGET_DIR}" WORKING_DIRECTORY "${MCL_PATCH_TARGET_DIR}"
RESULT_VARIABLE MCL_PATCH_RESULT RESULT_VARIABLE MCL_PATCH_RESULT
OUTPUT_QUIET OUTPUT_QUIET
@@ -437,6 +437,30 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif() endif()
endif() endif()
# Apply a patch to stb_image.h to fix a string overflow warning with modern compilers
message(STATUS "Applying custom patch to stb_image.h...")
set(STB_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patches/stb_image-overflow-fix.patch")
set(STB_PATCH_WORKING_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# Check if the file to be patched exists before trying to patch
if(EXISTS "${STB_PATCH_WORKING_DIR}/externals/stb/stb_image.h")
execute_process(
COMMAND git apply -p0 --ignore-whitespace "${STB_PATCH_FILE}"
WORKING_DIRECTORY "${STB_PATCH_WORKING_DIR}"
RESULT_VARIABLE PATCH_RESULT
OUTPUT_QUIET
ERROR_QUIET
)
if(NOT PATCH_RESULT EQUAL 0)
message(WARNING "Failed to apply stb_image.h compiler fix patch! This might be okay if it's already applied.")
endif()
else()
message(WARNING "Could not find stb_image.h to patch. It may not have been downloaded yet.")
endif()
if (ENABLE_QT) if (ENABLE_QT)
if (NOT USE_SYSTEM_QT) if (NOT USE_SYSTEM_QT)
download_qt(6.7.3) download_qt(6.7.3)