vcpkg/ports/libjpeg-turbo/portfile.cmake
Alexander Neumann 460f40992b
[libjepg-turbo] Fix *.pc files (#15735)
* [libjpeg-turbo] fix pkgconfig

* add version info

* Update ports/libjpeg-turbo/portfile.cmake

* update baseline

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
2021-01-19 22:30:34 -08:00

92 lines
3.8 KiB
CMake

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 ae87a958613b69628b92088b313ded0d4f59a716 # 2.0.5
SHA512 25e8857a3542cc74c48775959f11811529fe6a853990cb285f91a6218c1cde5dd1e58043208e81709fb7a71c376396b2de1f20b53b2c5b8595ca097fa02992fd
HEAD_REF master
PATCHES
add-options-for-exes-docs-headers.patch
#workaround for vcpkg bug see #5697 on github for more information
workaround_cmake_system_processor.patch
fix-incompatibility-for-c11-c17.patch
)
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=OFF)
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
jpeg7 WITH_JPEG7
jpeg8 WITH_JPEG8
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DENABLE_STATIC=${ENABLE_STATIC}
-DENABLE_SHARED=${ENABLE_SHARED}
-DENABLE_EXECUTABLES=OFF
-DINSTALL_DOCS=OFF
-DWITH_CRT_DLL=${WITH_CRT_DLL}
${FEATURE_OPTIONS}
${LIBJPEGTURBO_SIMD}
OPTIONS_DEBUG -DINSTALL_HEADERS=OFF
)
vcpkg_install_cmake()
# 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/jpegd.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpegd.lib")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()
else(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/jpegd.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpegd.lib")
endif()
endif()
set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libjpeg.pc")
if(EXISTS "${_file}" AND VCPKG_TARGET_IS_WINDOWS)
vcpkg_replace_string("${_file}" "-ljpeg" "-ljpegd")
endif()
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share/man)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/jpeg)
file(INSTALL ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
vcpkg_copy_pdbs()