Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update native libs, add custom libjpeg-turbo build
- Loading branch information
1 parent
9bd127e
commit 8e62ca7
Showing
18 changed files
with
998 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# switch to file-scoped namespaces | ||
9bd127e20ffe2923033ea5cd09495977bb893a1a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
set(_PKG_LIBS libheif libjxl libwebp) | ||
set(_PKG_LIBS libheif libjxl libwebp psjpeg) | ||
|
||
set(VCPKG_DISABLE_COMPILER_TRACKING true) |
176 changes: 176 additions & 0 deletions
176
build/vcpkg/ports/psjpeg/add-options-for-exes-docs-headers.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 10a198f..68ac5a3 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -168,6 +168,12 @@ option(ENABLE_SHARED "Build shared libraries" TRUE) | ||
boolean_number(ENABLE_SHARED) | ||
option(ENABLE_STATIC "Build static libraries" TRUE) | ||
boolean_number(ENABLE_STATIC) | ||
+option(ENABLE_EXECUTABLES "Build executables" TRUE) | ||
+boolean_number(ENABLE_EXECUTABLES) | ||
+option(INSTALL_DOCS "Install doc files" TRUE) | ||
+boolean_number(INSTALL_DOCS) | ||
+option(INSTALL_HEADERS "Install header files" TRUE) | ||
+boolean_number(INSTALL_HEADERS) | ||
option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE) | ||
boolean_number(REQUIRE_SIMD) | ||
option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE) | ||
@@ -634,6 +640,7 @@ if(WITH_TURBOJPEG) | ||
LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}") | ||
endif() | ||
|
||
+ if(ENABLE_EXECUTABLES) | ||
add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c) | ||
target_link_libraries(tjunittest turbojpeg) | ||
|
||
@@ -646,6 +653,7 @@ if(WITH_TURBOJPEG) | ||
add_executable(tjexample tjexample.c) | ||
target_link_libraries(tjexample turbojpeg) | ||
endif() | ||
+ endif() | ||
|
||
if(ENABLE_STATIC) | ||
add_library(turbojpeg-static STATIC ${JPEG_SOURCES} $<TARGET_OBJECTS:simd> | ||
@@ -657,6 +665,7 @@ if(WITH_TURBOJPEG) | ||
set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg) | ||
endif() | ||
|
||
+ if(ENABLE_EXECUTABLES) | ||
add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c | ||
md5/md5hl.c) | ||
target_link_libraries(tjunittest-static turbojpeg-static) | ||
@@ -666,6 +675,7 @@ if(WITH_TURBOJPEG) | ||
if(UNIX) | ||
target_link_libraries(tjbench-static m) | ||
endif() | ||
+ endif() | ||
endif() | ||
endif() | ||
|
||
@@ -680,7 +690,7 @@ else() | ||
set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c) | ||
endif() | ||
|
||
-if(ENABLE_STATIC) | ||
+if(ENABLE_STATIC AND ENABLE_EXECUTABLES) | ||
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c | ||
${CJPEG_BMP_SOURCES}) | ||
set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) | ||
@@ -696,10 +706,11 @@ if(ENABLE_STATIC) | ||
set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "${USE_SETMODE}") | ||
endif() | ||
|
||
+if(ENABLE_EXECUTABLES) | ||
add_executable(rdjpgcom rdjpgcom.c) | ||
|
||
add_executable(wrjpgcom wrjpgcom.c) | ||
- | ||
+endif() | ||
|
||
############################################################################### | ||
# TESTS | ||
@@ -1434,8 +1445,10 @@ if(WITH_TURBOJPEG) | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
+ if(ENABLE_EXECUTABLES) | ||
install(TARGETS tjbench | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
+ endif() | ||
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND | ||
CMAKE_C_LINKER_SUPPORTS_PDB) | ||
install(FILES "$<TARGET_PDB_FILE:turbojpeg>" | ||
@@ -1446,7 +1459,7 @@ if(WITH_TURBOJPEG) | ||
install(TARGETS turbojpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
- if(NOT ENABLE_SHARED) | ||
+ if(NOT ENABLE_SHARED AND ENABLE_EXECUTABLES) | ||
if(MSVC_IDE OR XCODE) | ||
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}") | ||
else() | ||
@@ -1456,15 +1469,17 @@ if(WITH_TURBOJPEG) | ||
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE}) | ||
endif() | ||
endif() | ||
+ if(INSTALL_HEADERS) | ||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
+ endif() | ||
endif() | ||
|
||
if(ENABLE_STATIC) | ||
install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
- if(NOT ENABLE_SHARED) | ||
+ if(NOT ENABLE_SHARED AND ENABLE_EXECUTABLES) | ||
if(MSVC_IDE OR XCODE) | ||
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}") | ||
else() | ||
@@ -1479,8 +1494,11 @@ if(ENABLE_STATIC) | ||
endif() | ||
endif() | ||
|
||
+if(ENABLE_EXECUTABLES) | ||
install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
+endif() | ||
|
||
+if(INSTALL_DOCS) | ||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg | ||
${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt | ||
${CMAKE_CURRENT_SOURCE_DIR}/tjexample.c | ||
@@ -1492,8 +1510,9 @@ if(WITH_JAVA) | ||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java | ||
DESTINATION ${CMAKE_INSTALL_DOCDIR}) | ||
endif() | ||
+endif() | ||
|
||
-if(UNIX OR MINGW) | ||
+if((UNIX OR MINGW) AND INSTALL_DOCS) | ||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cjpeg.1 | ||
${CMAKE_CURRENT_SOURCE_DIR}/djpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/jpegtran.1 | ||
${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1 | ||
@@ -1511,10 +1530,12 @@ install(EXPORT ${CMAKE_PROJECT_NAME}Targets | ||
NAMESPACE ${CMAKE_PROJECT_NAME}:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}) | ||
|
||
+if(INSTALL_HEADERS) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
+endif() | ||
|
||
include(cmakescripts/BuildPackages.cmake) | ||
|
||
diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt | ||
index 78a2f28..e653b2d 100644 | ||
--- a/sharedlib/CMakeLists.txt | ||
+++ b/sharedlib/CMakeLists.txt | ||
@@ -71,6 +71,7 @@ else() | ||
set(DJPEG_BMP_SOURCES ../wrbmp.c ../wrtarga.c) | ||
endif() | ||
|
||
+if(ENABLE_EXECUTABLES) | ||
add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c | ||
../rdswitch.c ${CJPEG_BMP_SOURCES}) | ||
set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) | ||
@@ -87,14 +88,17 @@ set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "${USE_SETMODE}") | ||
|
||
add_executable(jcstest ../jcstest.c) | ||
target_link_libraries(jcstest jpeg) | ||
+endif() | ||
|
||
install(TARGETS jpeg EXPORT ${CMAKE_PROJECT_NAME}Targets | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
+if(ENABLE_EXECUTABLES) | ||
install(TARGETS cjpeg djpeg jpegtran | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
+endif() | ||
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND | ||
CMAKE_C_LINKER_SUPPORTS_PDB) | ||
install(FILES "$<TARGET_PDB_FILE:jpeg>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
if(EXISTS "${CURRENT_INSTALLED_DIR}/share/mozjpeg/copyright") | ||
message(FATAL_ERROR "Can't build ${PORT} if mozjpeg is installed. Please remove mozjpeg:${TARGET_TRIPLET}, and try to install ${PORT}:${TARGET_TRIPLET} again.") | ||
endif() | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO libjpeg-turbo/libjpeg-turbo | ||
REF 2.1.4 | ||
SHA512 d3e92d614168355827e0ed884ff847cc7df8f6f1fb7b673c6c99afdf61fdfc0372afe5d30fdbf5e743335e2a7a27ca9f510c67d213e5cb2315a8d946e9414575 | ||
HEAD_REF master | ||
PATCHES | ||
add-options-for-exes-docs-headers.patch | ||
psjpeg-customize-build.patch | ||
psjpeg-customize-code.patch | ||
) | ||
|
||
file(COPY ${CURRENT_PORT_DIR}/psjpeg.c DESTINATION ${SOURCE_PATH}) | ||
file(COPY ${CURRENT_PORT_DIR}/psjpeg.h DESTINATION ${SOURCE_PATH}) | ||
|
||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR (VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")) | ||
set(LIBJPEGTURBO_SIMD -DWITH_SIMD=ON -DNEON_INTRINSICS=ON) | ||
else() | ||
set(LIBJPEGTURBO_SIMD -DWITH_SIMD=ON) | ||
vcpkg_find_acquire_program(NASM) | ||
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) | ||
set(ENV{PATH} "$ENV{PATH};${NASM_EXE_PATH}") | ||
endif() | ||
|
||
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") | ||
set(ENV{_CL_} "-DNO_GETENV -DNO_PUTENV") | ||
endif() | ||
|
||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ENABLE_SHARED) | ||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC) | ||
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" WITH_CRT_DLL) | ||
|
||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | ||
FEATURES | ||
jpeg7 WITH_JPEG7 | ||
jpeg8 WITH_JPEG8 | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS | ||
-DENABLE_STATIC=${ENABLE_STATIC} | ||
-DENABLE_SHARED=${ENABLE_SHARED} | ||
-DREQUIRE_SIMD=ON | ||
-DWITH_MEM_SRCDST=OFF | ||
-DWITH_TURBOJPEG=OFF | ||
-DENABLE_EXECUTABLES=OFF | ||
-DINSTALL_DOCS=OFF | ||
-DWITH_CRT_DLL=${WITH_CRT_DLL} | ||
${FEATURE_OPTIONS} | ||
${LIBJPEGTURBO_SIMD} | ||
OPTIONS_DEBUG | ||
-DINSTALL_HEADERS=OFF | ||
MAYBE_UNUSED_VARIABLES | ||
WITH_CRT_DLL | ||
) | ||
|
||
vcpkg_cmake_install() | ||
vcpkg_copy_pdbs() | ||
|
||
vcpkg_fixup_pkgconfig() | ||
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libjpeg-turbo) | ||
|
||
# Rename libraries for static builds | ||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") | ||
if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/jpeg-static.lib") | ||
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/jpeg-static.lib" "${CURRENT_PACKAGES_DIR}/lib/jpeg.lib") | ||
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/turbojpeg-static.lib" "${CURRENT_PACKAGES_DIR}/lib/turbojpeg.lib") | ||
endif() | ||
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg-static.lib") | ||
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg.lib") | ||
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg.lib") | ||
endif() | ||
|
||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") | ||
|
||
if (EXISTS "${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-debug.cmake") | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-debug.cmake" | ||
"jpeg-static${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "jpeg${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}") | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-debug.cmake" | ||
"turbojpeg-static${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "turbojpeg${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}") | ||
endif() | ||
if (EXISTS "${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-release.cmake") | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-release.cmake" | ||
"jpeg-static${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "jpeg${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}") | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-release.cmake" | ||
"turbojpeg-static${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "turbojpeg${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}") | ||
endif() | ||
endif() | ||
|
||
file(REMOVE_RECURSE | ||
"${CURRENT_PACKAGES_DIR}/debug/share" | ||
"${CURRENT_PACKAGES_DIR}/debug/include" | ||
"${CURRENT_PACKAGES_DIR}/share/man") | ||
|
||
file(INSTALL "${SOURCE_PATH}/LICENSE.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index cf2fa1e..c298606 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -588,7 +588,7 @@ if(WITH_JAVA) | ||
add_subdirectory(java) | ||
endif() | ||
|
||
-if(ENABLE_SHARED) | ||
+if(ENABLE_SHARED AND WITH_TURBOJPEG) | ||
add_subdirectory(sharedlib) | ||
endif() | ||
|
||
@@ -679,6 +679,11 @@ if(WITH_TURBOJPEG) | ||
endif() | ||
endif() | ||
|
||
+set(PSJPEG_SOURCES ${JPEG_SOURCES} $<TARGET_OBJECTS:simd> ${SIMD_OBJS} psjpeg.c) | ||
+set(CMAKE_C_VISIBILITY_PRESET hidden) | ||
+add_library(psjpeg SHARED ${PSJPEG_SOURCES}) | ||
+set_target_properties(psjpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE) | ||
+ | ||
if(WIN32) | ||
set(USE_SETMODE "-DUSE_SETMODE") | ||
endif() | ||
@@ -1475,6 +1480,17 @@ if(WITH_TURBOJPEG) | ||
endif() | ||
endif() | ||
|
||
+install(TARGETS psjpeg EXPORT ${CMAKE_PROJECT_NAME}Targets | ||
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
+if(MSVC AND CMAKE_C_LINKER_SUPPORTS_PDB) | ||
+ install(FILES "$<TARGET_PDB_FILE:psjpeg>" | ||
+ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) | ||
+endif() | ||
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/psjpeg.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
+ | ||
if(ENABLE_STATIC) | ||
install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
Oops, something went wrong.