vcpkg/ports/x264/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

89 lines
2.8 KiB
CMake

set(X264_VERSION 157)
vcpkg_fail_port_install(ON_TARGET "OSX")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO mirror/x264
REF 303c484ec828ed0d8bfe743500e70314d026c3bd
SHA512 faf210a3f9543028ed882c8348b243dd7ae6638e7b3ef43bec1326b717f23370f57c13d0ddb5e1ae94411088a2e33031a137b68ae9f64c18f8f33f601a0da54d
HEAD_REF master
PATCHES
"uwp-cflags.patch"
)
vcpkg_find_acquire_program(NASM)
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
set(ENV{PATH} "$ENV{PATH};${NASM_EXE_PATH}")
if(VCPKG_TARGET_IS_WINDOWS)
_vcpkg_determine_autotools_host_cpu(BUILD_ARCH)
_vcpkg_determine_autotools_target_cpu(HOST_ARCH)
list(APPEND OPTIONS --build=${BUILD_ARCH}-pc-mingw32)
list(APPEND OPTIONS --host=${HOST_ARCH}-pc-mingw32)
set(ENV{AS} "${NASM}")
endif()
if(VCPKG_TARGET_IS_UWP)
list(APPEND OPTIONS --extra-cflags=-DWINAPI_FAMILY=WINAPI_FAMILY_APP --extra-cflags=-D_WIN32_WINNT=0x0A00)
list(APPEND OPTIONS --extra-ldflags=-APPCONTAINER --extra-ldflags=WindowsApp.lib)
list(APPEND OPTIONS --disable-asm)
endif()
if(VCPKG_TARGET_IS_LINUX)
list(APPEND OPTIONS --enable-pic)
endif()
vcpkg_configure_make(
SOURCE_PATH ${SOURCE_PATH}
NO_ADDITIONAL_PATHS
OPTIONS
${OPTIONS}
--enable-strip
--disable-lavf
--disable-swscale
--disable-avs
--disable-ffms
--disable-gpac
--disable-lsmash
--enable-debug
)
vcpkg_install_make()
vcpkg_copy_tools(TOOL_NAMES x264 AUTO_CLEAN)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
if(VCPKG_TARGET_IS_WINDOWS)
set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/x264.pc")
if(EXISTS "${pcfile}")
vcpkg_replace_string("${pcfile}" "-lx264" "-llibx264")
endif()
set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/x264.pc")
if(EXISTS "${pcfile}")
vcpkg_replace_string("${pcfile}" "-lx264" "-llibx264")
endif()
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libx264.dll.lib ${CURRENT_PACKAGES_DIR}/lib/libx264.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libx264.dll.lib ${CURRENT_PACKAGES_DIR}/debug/lib/libx264.lib)
elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
# force U_STATIC_IMPLEMENTATION macro
file(READ ${CURRENT_PACKAGES_DIR}/include/x264.h HEADER_CONTENTS)
string(REPLACE "defined(U_STATIC_IMPLEMENTATION)" "1" HEADER_CONTENTS "${HEADER_CONTENTS}")
file(WRITE ${CURRENT_PACKAGES_DIR}/include/x264.h "${HEADER_CONTENTS}")
file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/bin
${CURRENT_PACKAGES_DIR}/debug/bin
)
endif()
vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES -lpthread -lm -ldl)
vcpkg_copy_pdbs()
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)