diff --git a/ports/libsquish/CONTROL b/ports/libsquish/CONTROL new file mode 100644 index 00000000000..9cc2e509737 --- /dev/null +++ b/ports/libsquish/CONTROL @@ -0,0 +1,3 @@ +Source: libsquish +Version: 1.15 +Description: Open source DXT compression library. diff --git a/ports/libsquish/fix-export-symbols.patch b/ports/libsquish/fix-export-symbols.patch new file mode 100644 index 00000000000..febf2eb5142 --- /dev/null +++ b/ports/libsquish/fix-export-symbols.patch @@ -0,0 +1,98 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a36e574..a3ecdde 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -75,6 +75,13 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + + ADD_LIBRARY(squish ${SQUISH_SRCS} ${SQUISH_HDRS}) + ++INCLUDE(GenerateExportHeader) ++GENERATE_EXPORT_HEADER(squish ++ EXPORT_FILE_NAME ${CMAKE_CURRENT_SOURCE_DIR}/squish_export.h ++ ) ++ ++list(APPEND SQUISH_HDRS "squish_export.h") ++ + SET_TARGET_PROPERTIES( + squish PROPERTIES + PUBLIC_HEADER "${SQUISH_HDRS}" +@@ -109,9 +116,12 @@ IF (BUILD_SQUISH_EXTRA) + ENDIF (PNG_FOUND) + ENDIF (BUILD_SQUISH_EXTRA) + ++INCLUDE(GNUInstallDirs) ++ + INSTALL( + TARGETS squish +- LIBRARY DESTINATION lib +- ARCHIVE DESTINATION lib +- PUBLIC_HEADER DESTINATION include ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) +diff --git a/squish.h b/squish.h +index 14c9bb5..aaffbb2 100644 +--- a/squish.h ++++ b/squish.h +@@ -26,6 +26,8 @@ + #ifndef SQUISH_H + #define SQUISH_H + ++#include "squish_export.h" ++ + //! All squish API functions live in this namespace. + namespace squish { + +@@ -176,7 +178,7 @@ inline void Compress( u8 const* rgba, void* block, int flags, float* metric = 0 + however, DXT1 will be used by default if none is specified. All other flags + are ignored. + */ +-void Decompress( u8* rgba, void const* block, int flags ); ++SQUISH_EXPORT void Decompress( u8* rgba, void const* block, int flags ); + + // ----------------------------------------------------------------------------- + +@@ -194,7 +196,7 @@ void Decompress( u8* rgba, void const* block, int flags ); + function supports arbitrary size images by allowing the outer blocks to + be only partially used. + */ +-int GetStorageRequirements( int width, int height, int flags ); ++SQUISH_EXPORT int GetStorageRequirements( int width, int height, int flags ); + + // ----------------------------------------------------------------------------- + +@@ -249,8 +251,8 @@ int GetStorageRequirements( int width, int height, int flags ); + Windows platform but for other platforms like MacOS X a different + gamma value may be more suitable. + */ +-void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 ); +-void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 ); ++SQUISH_EXPORT void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 ); ++SQUISH_EXPORT void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 ); + + // ----------------------------------------------------------------------------- + +@@ -274,8 +276,8 @@ void CompressImage( u8 const* rgba, int width, int height, void* blocks, int fla + + Internally this function calls squish::Decompress for each block. + */ +-void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags ); +-void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ); ++SQUISH_EXPORT void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags ); ++SQUISH_EXPORT void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ); + + // ----------------------------------------------------------------------------- + +@@ -299,8 +301,8 @@ void DecompressImage( u8* rgba, int width, int height, void const* blocks, int f + + Internally this function calls squish::Decompress for each block. + */ +-void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); +-void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); ++SQUISH_EXPORT void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); ++SQUISH_EXPORT void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); + + // ----------------------------------------------------------------------------- + diff --git a/ports/libsquish/portfile.cmake b/ports/libsquish/portfile.cmake new file mode 100644 index 00000000000..dbebf95667b --- /dev/null +++ b/ports/libsquish/portfile.cmake @@ -0,0 +1,40 @@ +# Common Ambient Variables: +# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} +# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} +# CURRENT_PORT_DIR = ${VCPKG_ROOT_DIR}\ports\${PORT} +# PORT = current port name (zlib, etc) +# TARGET_TRIPLET = current triplet (x86-windows, x64-windows-static, etc) +# VCPKG_CRT_LINKAGE = C runtime linkage type (static, dynamic) +# VCPKG_LIBRARY_LINKAGE = target library linkage type (static, dynamic) +# VCPKG_ROOT_DIR = +# VCPKG_TARGET_ARCHITECTURE = target architecture (x64, x86, arm) +# + +include(vcpkg_common_functions) + +vcpkg_download_distfile(ARCHIVE + URLS "https://downloads.sourceforge.net/project/libsquish/libsquish-1.15.tgz" + FILENAME "libsquish-1.15.tgz" + SHA512 5b569b7023874c7a43063107e2e428ea19e6eb00de045a4a13fafe852ed5402093db4b65d540b5971ec2be0d21cb97dfad9161ebfe6cf6e5376174ff6c6c3e7a +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + NO_REMOVE_ONE_LEVEL + REF v1.15 + PATCHES + fix-export-symbols.patch +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA +) + +vcpkg_install_cmake() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +file(COPY ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/libsquish) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/libsquish/LICENSE.txt ${CURRENT_PACKAGES_DIR}/share/libsquish/copyright)