2021-01-12 08:12:01 +08:00
# Build-Depends: From X Window PR: zstd, drm (!windows), elfutils (!windows), wayland (!windows), wayland-protocols (!windows), xdamage, xshmfence (!windows), x11, xcb, xfixes, xext, xxf86vm, xrandr, xv, xvmc (!windows), egl-registry, opengl-registry, tool-meson
# Required LLVM modules: LLVM (modules: bitwriter, core, coroutines, engine, executionengine, instcombine, mcdisassembler, mcjit, scalaropts, transformutils) found: YES
2021-06-30 07:08:28 +08:00
# Patches are from https://github.com/pal1000/mesa-dist-win/tree/master/patches
set ( PATCHES
# Fix swrAVX512 build
s w r a v x 5 1 2 - p o s t - s t a t i c - l i n k . p a t c h
2021-12-21 00:21:15 +08:00
# Fix swr build with MSVC
s w r - m s v c - 2 . p a t c h
# Fix swr build with LLVM 13
s w r - l l v m 1 3 . p a t c h
# Fix radv MSVC build with LLVM 13
r a d v - m s v c - l l v m 1 3 - 2 . p a t c h
# Fix d3d10sw MSVC build
d 3 d 1 0 s w . p a t c h
2021-06-30 07:08:28 +08:00
)
2021-01-12 08:12:01 +08:00
vcpkg_check_linkage ( ONLY_DYNAMIC_CRT )
2021-06-30 07:08:28 +08:00
if ( VCPKG_TARGET_IS_WINDOWS )
2021-01-12 08:12:01 +08:00
set ( VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled ) # some parts of this port can only build as a shared library.
endif ( )
vcpkg_from_gitlab (
G I T L A B _ U R L h t t p s : / / g i t l a b . f r e e d e s k t o p . o r g
O U T _ S O U R C E _ P A T H S O U R C E _ P A T H
R E P O m e s a / m e s a
2021-12-21 00:21:15 +08:00
R E F m e s a - 2 1 . 2 . 5
2022-01-19 07:45:42 +08:00
S H A 5 1 2 a 9 e a d 2 7 f 0 8 e 8 6 2 7 3 8 9 3 8 c f 7 2 8 9 2 8 b 7 9 3 7 f f 3 7 e 4 c 2 6 9 6 7 f 2 e 4 6 e 4 0 a 3 c 8 4 1 9 1 5 9 3 9 7 f 7 5 b 2 f 4 c e 4 3 f 9 b 4 5 3 b 3 5 b b 3 7 1 6 d f 5 8 1 0 8 7 f b 7 b a 8 4 3 4 f a f d f a b 9 4 8 8 c 3 d b 6 f 9 2
F I L E _ D I S A M B I G U A T O R 1
2021-06-30 07:08:28 +08:00
H E A D _ R E F m a s t e r
P A T C H E S $ { P A T C H E S }
2021-01-12 08:12:01 +08:00
)
vcpkg_find_acquire_program ( PYTHON3 )
get_filename_component ( PYTHON3_DIR "${PYTHON3}" DIRECTORY )
vcpkg_add_to_path ( "${PYTHON3_DIR}" )
vcpkg_add_to_path ( "${PYTHON3_DIR}/Scripts" )
set ( ENV{PYTHON} "${PYTHON3}" )
function ( vcpkg_get_python_package PYTHON_DIR )
cmake_parse_arguments ( PARSE_ARGV 0 _vgpp "" "PYTHON_EXECUTABLE" "PACKAGES" )
if ( NOT _vgpp_PYTHON_EXECUTABLE )
message ( FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} requires parameter PYTHON_EXECUTABLE!" )
endif ( )
if ( NOT _vgpp_PACKAGES )
message ( FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} requires parameter PACKAGES!" )
endif ( )
if ( NOT _vgpp_PYTHON_DIR )
get_filename_component ( _vgpp_PYTHON_DIR "${_vgpp_PYTHON_EXECUTABLE}" DIRECTORY )
endif ( )
if ( WIN32 )
set ( PYTHON_OPTION "" )
else ( )
set ( PYTHON_OPTION "--user" )
endif ( )
if ( "${_vgpp_PYTHON_DIR}" MATCHES "${DOWNLOADS}" ) # inside vcpkg
if ( NOT EXISTS "${_vgpp_PYTHON_DIR}/easy_install${VCPKG_HOST_EXECUTABLE_SUFFIX}" )
if ( NOT EXISTS "${_vgpp_PYTHON_DIR}/Scripts/pip${VCPKG_HOST_EXECUTABLE_SUFFIX}" )
vcpkg_from_github (
O U T _ S O U R C E _ P A T H P Y F I L E _ P A T H
R E P O p y p a / g e t - p i p
R E F 3 0 9 a 5 6 c 5 f d 9 4 b d 1 1 3 4 0 5 3 a 5 4 1 c b 4 6 5 7 a 4 e 4 7 e 0 9 d #2019-08-25
S H A 5 1 2 b b 4 b 0 7 4 5 9 9 8 a 3 2 0 5 c d 0 f 0 9 6 3 c 0 4 f b 4 5 f 4 6 1 4 b a 3 b 6 f c b e 9 7 e f e 8 f 8 6 1 4 1 9 2 f 2 4 4 b 7 a e 6 2 7 0 5 4 8 3 a 5 3 0 5 9 4 3 d 6 c 8 f e d e c a 5 3 b 2 e 9 9 0 5 a e d 9 1 8 d 2 c 6 1 0 6 f 8 a 9 6 8 0 1 8 4 c 7 a
H E A D _ R E F m a s t e r
)
execute_process ( COMMAND "${_vgpp_PYTHON_EXECUTABLE}" "${PYFILE_PATH}/get-pip.py" ${ PYTHON_OPTION } )
endif ( )
foreach ( _package IN LISTS _vgpp_PACKAGES )
execute_process ( COMMAND "${_vgpp_PYTHON_DIR}/Scripts/pip${VCPKG_HOST_EXECUTABLE_SUFFIX}" install ${ _package } ${ PYTHON_OPTION } )
endforeach ( )
else ( )
foreach ( _package IN LISTS _vgpp_PACKAGES )
execute_process ( COMMAND "${_vgpp_PYTHON_DIR}/easy_install${VCPKG_HOST_EXECUTABLE_SUFFIX}" ${ _package } )
endforeach ( )
endif ( )
if ( NOT VCPKG_TARGET_IS_WINDOWS )
execute_process ( COMMAND pip3 install ${ _vgpp_PACKAGES } )
endif ( )
else ( ) # outside vcpkg
foreach ( _package IN LISTS _vgpp_PACKAGES )
execute_process ( COMMAND ${ _vgpp_PYTHON_EXECUTABLE } -c "import ${_package}" RESULT_VARIABLE HAS_ERROR )
if ( HAS_ERROR )
message ( FATAL_ERROR "Python package '${_package}' needs to be installed for port '${PORT}'.\nComplete list of required python packages: ${_vgpp_PACKAGES}" )
endif ( )
endforeach ( )
endif ( )
endfunction ( )
vcpkg_get_python_package ( PYTHON_EXECUTABLE "${PYTHON3}" PACKAGES setuptools mako )
vcpkg_find_acquire_program ( FLEX )
get_filename_component ( FLEX_DIR "${FLEX}" DIRECTORY )
vcpkg_add_to_path ( PREPEND "${FLEX_DIR}" )
vcpkg_find_acquire_program ( BISON )
get_filename_component ( BISON_DIR "${BISON}" DIRECTORY )
vcpkg_add_to_path ( PREPEND "${BISON_DIR}" )
if ( WIN32 ) # WIN32 HOST probably has win_flex and win_bison!
if ( NOT EXISTS "${FLEX_DIR}/flex${VCPKG_HOST_EXECUTABLE_SUFFIX}" )
if ( FLEX_DIR MATCHES "${DOWNLOADS}" )
file ( CREATE_LINK "${FLEX}" "${FLEX_DIR}/flex${VCPKG_HOST_EXECUTABLE_SUFFIX}" )
else ( )
message ( FATAL_ERROR "${PORT} requires flex being named flex on windows and not win_flex!\n(Can be solved by creating a simple link from win_flex to flex)" )
endif ( )
endif ( )
if ( NOT EXISTS "${BISON_DIR}/BISON${VCPKG_HOST_EXECUTABLE_SUFFIX}" )
if ( BISON_DIR MATCHES "${DOWNLOADS}" )
file ( CREATE_LINK "${BISON}" "${BISON_DIR}/bison${VCPKG_HOST_EXECUTABLE_SUFFIX}" )
else ( )
message ( FATAL_ERROR "${PORT} requires bison being named bison on windows and not win_bison!\n(Can be solved by creating a simple link from win_bison to bison)" )
endif ( )
endif ( )
endif ( )
# For features https://github.com/pal1000/mesa-dist-win should be probably studied a bit more.
#string(APPEND GALLIUM_DRIVERS 'auto')
list ( APPEND MESA_OPTIONS -Dzstd=enabled )
list ( APPEND MESA_OPTIONS -Dshared-llvm=auto )
list ( APPEND MESA_OPTIONS -Dlibunwind=disabled )
list ( APPEND MESA_OPTIONS -Dlmsensors=disabled )
list ( APPEND MESA_OPTIONS -Dvalgrind=disabled )
list ( APPEND MESA_OPTIONS -Dglvnd=false )
list ( APPEND MESA_OPTIONS -Dglx=disabled )
list ( APPEND MESA_OPTIONS -Dgbm=disabled )
2021-06-30 07:08:28 +08:00
list ( APPEND MESA_OPTIONS -Dosmesa=true )
2021-01-12 08:12:01 +08:00
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
list ( APPEND MESA_OPTIONS -Dshared-swr=false )
list ( APPEND MESA_OPTIONS "-Dswr-arches=['avx']" )
else ( )
list ( APPEND MESA_OPTIONS -Dshared-swr=true )
list ( APPEND MESA_OPTIONS "-Dswr-arches=['avx','avx2','knl','skx']" )
endif ( )
string ( APPEND GALLIUM_DRIVERS 'swrast' )
if ( "llvm" IN_LIST FEATURES )
list ( APPEND MESA_OPTIONS -Dllvm=enabled )
string ( APPEND GALLIUM_DRIVERS ",'swr'" ) # SWR always requires llvm
else ( )
list ( APPEND MESA_OPTIONS -Dllvm=disabled )
endif ( )
list ( APPEND MESA_OPTIONS -Dgallium-drivers=[ ${ GALLIUM_DRIVERS } ] )
if ( "gles1" IN_LIST FEATURES )
list ( APPEND MESA_OPTIONS -Dgles1=enabled )
else ( )
list ( APPEND MESA_OPTIONS -Dgles1=disabled )
endif ( )
if ( "gles2" IN_LIST FEATURES )
list ( APPEND MESA_OPTIONS -Dgles2=enabled )
else ( )
list ( APPEND MESA_OPTIONS -Dgles2=disabled )
endif ( )
if ( "opengl" IN_LIST FEATURES )
list ( APPEND MESA_OPTIONS -Dopengl=true )
else ( )
list ( APPEND MESA_OPTIONS -Dopengl=false )
endif ( )
if ( "egl" IN_LIST FEATURES ) # EGL feature only works on Linux
list ( APPEND MESA_OPTIONS -Degl=enabled )
else ( )
list ( APPEND MESA_OPTIONS -Degl=disabled )
endif ( )
list ( APPEND MESA_OPTIONS -Dshared-glapi=enabled ) #shared GLAPI required when building two or more of the following APIs - opengl, gles1 gles2
if ( VCPKG_TARGET_IS_WINDOWS )
list ( APPEND MESA_OPTIONS -Dplatforms=['windows'] )
2021-06-30 07:08:28 +08:00
list ( APPEND MESA_OPTIONS -Dmicrosoft-clc=disabled )
2022-01-25 04:21:52 +08:00
if ( NOT VCPKG_TARGET_IS_MINGW )
set ( VCPKG_CXX_FLAGS "/D_CRT_DECLARE_NONSTDC_NAMES ${VCPKG_CXX_FLAGS}" )
set ( VCPKG_C_FLAGS "/D_CRT_DECLARE_NONSTDC_NAMES ${VCPKG_C_FLAGS}" )
endif ( )
2021-01-12 08:12:01 +08:00
endif ( )
2022-01-25 04:21:52 +08:00
2021-01-12 08:12:01 +08:00
vcpkg_configure_meson (
S O U R C E _ P A T H " $ { S O U R C E _ P A T H } "
O P T I O N S
2021-01-23 02:27:34 +08:00
- D g l e s - l i b - s u f f i x = _ m e s a
2021-01-12 08:12:01 +08:00
#-D egl-lib-suffix=_mesa
- D b u i l d - t e s t s = f a l s e
$ { M E S A _ O P T I O N S }
)
vcpkg_install_meson ( )
vcpkg_fixup_pkgconfig ( )
2022-01-19 07:45:42 +08:00
file ( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" )
file ( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share" )
2021-01-12 08:12:01 +08:00
#installed by egl-registry
2022-01-19 07:45:42 +08:00
file ( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/KHR" )
file ( REMOVE "${CURRENT_PACKAGES_DIR}/include/EGL/egl.h" )
file ( REMOVE "${CURRENT_PACKAGES_DIR}/include/EGL/eglext.h" )
file ( REMOVE "${CURRENT_PACKAGES_DIR}/include/EGL/eglplatform.h" )
2021-01-12 08:12:01 +08:00
#installed by opengl-registry
set ( _double_files include/GL/glcorearb.h include/GL/glext.h include/GL/glxext.h
i n c l u d e / G L E S / e g l . h i n c l u d e / G L E S / g l . h i n c l u d e / G L E S / g l e x t . h i n c l u d e / G L E S / g l p l a t f o r m . h
i n c l u d e / G L E S 2 / g l 2 . h i n c l u d e / G L E S 2 / g l 2 e x t . h i n c l u d e / G L E S 2 / g l 2 p l a t f o r m . h
i n c l u d e / G L E S 3 / g l 3 . h i n c l u d e / G L E S 3 / g l 3 1 . h i n c l u d e / G L E S 3 / g l 3 2 . h i n c l u d e / G L E S 3 / g l 3 p l a t f o r m . h )
list ( TRANSFORM _double_files PREPEND "${CURRENT_PACKAGES_DIR}/" )
file ( REMOVE ${ _double_files } )
2022-01-19 07:45:42 +08:00
file ( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/GLES" )
file ( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/GLES2" )
2021-12-21 00:21:15 +08:00
# Handle copyright
2021-01-12 08:12:01 +08:00
file ( MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}" )
file ( TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" )