vcpkg/ports/x265/portfile.cmake
Long Nguyen 02f6b89775
[many ports] mingw support (#14556)
* [vcpkg_configure_make] Only rename import libs on MSVC

* [x264] Only rename import libs on MSVC

* [x265] Add libc++ and libstdc++ as system libs

* [ffmpeg] mingw support

* [libvpx] Set AS environment variable

* [vcpkg_common_definition] Fix a mistake in the prefix and suffix variables

* [vcpkg_configure_make] Strip leading -l from lib list before joining

* [mp3lame] Use vcpkg_configure_make + mingw support

* [x265] Escape the pluses

* [ffmpeg] Add compiler flags for mingw

* [ffmpeg] Add WINVER define in mf_utils.c

* [ffmpeg] Remove unnecessary patch in 0003-fic-windowsinclude.patch

* [mp3lame] Add missing dollar sign

Co-authored-by: Matthias C. M. Troffaes <matthias.troffaes@gmail.com>

* [x265] Remove static lib when building shared with mingw

* [libogg] Change library name to libogg on mingw

* [libogg] Bump port version

* [x265] Remove -l(std)c++ flag in pkgconfig file

* [vcpkg_configure_make] Try to fix huge diff

* [mp3lame] Add comment on deprecated function lame_init_old

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>

Co-authored-by: Matthias C. M. Troffaes <matthias.troffaes@gmail.com>
Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
2020-12-01 14:13:58 -08:00

73 lines
2.3 KiB
CMake

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO videolan/x265
REF 07295ba7ab551bb9c1580fdaee3200f1b45711b7 #v3.4
SHA512 21a4ef8733a9011eec8b336106c835fbe04689e3a1b820acb11205e35d2baba8c786d9d8cf5f395e78277f921857e4eb8622cf2ef3597bce952d374f7fe9ec29
HEAD_REF master
PATCHES
disable-install-pdb.patch
)
set(ENABLE_ASSEMBLY OFF)
if (VCPKG_TARGET_IS_WINDOWS)
vcpkg_find_acquire_program(NASM)
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
set(ENV{PATH} "$ENV{PATH};${NASM_EXE_PATH}")
set(ENABLE_ASSEMBLY ON)
endif ()
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ENABLE_SHARED)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/source
PREFER_NINJA
OPTIONS
-DENABLE_ASSEMBLY=${ENABLE_ASSEMBLY}
-DENABLE_SHARED=${ENABLE_SHARED}
OPTIONS_DEBUG
-DENABLE_CLI=OFF
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
# remove duplicated include files
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
vcpkg_copy_tools(TOOL_NAMES x265 AUTO_CLEAN)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR VCPKG_TARGET_IS_LINUX)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
endif()
if(VCPKG_TARGET_IS_WINDOWS AND (NOT VCPKG_TARGET_IS_MINGW))
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/x265.pc" "-lx265" "-lx265-static")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/x265.pc" "-lx265" "-lx265-static")
endif()
endif()
# maybe create vcpkg_regex_replace_string?
file(READ ${CURRENT_PACKAGES_DIR}/lib/pkgconfig/x265.pc _contents)
string(REGEX REPLACE "-l(std)?c\\+\\+" "" _contents "${_contents}")
file(WRITE ${CURRENT_PACKAGES_DIR}/lib/pkgconfig/x265.pc "${_contents}")
file(READ ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/x265.pc _contents)
string(REGEX REPLACE "-l(std)?c\\+\\+" "" _contents "${_contents}")
file(WRITE ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/x265.pc "${_contents}")
if(VCPKG_TARGET_IS_MINGW AND ENABLE_SHARED)
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/libx265.a)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libx265.a)
endif()
if(UNIX)
vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES numa)
else()
vcpkg_fixup_pkgconfig()
endif()
# Handle copyright
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)