From d9a3158f6a85737bd99a94af765a85798d85671c Mon Sep 17 00:00:00 2001 From: Ben Young Date: Wed, 8 Oct 2025 12:15:35 -0500 Subject: [PATCH] Use system-installed lodepng if BUNDLE_DEPENDENCIES=OFF (#1250) --- desktop_version/CMakeLists.txt | 21 ++++++++++----------- desktop_version/src/lodepng_wrapper.c | 4 ++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt index 26d191d4..090ac202 100644 --- a/desktop_version/CMakeLists.txt +++ b/desktop_version/CMakeLists.txt @@ -240,6 +240,7 @@ if(APPLE) set(PFS_SRC ${PFS_SRC} ../third_party/physfs/src/physfs_platform_apple.m) endif() set(PNG_SRC src/lodepng_wrapper.c) +set(PNG_DEF -DLODEPNG_NO_COMPILE_ALLOCATORS -DLODEPNG_NO_COMPILE_DISK) set(CHM_SRC ../third_party/c-hashmap/map.c) set(SBIDI_SRC ../third_party/SheenBidi/Source/SheenBidi.c) @@ -341,14 +342,6 @@ else() set_source_files_properties(${CHM_SRC} PROPERTIES COMPILE_FLAGS -std=c99) endif() -# Unfortunately, it doesn't seem like distros package LodePNG -add_library(lodepng-static STATIC ${PNG_SRC}) - -target_compile_definitions(lodepng-static PRIVATE - -DLODEPNG_NO_COMPILE_ALLOCATORS - -DLODEPNG_NO_COMPILE_DISK -) - add_library(c-hashmap-static STATIC ${CHM_SRC}) add_library(sheenbidi-static STATIC ${SBIDI_SRC}) @@ -361,12 +354,14 @@ target_include_directories(sheenbidi-static PRIVATE ) if(BUNDLE_DEPENDENCIES) - list(APPEND STATIC_LIBRARIES physfs-static tinyxml2-static lodepng-static c-hashmap-static faudio-static sheenbidi-static) + list(APPEND STATIC_LIBRARIES lodepng-static physfs-static tinyxml2-static c-hashmap-static faudio-static sheenbidi-static) else() - list(APPEND STATIC_LIBRARIES lodepng-static c-hashmap-static sheenbidi-static) + list(APPEND STATIC_LIBRARIES c-hashmap-static sheenbidi-static) endif() if(BUNDLE_DEPENDENCIES) + add_library(lodepng-static STATIC ${PNG_SRC}) + target_compile_definitions(lodepng-static PRIVATE ${PNG_DEF}) add_library(tinyxml2-static STATIC ${XML2_SRC}) add_library(physfs-static STATIC ${PFS_SRC}) target_compile_definitions(physfs-static PRIVATE @@ -382,7 +377,11 @@ if(BUNDLE_DEPENDENCIES) target_link_libraries(VVVVVV ${STATIC_LIBRARIES}) else() - target_link_libraries(VVVVVV ${STATIC_LIBRARIES} physfs tinyxml2 FAudio) + target_compile_definitions(VVVVVV PRIVATE + ${PNG_DEF} + -DSYSTEM_LODEPNG + ) + target_link_libraries(VVVVVV ${STATIC_LIBRARIES} physfs tinyxml2 FAudio lodepng) endif() diff --git a/desktop_version/src/lodepng_wrapper.c b/desktop_version/src/lodepng_wrapper.c index a2cbb9b3..d290296e 100644 --- a/desktop_version/src/lodepng_wrapper.c +++ b/desktop_version/src/lodepng_wrapper.c @@ -1,2 +1,6 @@ +#ifdef SYSTEM_LODEPNG +#include +#else /* Workaround for being unable to rename lodepng.cpp to lodepng.c */ #include "../../third_party/lodepng/lodepng.cpp" +#endif \ No newline at end of file