From ce94a4eceae1aa66c5a2907a5212d073969263a4 Mon Sep 17 00:00:00 2001 From: polar Date: Fri, 7 May 2021 09:07:42 +0100 Subject: [PATCH] BUILD: Refactor libpng submodule (#10238) * relocate libpng files * fix cmake build * fix MSVC build --- .gitmodules | 2 +- 3rdparty/CMakeLists.txt | 23 +---------------- 3rdparty/libpng/CMakeLists.txt | 22 ++++++++++++++++ 3rdparty/{ => libpng}/libpng | 0 3rdparty/{ => libpng}/libpng.vcxproj | 32 ++++++++++++------------ 3rdparty/{ => libpng}/pnglibconf.vcxproj | 0 rpcs3.sln | 4 +-- rpcs3/rpcs3.vcxproj | 4 +-- rpcs3_default.props | 2 +- 9 files changed, 45 insertions(+), 44 deletions(-) create mode 100644 3rdparty/libpng/CMakeLists.txt rename 3rdparty/{ => libpng}/libpng (100%) rename 3rdparty/{ => libpng}/libpng.vcxproj (89%) rename 3rdparty/{ => libpng}/pnglibconf.vcxproj (100%) diff --git a/.gitmodules b/.gitmodules index a9d96dbdf4..1cac210ca7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,7 +49,7 @@ url = https://github.com/RPCS3/yaml-cpp.git ignore = dirty [submodule "3rdparty/libpng"] - path = 3rdparty/libpng + path = 3rdparty/libpng/libpng url = https://github.com/glennrp/libpng.git ignore = dirty [submodule "3rdparty/libusb"] diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index d8cc208798..58e9a81b2b 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -29,28 +29,7 @@ add_library(3rdparty_flatbuffers INTERFACE) target_include_directories(3rdparty_flatbuffers INTERFACE flatbuffers/include) # libPNG -# Select the version of libpng to use, default is builtin -if (NOT USE_SYSTEM_LIBPNG) - # We use libpng's static library and don't need to build the shared library and run the tests - set(PNG_SHARED OFF CACHE BOOL "Build shared lib" FORCE) - set(PNG_TESTS OFF CACHE BOOL "Build libpng tests" FORCE) - set(PNG_BUILD_ZLIB ON CACHE BOOL "ZLIB is already build or package is found" FORCE) - set(SKIP_INSTALL_ALL ON) - add_subdirectory(libpng EXCLUDE_FROM_ALL) - - set(LIBPNG_TARGET png_static) - - target_include_directories(png_static INTERFACE "${libpng_BINARY_DIR}" "${libpng_SOURCE_DIR}") -else() - find_package(PNG REQUIRED) - - add_library(3rdparty_system_libpng INTERFACE) - target_include_directories(3rdparty_system_libpng INTERFACE ${PNG_INCLUDE_DIR}) - target_link_libraries(3rdparty_system_libpng INTERFACE ${PNG_LIBRARY}) - target_compile_definitions(3rdparty_system_libpng INTERFACE ${PNG_DEFINITIONS}) - - set(LIBPNG_TARGET 3rdparty_system_libpng) -endif() +add_subdirectory(libpng EXCLUDE_FROM_ALL) # pugixml diff --git a/3rdparty/libpng/CMakeLists.txt b/3rdparty/libpng/CMakeLists.txt new file mode 100644 index 0000000000..d1c3b58bcd --- /dev/null +++ b/3rdparty/libpng/CMakeLists.txt @@ -0,0 +1,22 @@ +# libPNG +# Select the version of libpng to use, default is builtin +if (NOT USE_SYSTEM_LIBPNG) + # We use libpng's static library and don't need to build the shared library and run the tests + set(PNG_SHARED OFF CACHE BOOL "Build shared lib" FORCE) + set(PNG_TESTS OFF CACHE BOOL "Build libpng tests" FORCE) + set(PNG_BUILD_ZLIB ON CACHE BOOL "ZLIB is already build or package is found" FORCE) + set(SKIP_INSTALL_ALL ON) + add_subdirectory(libpng EXCLUDE_FROM_ALL) + target_include_directories(png_static INTERFACE "${libpng_BINARY_DIR}" "${libpng_SOURCE_DIR}") + + set(LIBPNG_TARGET png_static PARENT_SCOPE) +else() + find_package(PNG REQUIRED) + + add_library(3rdparty_system_libpng INTERFACE) + target_include_directories(3rdparty_system_libpng INTERFACE ${PNG_INCLUDE_DIR}) + target_link_libraries(3rdparty_system_libpng INTERFACE ${PNG_LIBRARY}) + target_compile_definitions(3rdparty_system_libpng INTERFACE ${PNG_DEFINITIONS}) + + set(LIBPNG_TARGET 3rdparty_system_libpng PARENT_SCOPE) +endif() diff --git a/3rdparty/libpng b/3rdparty/libpng/libpng similarity index 100% rename from 3rdparty/libpng rename to 3rdparty/libpng/libpng diff --git a/3rdparty/libpng.vcxproj b/3rdparty/libpng/libpng.vcxproj similarity index 89% rename from 3rdparty/libpng.vcxproj rename to 3rdparty/libpng/libpng.vcxproj index d9e94ae83c..a7bc0df739 100644 --- a/3rdparty/libpng.vcxproj +++ b/3rdparty/libpng/libpng.vcxproj @@ -114,27 +114,27 @@ - + Create Create - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + true true diff --git a/3rdparty/pnglibconf.vcxproj b/3rdparty/libpng/pnglibconf.vcxproj similarity index 100% rename from 3rdparty/pnglibconf.vcxproj rename to 3rdparty/libpng/pnglibconf.vcxproj diff --git a/rpcs3.sln b/rpcs3.sln index 44b3f4a7d6..ed11ef5095 100644 --- a/rpcs3.sln +++ b/rpcs3.sln @@ -19,9 +19,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XAudio", "rpcs3\XAudio.vcxp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenAL", "rpcs3\OpenAL.vcxproj", "{30A05C4D-F5FD-421C-A864-17A64BDEAA75}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pnglibconf", "3rdparty\pnglibconf.vcxproj", "{EB33566E-DA7F-4D28-9077-88C0B7C77E35}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pnglibconf", "3rdparty\libpng\pnglibconf.vcxproj", "{EB33566E-DA7F-4D28-9077-88C0B7C77E35}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "3rdparty\libpng.vcxproj", "{D6973076-9317-4EF2-A0B8-B7A18AC0713E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "3rdparty\libpng\libpng.vcxproj", "{D6973076-9317-4EF2-A0B8-B7A18AC0713E}" ProjectSection(ProjectDependencies) = postProject {60F89955-91C6-3A36-8000-13C592FEC2DF} = {60F89955-91C6-3A36-8000-13C592FEC2DF} {EB33566E-DA7F-4D28-9077-88C0B7C77E35} = {EB33566E-DA7F-4D28-9077-88C0B7C77E35} diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index ae0fa04d85..f1ac996ece 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -62,12 +62,12 @@ true - ..\3rdparty\7z\src;..\3rdparty\hidapi\hidapi;.\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\XAudio2Redist\include;..\3rdparty\span\include;..\3rdparty\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\Optional;..\3rdparty\discord-rpc\include;..\3rdparty\zlib + ..\3rdparty\7z\src;..\3rdparty\hidapi\hidapi;.\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\XAudio2Redist\include;..\3rdparty\span\include;..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\Optional;..\3rdparty\discord-rpc\include;..\3rdparty\zlib $(SolutionDir)lib\$(Configuration)-$(Platform)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(SolutionDir)lib\$(Configuration)-$(Platform)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) - ..\3rdparty\7z\src;..\3rdparty\hidapi\hidapi;.\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\XAudio2Redist\include;..\3rdparty\span\include;..\3rdparty\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\Optional;..\3rdparty\discord-rpc\include;..\3rdparty\zlib + ..\3rdparty\7z\src;..\3rdparty\hidapi\hidapi;.\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\XAudio2Redist\include;..\3rdparty\span\include;..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\Optional;..\3rdparty\discord-rpc\include;..\3rdparty\zlib diff --git a/rpcs3_default.props b/rpcs3_default.props index e528225952..7f5418ab72 100644 --- a/rpcs3_default.props +++ b/rpcs3_default.props @@ -3,7 +3,7 @@ - .\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\span\include;..\3rdparty\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\hidapi\hidapi;..\3rdparty\Optional;..\3rdparty\xxhash + .\;..\;..\3rdparty\asmjit\asmjit\src;..\3rdparty\yaml-cpp\include;..\3rdparty\ffmpeg\include;..\3rdparty\cereal\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);..\3rdparty\span\include;..\3rdparty\libpng\libpng;..\3rdparty\GL;..\3rdparty\stblib\include;..\3rdparty\OpenAL\include;..\3rdparty\pugixml\src;..\3rdparty\hidapi\hidapi;..\3rdparty\Optional;..\3rdparty\xxhash $(SolutionDir)lib\$(Configuration)-$(Platform)\ $(SolutionDir)lib\$(Configuration)-$(Platform)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(SolutionDir)tmp\$(ProjectName)-$(Configuration)-$(Platform)\