vcpkg/ports/mozjpeg/portfile.cmake

61 lines
2.5 KiB
CMake
Raw Normal View History

if(EXISTS "${CURRENT_INSTALLED_DIR}/share/libjpeg-turbo/copyright")
message(FATAL_ERROR "Can't build ${PORT} if libjpeg-turbo is installed. Please remove libjpeg-turbo:${TARGET_TRIPLET}, and try to install ${PORT}:${TARGET_TRIPLET} again.")
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO mozilla/mozjpeg
REF a2d2907ff023227e80c1e4efa809812410275a12 #v4.1.1
SHA512 77c003406a0b86859c461d92bd216168d6c4f5d55735e4a9ab473d3dbcad03fd4e398204f884dfd03f0fa883da296ac05a8c5242aa40792a3e179627e51db154
HEAD_REF master
PATCHES
fix-install-error.patch
2017-10-06 00:15:42 +08:00
)
vcpkg_find_acquire_program(NASM)
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
vcpkg_add_to_path(${NASM_EXE_PATH})
2017-10-06 00:15:42 +08:00
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_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DENABLE_SHARED=${ENABLE_SHARED}
-DENABLE_STATIC=${ENABLE_STATIC}
-DWITH_CRT_DLL=${WITH_CRT_DLL}
2017-10-06 00:15:42 +08:00
)
vcpkg_cmake_install()
2017-10-06 00:15:42 +08:00
# 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()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/mozjpeg)
# Remove extra debug files
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
2017-10-06 00:15:42 +08:00
vcpkg_copy_tools(TOOL_NAMES cjpeg djpeg jpegtran tjbench AUTO_CLEAN)
vcpkg_fixup_pkgconfig()
vcpkg_copy_pdbs()
# Remove empty folders after static build
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin")
2017-10-06 00:15:42 +08:00
endif()
# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)