[mozjpeg] fix build (#12118)

* fix mozjpeg build

* re-disable in CI baseline

* fix static install

* rename static libs, add pkgconfig fixup

* update version string

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
Clinton Ingram 2020-07-30 22:38:32 -07:00 committed by GitHub
parent fe19c5e411
commit 3513e92bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 120 deletions

View File

@ -1,4 +1,5 @@
Source: mozjpeg Source: mozjpeg
Version: 2020-06-02 Version: 2020-06-02-1
Build-Depends: libpng
Homepage: https://github.com/mozilla/mozjpeg Homepage: https://github.com/mozilla/mozjpeg
Description: MozJPEG reduces file sizes of JPEG images while retaining quality and compatibility with the vast majority of the world's deployed decoders. It's compatible with libjpeg API and ABI, and can be used as a drop-in replacement for libjpeg. Description: MozJPEG reduces file sizes of JPEG images while retaining quality and compatibility with the vast majority of the world's deployed decoders. It's compatible with libjpeg API and ABI, and can be used as a drop-in replacement for libjpeg.

View File

@ -1,126 +1,33 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51f4714..9ca3463 100644
--- a/CMakeLists.txt --- a/CMakeLists.txt
+++ b/CMakeLists.txt +++ b/CMakeLists.txt
@@ -1370,21 +1370,28 @@ endif() @@ -1369,13 +1369,13 @@
###############################################################################
set(EXE ${CMAKE_EXECUTABLE_SUFFIX}) set(EXE ${CMAKE_EXECUTABLE_SUFFIX})
+if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(REAL_BUILDS_PATH "Debug/")
+else()
+ set(REAL_BUILDS_PATH "Release/")
+endif()
+
if(WITH_TURBOJPEG) if(WITH_TURBOJPEG)
if(ENABLE_SHARED) if(ENABLE_SHARED)
install(TARGETS turbojpeg tjbench - install(TARGETS turbojpeg tjbench
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + install(TARGETS turbojpeg #tjbench
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/mozjpeg RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mozjpeg
+ RUNTIME DESTINATION tools/mozjpeg)
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
CMAKE_C_LINKER_SUPPORTS_PDB) CMAKE_C_LINKER_SUPPORTS_PDB)
install(FILES "$<TARGET_PDB_FILE:turbojpeg>" install(FILES "$<TARGET_PDB_FILE:turbojpeg>"
- DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) @@ -1413,13 +1413,13 @@
+ DESTINATION ${CMAKE_INSTALL_BINDIR}/mozjpeg OPTIONAL) DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
endif()
endif()
if(ENABLE_STATIC)
- install(TARGETS turbojpeg-static ARCHIVE
- DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(TARGETS turbojpeg-static
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mozjpeg
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/mozjpeg)
if(NOT ENABLE_SHARED)
if(MSVC_IDE OR XCODE)
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
@@ -1392,15 +1399,15 @@ if(WITH_TURBOJPEG)
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
install(PROGRAMS ${DIR}/tjbench-static${EXE}
- DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
+ DESTINATION tools/mozjpeg RENAME tjbench${EXE})
endif()
endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mozjpeg)
endif()
if(ENABLE_STATIC)
- install(TARGETS jpeg-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(TARGETS jpeg-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/mozjpeg)
if(NOT ENABLE_SHARED)
if(MSVC_IDE OR XCODE)
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
@@ -1408,15 +1415,15 @@ if(ENABLE_STATIC)
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
install(PROGRAMS ${DIR}/cjpeg-static${EXE}
- DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
+ DESTINATION tools/mozjpeg RENAME cjpeg${EXE})
install(PROGRAMS ${DIR}/djpeg-static${EXE}
- DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
+ DESTINATION tools/mozjpeg RENAME djpeg${EXE})
install(PROGRAMS ${DIR}/jpegtran-static${EXE} install(PROGRAMS ${DIR}/jpegtran-static${EXE}
- DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE}) DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
+ DESTINATION tools/mozjpeg RENAME jpegtran${EXE})
endif() endif()
endif() endif()
-install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION tools/mozjpeg) +#install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt
@@ -1424,10 +1431,10 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg ${CMAKE_CURRENT_SOURCE_DIR}/tjexample.c
${CMAKE_CURRENT_SOURCE_DIR}/libjpeg.txt ${CMAKE_CURRENT_SOURCE_DIR}/libjpeg.txt
${CMAKE_CURRENT_SOURCE_DIR}/structure.txt ${CMAKE_CURRENT_SOURCE_DIR}/structure.txt
${CMAKE_CURRENT_SOURCE_DIR}/usage.txt ${CMAKE_CURRENT_SOURCE_DIR}/wizard.txt
- ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
+ ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION share/mozjpeg)
if(WITH_JAVA)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java
- DESTINATION ${CMAKE_INSTALL_DOCDIR})
+ DESTINATION share/mozjpeg)
endif()
if(UNIX OR MINGW)
@@ -1439,12 +1446,12 @@ if(UNIX OR MINGW)
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/mozjpeg)
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})
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mozjpeg)
include(cmakescripts/BuildPackages.cmake)
diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
index f0a7d87..1e82349 100644
--- a/sharedlib/CMakeLists.txt
+++ b/sharedlib/CMakeLists.txt
@@ -92,11 +92,11 @@ add_executable(jcstest ../jcstest.c)
target_link_libraries(jcstest jpeg)
install(TARGETS jpeg cjpeg djpeg jpegtran
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/mozjpeg
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mozjpeg
+ RUNTIME DESTINATION tools/mozjpeg)
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
CMAKE_C_LINKER_SUPPORTS_PDB)
install(FILES "$<TARGET_PDB_FILE:jpeg>"
- DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
+ DESTINATION ${CMAKE_INSTALL_BINDIR}/mozjpeg OPTIONAL)
endif()

View File

@ -12,34 +12,41 @@ vcpkg_find_acquire_program(NASM)
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
vcpkg_add_to_path(${NASM_EXE_PATH}) vcpkg_add_to_path(${NASM_EXE_PATH})
if(VCPKG_LIBRARY_LINKAGE STREQUAL static) string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ENABLE_SHARED)
set(ENABLE_STATIC_BUILD ON) string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC)
set(ENABLE_SHARED_BUILD OFF)
else()
set(ENABLE_STATIC_BUILD OFF)
set(ENABLE_SHARED_BUILD ON)
endif()
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" WITH_CRT_DLL) string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" WITH_CRT_DLL)
vcpkg_configure_cmake( vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH} SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA PREFER_NINJA
OPTIONS OPTIONS
-DDENABLE_SHARED=${ENABLE_SHARED_BUILD} -DENABLE_SHARED=${ENABLE_SHARED}
-DENABLE_STATIC=${ENABLE_STATIC_BUILD} -DENABLE_STATIC=${ENABLE_STATIC}
-DWITH_CRT_DLL=${WITH_CRT_DLL} -DWITH_CRT_DLL=${WITH_CRT_DLL}
) )
vcpkg_install_cmake() vcpkg_install_cmake()
#remove extra debug files # 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()
endif()
# Remove extra debug files
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
vcpkg_copy_tools(${CURRENT_PACKAGES_DIR}/tools/mozjpeg) vcpkg_copy_tools(TOOL_NAMES cjpeg djpeg jpegtran AUTO_CLEAN)
vcpkg_fixup_pkgconfig()
#remove empty folders after static build # Remove empty folders after static build
if (VCPKG_LIBRARY_LINKAGE STREQUAL static) if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)

View File

@ -1083,6 +1083,7 @@ moos-core:x86-windows=fail
moos-essential:arm64-windows=fail moos-essential:arm64-windows=fail
moos-essential:x64-windows=fail moos-essential:x64-windows=fail
moos-essential:x86-windows=fail moos-essential:x86-windows=fail
# Conflicts with libjpeg-turbo
mozjpeg:arm64-windows = skip mozjpeg:arm64-windows = skip
mozjpeg:arm-uwp = skip mozjpeg:arm-uwp = skip
mozjpeg:x64-linux = skip mozjpeg:x64-linux = skip
@ -1943,4 +1944,4 @@ ctp:x64-windows=skip
ctp:x64-windows-static=skip ctp:x64-windows-static=skip
ctp:x86-windows=skip ctp:x86-windows=skip
protozero:arm-uwp=fail protozero:arm-uwp=fail
protozero:x64-uwp=fail protozero:x64-uwp=fail