[meson|scripts] update scripts (#12945)

* Update meson to a recent commit to fix a bug with 0.56

* rename static libraries built by meson by default on windows

* apply cmake variables detection to meson.
use native/cross files
make arm builds work.

* update munit

* fix fribidi

* fix _FLAGS variables

* set env SDKROOT and MACOSX_DEPLOYMENT_TARGET in configure_meson

* need osx env while building and configuring

* - remove unused env backup functions
- rename internal functions to be prefixed with _vcpkg_
- fix VCPKG_CHAINLOAD_TOOLCHAIN_FILE for ios/freebsd

* replace _vcpkg with vcpkg since _ has special meaning in functions

* rename functions to vcpkg_internal_meson_generate

* update control tool-meson
This commit is contained in:
Alexander Neumann 2020-11-18 22:36:20 +01:00 committed by GitHub
parent f08e44a301
commit 3217e25596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 470 additions and 172 deletions

View File

@ -1,4 +1,5 @@
Source: fribidi Source: fribidi
Version: 1.0.10 Version: 1.0.10
Port-Version: 1
Description: GNU FriBidi is an implementation of the Unicode Bidirectional Algorithm (bidi) Description: GNU FriBidi is an implementation of the Unicode Bidirectional Algorithm (bidi)
Build-Depends: tool-meson Build-Depends: tool-meson

View File

@ -1,25 +0,0 @@
diff --git a/lib/meson.build b/lib/meson.build
index aaf2aed..3fe8937 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -71,6 +71,10 @@ fribidi_sources = [
'fribidi-shape.c',
]
+libsuffix = []
+if host_machine.system() == 'windows' and get_option('default_library') == 'static'
+ libsuffix = 'lib'
+endif
libfribidi = library('fribidi',
fribidi_sources, fribidi_unicode_version_h, fribidi_config_h,
generated_tab_include_files, config_h,
@@ -78,7 +82,8 @@ libfribidi = library('fribidi',
c_args: ['-DHAVE_CONFIG_H', '-DFRIBIDI_BUILD'] + fribidi_static_cargs + visibility_args,
version: libversion,
soversion: soversion,
- install: true)
+ install: true,
+ name_suffix: libsuffix)
libfribidi_dep = declare_dependency(link_with: libfribidi,
include_directories: incs,

View File

@ -4,7 +4,6 @@ vcpkg_from_github(
REF 5464c284034da9c058269377b7f5013bb089f553 # v1.0.10 REF 5464c284034da9c058269377b7f5013bb089f553 # v1.0.10
SHA512 82e42b022f23d6ecebac5071f997c9f46db6aa41c36f87a7f1a28a79b4ccaada10d68b233bbf687c552fc94d91f4b47161e0ef4909fd1de0b483089f1d1377f9 SHA512 82e42b022f23d6ecebac5071f997c9f46db6aa41c36f87a7f1a28a79b4ccaada10d68b233bbf687c552fc94d91f4b47161e0ef4909fd1de0b483089f1d1377f9
HEAD_REF master HEAD_REF master
PATCHES fix-win-static-suffix.patch
) )
vcpkg_configure_meson( vcpkg_configure_meson(
@ -13,10 +12,10 @@ vcpkg_configure_meson(
-Ddocs=false -Ddocs=false
-Dbin=false -Dbin=false
-Dtests=false -Dtests=false
--backend=ninja
) )
vcpkg_install_meson() vcpkg_install_meson()
vcpkg_fixup_pkgconfig()
vcpkg_copy_pdbs() vcpkg_copy_pdbs()
# Define static macro # Define static macro

View File

@ -1,5 +1,7 @@
Source: munit Source: munit
Version: 2019-04-06 Version: 2019-04-06
Port-Version: 1
Description: A small but full-featured unit testing framework for C Description: A small but full-featured unit testing framework for C
Build-Depends: tool-meson
Supports: !(arm|arm64|uwp) Supports: !(arm|arm64|uwp)
Homepage: https://github.com/nemequ/munit Homepage: https://github.com/nemequ/munit

View File

@ -14,8 +14,6 @@ vcpkg_from_github(
vcpkg_configure_meson( vcpkg_configure_meson(
SOURCE_PATH ${SOURCE_PATH} SOURCE_PATH ${SOURCE_PATH}
OPTIONS
--backend=ninja
) )
vcpkg_install_meson() vcpkg_install_meson()

View File

@ -1,4 +1,4 @@
Source: tool-meson Source: tool-meson
Version: 0.56.0 Version: 0.56.01
Homepage: https://github.com/mesonbuild/meson Homepage: https://github.com/mesonbuild/meson
Description: Meson build system Description: Meson build system

View File

@ -33,55 +33,347 @@
## ##
## * [fribidi](https://github.com/Microsoft/vcpkg/blob/master/ports/fribidi/portfile.cmake) ## * [fribidi](https://github.com/Microsoft/vcpkg/blob/master/ports/fribidi/portfile.cmake)
## * [libepoxy](https://github.com/Microsoft/vcpkg/blob/master/ports/libepoxy/portfile.cmake) ## * [libepoxy](https://github.com/Microsoft/vcpkg/blob/master/ports/libepoxy/portfile.cmake)
function(vcpkg_configure_meson) function(vcpkg_internal_meson_generate_native_file) #https://mesonbuild.com/Native-environments.html
# parse parameters such that semicolons in options arguments to COMMAND don't get erased set(NATIVE "[binaries]\n")
cmake_parse_arguments(PARSE_ARGV 0 _vcm "" "SOURCE_PATH" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE") #set(proglist AR RANLIB STRIP NM OBJDUMP DLLTOOL MT)
if(VCPKG_TARGET_IS_WINDOWS)
set(proglist MT)
else()
set(proglist AR RANLIB STRIP NM OBJDUMP DLLTOOL MT)
endif()
foreach(prog IN LISTS proglist)
if(VCPKG_DETECTED_CMAKE_${prog})
string(TOLOWER "${prog}" proglower)
string(APPEND NATIVE "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}}'\n")
endif()
endforeach()
set(compiler C CXX RC)
foreach(prog IN LISTS compiler)
if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER)
string(REPLACE "CXX" "CPP" mesonprog "${prog}")
string(TOLOWER "${mesonprog}" proglower)
string(APPEND NATIVE "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}'\n")
endif()
endforeach()
if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS)
string(APPEND NATIVE "c_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n")
string(APPEND NATIVE "cpp_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n")
endif()
string(APPEND NATIVE "cmake = '${CMAKE_COMMAND}'\n")
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) string(APPEND NATIVE "[built-in options]\n") #https://mesonbuild.com/Builtin-options.html
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) if(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe")
string(APPEND NATIVE "cpp_eh='none'\n") # To make sure meson is not adding eh flags by itself using msvc
endif()
if(VCPKG_TARGET_IS_WINDOWS)
string(REGEX REPLACE "( |^)(-|/)" ";\\2" WIN_C_STANDARD_LIBRARIES "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES}")
string(REGEX REPLACE "\\.lib " ".lib;" WIN_C_STANDARD_LIBRARIES "${WIN_C_STANDARD_LIBRARIES}")
list(TRANSFORM WIN_C_STANDARD_LIBRARIES APPEND "'")
list(TRANSFORM WIN_C_STANDARD_LIBRARIES PREPEND "'")
list(JOIN WIN_C_STANDARD_LIBRARIES ", " WIN_C_STANDARD_LIBRARIES)
string(APPEND NATIVE "c_winlibs = [${WIN_C_STANDARD_LIBRARIES}]\n")
string(REGEX REPLACE "( |^)(-|/)" ";\\2" WIN_CXX_STANDARD_LIBRARIES "${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
string(REGEX REPLACE "\\.lib " ".lib;" WIN_CXX_STANDARD_LIBRARIES "${WIN_CXX_STANDARD_LIBRARIES}")
list(TRANSFORM WIN_CXX_STANDARD_LIBRARIES APPEND "'")
list(TRANSFORM WIN_CXX_STANDARD_LIBRARIES PREPEND "'")
list(JOIN WIN_CXX_STANDARD_LIBRARIES ", " WIN_CXX_STANDARD_LIBRARIES)
string(APPEND NATIVE "cpp_winlibs = [${WIN_CXX_STANDARD_LIBRARIES}]\n")
endif()
set(_file "${CURRENT_BUILDTREES_DIR}/meson-nativ-${TARGET_TRIPLET}.log")
set(VCPKG_MESON_NATIVE_FILE "${_file}" PARENT_SCOPE)
file(WRITE "${_file}" "${NATIVE}")
endfunction()
function(vcpkg_internal_meson_generate_native_file_config _config) #https://mesonbuild.com/Native-environments.html
if(VCPKG_TARGET_IS_WINDOWS)
set(L_FLAG /LIBPATH:)
else()
set(L_FLAG -L)
endif()
set(PATH_SUFFIX_DEBUG /debug)
set(LIBPATH_${_config} "'${L_FLAG}${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_config}}/lib'")
set(NATIVE_${_config} "[properties]\n") #https://mesonbuild.com/Builtin-options.html
string(REGEX REPLACE "( |^)(-|/)" ";\\2" MESON_CFLAGS_${_config} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_config}}")
list(TRANSFORM MESON_CFLAGS_${_config} APPEND "'")
list(TRANSFORM MESON_CFLAGS_${_config} PREPEND "'")
#list(APPEND MESON_CFLAGS_${_config} "${LIBPATH_${_config}}")
list(APPEND MESON_CFLAGS_${_config} "'-I${CURRENT_INSTALLED_DIR}/include'")
list(JOIN MESON_CFLAGS_${_config} ", " MESON_CFLAGS_${_config})
string(REPLACE "'', " "" MESON_CFLAGS_${_config} "${MESON_CFLAGS_${_config}}")
string(APPEND NATIVE_${_config} "c_args = [${MESON_CFLAGS_${_config}}]\n")
string(REGEX REPLACE "( |^)(-|/)" ";\\2" MESON_CXXFLAGS_${_config} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_config}}")
list(TRANSFORM MESON_CXXFLAGS_${_config} APPEND "'")
list(TRANSFORM MESON_CXXFLAGS_${_config} PREPEND "'")
#list(APPEND MESON_CXXFLAGS_${_config} "${LIBPATH_${_config}}")
list(APPEND MESON_CXXFLAGS_${_config} "'-I${CURRENT_INSTALLED_DIR}/include'")
list(JOIN MESON_CXXFLAGS_${_config} ", " MESON_CXXFLAGS_${_config})
string(REPLACE "'', " "" MESON_CXXFLAGS_${_config} "${MESON_CXXFLAGS_${_config}}")
string(APPEND NATIVE_${_config} "cpp_args = [${MESON_CXXFLAGS_${_config}}]\n")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(LINKER_FLAGS_${_config} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${_config}}")
else()
set(LINKER_FLAGS_${_config} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${_config}}")
endif()
string(REGEX REPLACE "( |^)(-|/)" ";\\2" LINKER_FLAGS_${_config} "${LINKER_FLAGS_${_config}}")
list(TRANSFORM LINKER_FLAGS_${_config} APPEND "'")
list(TRANSFORM LINKER_FLAGS_${_config} PREPEND "'")
list(APPEND LINKER_FLAGS_${_config} "${LIBPATH_${_config}}")
list(JOIN LINKER_FLAGS_${_config} ", " LINKER_FLAGS_${_config})
string(REPLACE "'', " "" LINKER_FLAGS_${_config} "${LINKER_FLAGS_${_config}}")
string(APPEND NATIVE_${_config} "c_link_args = [${LINKER_FLAGS_${_config}}]\n")
string(APPEND NATIVE_${_config} "cpp_link_args = [${LINKER_FLAGS_${_config}}]\n")
#Setup CMake properties
string(APPEND NATIVE_${_config} "cmake_toolchain_file = '${SCRIPTS}/buildsystems/vcpkg.cmake'\n")
string(APPEND NATIVE_${_config} "[cmake]\n")
#Extract compiler flags
if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE) if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
set(MESON_CMAKE_FLAG_SUFFIX "_INIT")
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake") set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
set(MESON_CMAKE_FLAG_SUFFIX "")
elseif(VCPKG_TARGET_IS_LINUX) elseif(VCPKG_TARGET_IS_LINUX)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/linux.cmake") set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/linux.cmake")
elseif(VCPKG_TARGET_IS_ANDROID) elseif(VCPKG_TARGET_IS_ANDROID)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/android.cmake") set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/android.cmake")
elseif(VCPKG_TARGET_IS_OSX) elseif(VCPKG_TARGET_IS_OSX)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/osx.cmake") set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/osx.cmake")
elseif(VVCPKG_TARGET_IS_FREEBSD) elseif(VCPKG_TARGET_IS_IOS)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/ios.cmake")
elseif(VCPKG_TARGET_IS_FREEBSD)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake") set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake")
elseif(VCPKG_TARGET_IS_MINGW) elseif(VCPKG_TARGET_IS_MINGW)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/mingw.cmake") set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/mingw.cmake")
endif() endif()
endif() endif()
include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}") string(APPEND NATIVE_${_config} "VCPKG_TARGET_TRIPLET = '${TARGET_TRIPLET}'\n")
string(APPEND NATIVE_${_config} "VCPKG_CHAINLOAD_TOOLCHAIN_FILE = '${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}'\n")
string(APPEND MESON_COMMON_CFLAGS " ${CMAKE_C_FLAGS${MESON_CMAKE_FLAG_SUFFIX}}")
string(APPEND MESON_COMMON_CXXFLAGS " ${CMAKE_CXX_FLAGS${MESON_CMAKE_FLAG_SUFFIX}}")
string(APPEND MESON_DEBUG_CFLAGS " ${CMAKE_C_FLAGS_DEBUG${MESON_CMAKE_FLAG_SUFFIX}}") string(APPEND NATIVE_${_config} "[built-in options]\n")
string(APPEND MESON_DEBUG_CXXFLAGS " ${CMAKE_CXX_FLAGS_DEBUG${MESON_CMAKE_FLAG_SUFFIX}}")
string(APPEND MESON_RELEASE_CFLAGS " ${CMAKE_C_FLAGS_RELEASE${MESON_CMAKE_FLAG_SUFFIX}}")
string(APPEND MESON_RELEASE_CXXFLAGS " ${CMAKE_CXX_FLAGS_RELEASE${MESON_CMAKE_FLAG_SUFFIX}}")
string(APPEND MESON_COMMON_LDFLAGS " ${CMAKE_SHARED_LINKER_FLAGS${MESON_CMAKE_FLAG_SUFFIX}}")
string(APPEND MESON_DEBUG_LDFLAGS " ${CMAKE_SHARED_LINKER_FLAGS_DEBUG${MESON_CMAKE_FLAG_SUFFIX}}")
string(APPEND MESON_RELEASE_LDFLAGS " ${CMAKE_SHARED_LINKER_FLAGS_RELEASE${MESON_CMAKE_FLAG_SUFFIX}}")
# select meson cmd-line options
if(VCPKG_TARGET_IS_WINDOWS) if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND _vcm_OPTIONS "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/share']") if(VCPKG_CRT_LINKAGE STREQUAL "static")
else() set(CRT mt)
list(APPEND _vcm_OPTIONS "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}']") else()
set(CRT md)
endif()
if(${_config} STREQUAL DEBUG)
set(CRT ${CRT}d)
endif()
string(APPEND NATIVE_${_config} "b_vscrt = '${CRT}'\n")
endif() endif()
list(APPEND _vcm_OPTIONS --buildtype plain --backend ninja --wrap-mode nodownload) string(TOLOWER "${_config}" lowerconfig)
set(_file "${CURRENT_BUILDTREES_DIR}/meson-nativ-${TARGET_TRIPLET}-${lowerconfig}.log")
set(VCPKG_MESON_NATIVE_FILE_${_config} "${_file}" PARENT_SCOPE)
file(WRITE "${_file}" "${NATIVE_${_config}}")
endfunction()
function(vcpkg_internal_meson_generate_cross_file) #https://mesonbuild.com/Cross-compilation.html
if(CMAKE_HOST_WIN32)
if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
set(BUILD_ARCH $ENV{PROCESSOR_ARCHITEW6432})
else()
set(BUILD_ARCH $ENV{PROCESSOR_ARCHITECTURE})
endif()
if(BUILD_ARCH MATCHES "(amd|AMD)64")
set(BUILD_CPU_FAM x86_x64)
set(BUILD_CPU x86_x64)
elseif(BUILD_ARCH MATCHES "(x|X)86")
set(BUILD_CPU_FAM x86)
set(BUILD_CPU i686)
elseif(BUILD_ARCH MATCHES "^(ARM|arm)64$")
set(BUILD_CPU_FAM aarch64)
set(BUILD_CPU armv8)
elseif(BUILD_ARCH MATCHES "^(ARM|arm)$")
set(BUILD_CPU_FAM arm)
set(BUILD_CPU armv7hl)
else()
message(FATAL_ERROR "Unsupported host architecture ${BUILD_ARCH}!" )
endif()
else() # TODO: add correct detection for OSX and Linux. Currently only x64 triplets are available in official vcpkg.
set(BUILD_CPU_FAM x86_x64)
set(BUILD_CPU x86_x64)
endif()
if(VCPKG_TARGET_ARCHITECTURE MATCHES "(amd|AMD|x|X)64")
set(HOST_CPU_FAM x86_x64)
set(HOST_CPU x86_x64)
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)86")
set(HOST_CPU_FAM x86)
set(HOST_CPU i686)
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)64$")
set(HOST_CPU_FAM aarch64)
set(HOST_CPU armv8)
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)$")
set(HOST_CPU_FAM arm)
set(HOST_CPU armv7hl)
else()
message(FATAL_ERROR "Unsupported target architecture ${VCPKG_TARGET_ARCHITECTURE}!" )
endif()
set(CROSS "[binaries]\n")
if(VCPKG_TARGET_IS_WINDOWS)
set(proglist MT)
else()
set(proglist AR RANLIB STRIP NM OBJDUMP DLLTOOL MT)
endif()
foreach(prog IN LISTS proglist)
if(VCPKG_DETECTED_CMAKE_${prog})
string(TOLOWER "${prog}" proglower)
string(APPEND CROSS "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}}'\n")
endif()
endforeach()
set(compiler C CXX RC)
foreach(prog IN LISTS compiler)
if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER)
string(REPLACE "CXX" "CPP" mesonprog "${prog}")
string(TOLOWER "${mesonprog}" proglower)
string(APPEND CROSS "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}'\n")
endif()
endforeach()
if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS)
string(APPEND CROSS "c_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n")
string(APPEND CROSS "cpp_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n")
endif()
string(APPEND CROSS "[properties]\n")
string(APPEND CROSS "skip_sanity_check = true\n")
string(APPEND CROSS "[host_machine]\n")
string(APPEND CROSS "endian = 'little'\n")
if(NOT VCPKG_CMAKE_SYSTEM_NAME)
set(MESON_SYSTEM_NAME "windows")
else()
string(TOLOWER "${VCPKG_CMAKE_SYSTEM_NAME}" MESON_SYSTEM_NAME)
endif()
string(APPEND CROSS "system = '${MESON_SYSTEM_NAME}'\n")
string(APPEND CROSS "cpu_family = '${HOST_CPU_FAM}'\n")
string(APPEND CROSS "cpu = '${HOST_CPU}'\n")
string(APPEND CROSS "[build_machine]\n")
string(APPEND CROSS "endian = 'little'\n")
if(WIN32)
string(APPEND CROSS "system = 'windows'\n")
elseif(DARWIN)
string(APPEND CROSS "system = 'darwin'\n")
else()
string(APPEND CROSS "system = 'linux'\n")
endif()
string(APPEND CROSS "cpu_family = '${BUILD_CPU_FAM}'\n")
string(APPEND CROSS "cpu = '${BUILD_CPU}'\n")
if(NOT BUILD_CPU_FAM STREQUAL HOST_CPU_FAM)
set(_file "${CURRENT_BUILDTREES_DIR}/meson-cross-${TARGET_TRIPLET}.log")
set(VCPKG_MESON_CROSS_FILE "${_file}" PARENT_SCOPE)
file(WRITE "${_file}" "${CROSS}")
endif()
endfunction()
function(vcpkg_internal_meson_generate_cross_file_config _config) #https://mesonbuild.com/Native-environments.html
if(VCPKG_TARGET_IS_WINDOWS)
set(L_FLAG /LIBPATH:)
else()
set(L_FLAG -L)
endif()
set(PATH_SUFFIX_DEBUG /debug)
set(LIBPATH_${_config} "'${L_FLAG}${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_config}}/lib'")
set(NATIVE_${_config} "[properties]\n") #https://mesonbuild.com/Builtin-options.html
string(REGEX REPLACE "( |^)(-|/)" ";\\2" MESON_CFLAGS_${_config} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_config}}")
list(TRANSFORM MESON_CFLAGS_${_config} APPEND "'")
list(TRANSFORM MESON_CFLAGS_${_config} PREPEND "'")
list(APPEND MESON_CFLAGS_${_config} "'-I\"${CURRENT_INSTALLED_DIR}/include\"'")
list(JOIN MESON_CFLAGS_${_config} ", " MESON_CFLAGS_${_config})
string(REPLACE "'', " "" MESON_CFLAGS_${_config} "${MESON_CFLAGS_${_config}}")
string(APPEND NATIVE_${_config} "c_args = [${MESON_CFLAGS_${_config}}]\n")
string(REGEX REPLACE "( |^)(-|/)" ";\\2" MESON_CXXFLAGS_${_config} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_config}}")
list(TRANSFORM MESON_CXXFLAGS_${_config} APPEND "'")
list(TRANSFORM MESON_CXXFLAGS_${_config} PREPEND "'")
list(APPEND MESON_CXXFLAGS_${_config} "'-I\"${CURRENT_INSTALLED_DIR}/include\"'")
list(JOIN MESON_CXXFLAGS_${_config} ", " MESON_CXXFLAGS_${_config})
string(REPLACE "'', " "" MESON_CXXFLAGS_${_config} "${MESON_CXXFLAGS_${_config}}")
string(APPEND NATIVE_${_config} "cpp_args = [${MESON_CXXFLAGS_${_config}}]\n")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(LINKER_FLAGS_${_config} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${_config}}")
else()
set(LINKER_FLAGS_${_config} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${_config}}")
endif()
string(REGEX REPLACE "( |^)(-|/)" ";\\2" LINKER_FLAGS_${_config} "${LINKER_FLAGS_${_config}}")
list(TRANSFORM LINKER_FLAGS_${_config} APPEND "'")
list(TRANSFORM LINKER_FLAGS_${_config} PREPEND "'")
list(APPEND LINKER_FLAGS_${_config} "${LIBPATH_${_config}}")
list(JOIN LINKER_FLAGS_${_config} ", " LINKER_FLAGS_${_config})
string(REPLACE "'', " "" LINKER_FLAGS_${_config} "${LINKER_FLAGS_${_config}}")
string(APPEND NATIVE_${_config} "c_link_args = [${LINKER_FLAGS_${_config}}]\n")
string(APPEND NATIVE_${_config} "cpp_link_args = [${LINKER_FLAGS_${_config}}]\n")
string(APPEND NATIVE_${_config} "[built-in options]\n")
if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_CRT_LINKAGE STREQUAL "static")
set(CRT mt)
else()
set(CRT md)
endif()
if(${_config} STREQUAL DEBUG)
set(CRT ${CRT}d)
endif()
string(APPEND NATIVE_${_config} "b_vscrt = '${CRT}'\n")
endif()
string(TOLOWER "${_config}" lowerconfig)
set(_file "${CURRENT_BUILDTREES_DIR}/meson-cross-${TARGET_TRIPLET}-${lowerconfig}.log")
set(VCPKG_MESON_CROSS_FILE_${_config} "${_file}" PARENT_SCOPE)
file(WRITE "${_file}" "${NATIVE_${_config}}")
endfunction()
function(vcpkg_configure_meson)
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
cmake_parse_arguments(PARSE_ARGV 0 _vcm "" "SOURCE_PATH" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE")
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_internal_get_cmake_vars(OUTPUT_FILE _VCPKG_CMAKE_VARS_FILE)
set(_VCPKG_CMAKE_VARS_FILE "${_VCPKG_CMAKE_VARS_FILE}" PARENT_SCOPE)
debug_message("Including cmake vars from: ${_VCPKG_CMAKE_VARS_FILE}")
include("${_VCPKG_CMAKE_VARS_FILE}")
list(APPEND _vcm_OPTIONS --buildtype plain --backend ninja --wrap-mode nodownload)
if(NOT VCPKG_MESON_NATIVE_FILE)
vcpkg_internal_meson_generate_native_file()
endif()
if(NOT VCPKG_MESON_NATIVE_FILE_DEBUG)
vcpkg_internal_meson_generate_native_file_config(DEBUG)
endif()
if(NOT VCPKG_MESON_NATIVE_FILE_RELEASE)
vcpkg_internal_meson_generate_native_file_config(RELEASE)
endif()
list(APPEND _vcm_OPTIONS --native "${VCPKG_MESON_NATIVE_FILE}")
list(APPEND _vcm_OPTIONS_DEBUG --native "${VCPKG_MESON_NATIVE_FILE_DEBUG}")
list(APPEND _vcm_OPTIONS_RELEASE --native "${VCPKG_MESON_NATIVE_FILE_RELEASE}")
if(NOT VCPKG_MESON_CROSS_FILE)
vcpkg_internal_meson_generate_cross_file()
endif()
if(NOT VCPKG_MESON_CROSS_FILE_DEBUG AND VCPKG_MESON_CROSS_FILE)
vcpkg_internal_meson_generate_cross_file_config(DEBUG)
endif()
if(NOT VCPKG_MESON_CROSS_FILE_RELEASE AND VCPKG_MESON_CROSS_FILE)
vcpkg_internal_meson_generate_cross_file_config(RELEASE)
endif()
if(VCPKG_MESON_CROSS_FILE)
list(APPEND _vcm_OPTIONS --cross "${VCPKG_MESON_CROSS_FILE}")
endif()
if(VCPKG_MESON_CROSS_FILE_DEBUG)
list(APPEND _vcm_OPTIONS_DEBUG --cross "${VCPKG_MESON_CROSS_FILE_DEBUG}")
endif()
if(VCPKG_MESON_CROSS_FILE_RELEASE)
list(APPEND _vcm_OPTIONS_RELEASE --cross "${VCPKG_MESON_CROSS_FILE_RELEASE}")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
list(APPEND _vcm_OPTIONS --default-library shared) list(APPEND _vcm_OPTIONS --default-library shared)
else() else()
@ -89,11 +381,24 @@ function(vcpkg_configure_meson)
endif() endif()
list(APPEND _vcm_OPTIONS --libdir lib) # else meson install into an architecture describing folder list(APPEND _vcm_OPTIONS --libdir lib) # else meson install into an architecture describing folder
list(APPEND _vcm_OPTIONS_DEBUG --prefix ${CURRENT_PACKAGES_DIR}/debug --includedir ../include) list(APPEND _vcm_OPTIONS_DEBUG -Ddebug=true --prefix ${CURRENT_PACKAGES_DIR}/debug --includedir ../include)
list(APPEND _vcm_OPTIONS_RELEASE --prefix ${CURRENT_PACKAGES_DIR}) list(APPEND _vcm_OPTIONS_RELEASE -Ddebug=false --prefix ${CURRENT_PACKAGES_DIR})
# select meson cmd-line options
if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND _vcm_OPTIONS_DEBUG "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/share']")
list(APPEND _vcm_OPTIONS_RELEASE "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}/share']")
else()
list(APPEND _vcm_OPTIONS_DEBUG "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}']")
list(APPEND _vcm_OPTIONS_RELEASE "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/debug']")
endif()
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")
vcpkg_find_acquire_program(MESON) vcpkg_find_acquire_program(MESON)
get_filename_component(CMAKE_PATH ${CMAKE_COMMAND} DIRECTORY) get_filename_component(CMAKE_PATH ${CMAKE_COMMAND} DIRECTORY)
vcpkg_add_to_path("${CMAKE_PATH}") # Make CMake invokeable for Meson vcpkg_add_to_path("${CMAKE_PATH}") # Make CMake invokeable for Meson
@ -105,129 +410,90 @@ function(vcpkg_configure_meson)
get_filename_component(PKGCONFIG_PATH ${PKGCONFIG} DIRECTORY) get_filename_component(PKGCONFIG_PATH ${PKGCONFIG} DIRECTORY)
vcpkg_add_to_path("${PKGCONFIG_PATH}") vcpkg_add_to_path("${PKGCONFIG_PATH}")
set(PKGCONFIG_SHARE_DIR "${CURRENT_INSTALLED_DIR}/share/pkgconfig/") set(PKGCONFIG_SHARE_DIR "${CURRENT_INSTALLED_DIR}/share/pkgconfig/")
# configure debug
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
#setting up PKGCONFIG
if(NOT PKGCONFIG MATCHES "--define-variable=prefix")
set(PKGCONFIG_PREFIX "${CURRENT_INSTALLED_DIR}/debug")
set(ENV{PKG_CONFIG} "${PKGCONFIG} --define-variable=prefix=${PKGCONFIG_PREFIX}")
endif()
set(PKGCONFIG_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig/")
if(ENV{PKG_CONFIG_PATH})
set(BACKUP_ENV_PKG_CONFIG_PATH_DEBUG $ENV{PKG_CONFIG_PATH})
set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_SHARE_DIR}${VCPKG_HOST_PATH_SEPARATOR}$ENV{PKG_CONFIG_PATH}")
else()
set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_SHARE_DIR}")
endif()
set(CFLAGS "-Dc_args=[${MESON_COMMON_CFLAGS} ${MESON_DEBUG_CFLAGS}]") set(buildtypes)
string(REGEX REPLACE " +(/|-)" "','\\1" CFLAGS ${CFLAGS}) # Seperate compiler arguments with comma and enclose in ' if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
string(REGEX REPLACE " *\\\]" "']" CFLAGS ${CFLAGS}) # Add trailing ' at end set(BUILDNAME DEBUG)
string(REGEX REPLACE "\\\['," "[" CFLAGS ${CFLAGS}) # Remove prepended ', introduced in #1 list(APPEND buildtypes ${BUILDNAME})
string(REGEX REPLACE "\\\['\\\]" "[]" CFLAGS ${CFLAGS}) # Remove trailing ' introduced in #2 if no elements set(PATH_SUFFIX_${BUILDNAME} "debug/")
set(SUFFIX_${BUILDNAME} "dbg")
set(CXXFLAGS "-Dcpp_args=[${MESON_COMMON_CXXFLAGS} ${MESON_DEBUG_CXXFLAGS}]")
string(REGEX REPLACE " +(/|-)" "','\\1" CXXFLAGS ${CXXFLAGS})
string(REGEX REPLACE " *\\\]" "']" CXXFLAGS ${CXXFLAGS})
string(REGEX REPLACE "\\\['," "[" CXXFLAGS ${CXXFLAGS})
string(REGEX REPLACE "\\\['\\\]" "[]" CXXFLAGS ${CXXFLAGS})
set(LDFLAGS "[${MESON_COMMON_LDFLAGS} ${MESON_DEBUG_LDFLAGS}]")
string(REGEX REPLACE " +(/|-)" "','\\1" LDFLAGS ${LDFLAGS})
string(REGEX REPLACE " *\\\]" "']" LDFLAGS ${LDFLAGS})
string(REGEX REPLACE "\\\['," "[" LDFLAGS ${LDFLAGS})
string(REGEX REPLACE "\\\['\\\]" "[]" LDFLAGS ${LDFLAGS})
set(CLDFLAGS "-Dc_link_args=${LDFLAGS}")
set(CXXLDFLAGS "-Dcpp_link_args=${LDFLAGS}")
vcpkg_execute_required_process(
COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_DEBUG} ${_vcm_SOURCE_PATH} ${CFLAGS} ${CXXFLAGS} ${CLDFLAGS} ${CXXLDFLAGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME config-${TARGET_TRIPLET}-dbg
)
#Copy meson log files into buildtree for CI
if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/meson-logs/meson-log.txt")
file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/meson-logs/meson-log.txt" DESTINATION "${CURRENT_BUILDTREES_DIR}")
file(RENAME "${CURRENT_BUILDTREES_DIR}/meson-log.txt" "${CURRENT_BUILDTREES_DIR}/meson-log-dbg.txt")
endif()
if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/meson-logs/install-log.txt")
file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/meson-logs/install-log.txt" DESTINATION "${CURRENT_BUILDTREES_DIR}")
file(RENAME "${CURRENT_BUILDTREES_DIR}/install-log.txt" "${CURRENT_BUILDTREES_DIR}/install-log-dbg.txt")
endif()
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
#Restore PKG_CONFIG_PATH
if(BACKUP_ENV_PKG_CONFIG_PATH_DEBUG)
set(ENV{PKG_CONFIG_PATH} "${BACKUP_ENV_PKG_CONFIG_PATH_DEBUG}")
unset(BACKUP_ENV_PKG_CONFIG_PATH_DEBUG)
else()
unset(ENV{PKG_CONFIG_PATH})
endif()
endif() endif()
# configure release
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Configuring ${TARGET_TRIPLET}-rel") set(BUILDNAME RELEASE)
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) list(APPEND buildtypes ${BUILDNAME})
#setting up PKGCONFIG set(PATH_SUFFIX_${BUILDNAME} "")
if(NOT PKGCONFIG MATCHES "--define-variable=prefix") set(SUFFIX_${BUILDNAME} "rel")
set(PKGCONFIG_PREFIX "${CURRENT_INSTALLED_DIR}") endif()
set(ENV{PKG_CONFIG} "${PKGCONFIG} --define-variable=prefix=${PKGCONFIG_PREFIX}")
if(VCPKG_TARGET_IS_OSX)
if(DEFINED ENV{SDKROOT})
set(_VCPKG_ENV_SDKROOT_BACKUP $ENV{SDKROOT})
endif() endif()
set(PKGCONFIG_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/") set(ENV{SDKROOT} "${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}")
if(ENV{PKG_CONFIG_PATH}) set(VCPKG_DETECTED_CMAKE_OSX_SYSROOT "${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}" PARENT_SCOPE)
if(DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
set(_VCPKG_ENV_MACOSX_DEPLOYMENT_TARGET_BACKUP $ENV{MACOSX_DEPLOYMENT_TARGET})
endif()
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${VCPKG_DETECTED_CMAKE_OSX_DEPLOYMENT_TARGET}")
set(VCPKG_DETECTED_CMAKE_OSX_DEPLOYMENT_TARGET "${VCPKG_DETECTED_CMAKE_OSX_DEPLOYMENT_TARGET}" PARENT_SCOPE)
endif()
if(DEFINED ENV{INCLUDE})
set(ENV{INCLUDE} "$ENV{INCLUDE}${VCPKG_HOST_PATH_SEPARATOR}${CURRENT_INSTALLED_DIR}/include")
else()
set(ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include")
endif()
# configure build
foreach(buildtype IN LISTS buildtypes)
message(STATUS "Configuring ${TARGET_TRIPLET}-${SUFFIX_${buildtype}}")
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SUFFIX_${buildtype}}")
#setting up PKGCONFIG
set(ENV{PKG_CONFIG} "${PKGCONFIG}") # Set via native file?
set(PKGCONFIG_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}/${PATH_SUFFIX_${buildtype}}lib/pkgconfig/")
if(DEFINED ENV{PKG_CONFIG_PATH})
set(BACKUP_ENV_PKG_CONFIG_PATH_RELEASE $ENV{PKG_CONFIG_PATH}) set(BACKUP_ENV_PKG_CONFIG_PATH_RELEASE $ENV{PKG_CONFIG_PATH})
set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_SHARE_DIR}${VCPKG_HOST_PATH_SEPARATOR}$ENV{PKG_CONFIG_PATH}") set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_SHARE_DIR}${VCPKG_HOST_PATH_SEPARATOR}$ENV{PKG_CONFIG_PATH}")
else() else()
set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_SHARE_DIR}") set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_SHARE_DIR}")
endif() endif()
# Normalize flags for meson (i.e. " /string /with /flags " -> ['/string', '/with', '/flags'])
set(CFLAGS "-Dc_args=[${MESON_COMMON_CFLAGS} ${MESON_RELEASE_CFLAGS}]")
string(REGEX REPLACE " +(/|-)" "','\\1" CFLAGS ${CFLAGS}) # Seperate compiler arguments with comma and enclose in '
string(REGEX REPLACE " *\\\]" "']" CFLAGS ${CFLAGS}) # Add trailing ' at end
string(REGEX REPLACE "\\\['," "[" CFLAGS ${CFLAGS}) # Remove prepended ', introduced in #1
string(REGEX REPLACE "\\\['\\\]" "[]" CFLAGS ${CFLAGS}) # Remove trailing ' introduced in #2 if no elements
set(CXXFLAGS "-Dcpp_args=[${MESON_COMMON_CXXFLAGS} ${MESON_RELEASE_CXXFLAGS}]")
string(REGEX REPLACE " +(/|-)" "','\\1" CXXFLAGS ${CXXFLAGS})
string(REGEX REPLACE " *\\\]" "']" CXXFLAGS ${CXXFLAGS})
string(REGEX REPLACE "\\\['," "[" CXXFLAGS ${CXXFLAGS})
string(REGEX REPLACE "\\\['\\\]" "[]" CXXFLAGS ${CXXFLAGS})
set(LDFLAGS "[${MESON_COMMON_LDFLAGS} ${MESON_RELEASE_LDFLAGS}]")
string(REGEX REPLACE " +(/|-)" "','\\1" LDFLAGS ${LDFLAGS})
string(REGEX REPLACE " *\\\]" "']" LDFLAGS ${LDFLAGS})
string(REGEX REPLACE "\\\['," "[" LDFLAGS ${LDFLAGS})
string(REGEX REPLACE "\\\['\\\]" "[]" LDFLAGS ${LDFLAGS})
set(CLDFLAGS "-Dc_link_args=${LDFLAGS}")
set(CXXLDFLAGS "-Dcpp_link_args=${LDFLAGS}")
vcpkg_execute_required_process( vcpkg_execute_required_process(
COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_RELEASE} ${_vcm_SOURCE_PATH} ${CFLAGS} ${CXXFLAGS} ${CLDFLAGS} ${CXXLDFLAGS} COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_${buildtype}} ${_vcm_SOURCE_PATH}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SUFFIX_${buildtype}}
LOGNAME config-${TARGET_TRIPLET}-rel LOGNAME config-${TARGET_TRIPLET}-${SUFFIX_${buildtype}}
) )
#Copy meson log files into buildtree for CI #Copy meson log files into buildtree for CI
if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/meson-logs/meson-log.txt") if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SUFFIX_${buildtype}}/meson-logs/meson-log.txt")
file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/meson-logs/meson-log.txt" DESTINATION "${CURRENT_BUILDTREES_DIR}") file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SUFFIX_${buildtype}}/meson-logs/meson-log.txt" DESTINATION "${CURRENT_BUILDTREES_DIR}")
file(RENAME "${CURRENT_BUILDTREES_DIR}/meson-log.txt" "${CURRENT_BUILDTREES_DIR}/meson-log-rel.txt") file(RENAME "${CURRENT_BUILDTREES_DIR}/meson-log.txt" "${CURRENT_BUILDTREES_DIR}/meson-log-${SUFFIX_${buildtype}}.txt")
endif() endif()
if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/meson-logs/install-log.txt") if(EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SUFFIX_${buildtype}}/meson-logs/install-log.txt")
file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/meson-logs/install-log.txt" DESTINATION "${CURRENT_BUILDTREES_DIR}") file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SUFFIX_${buildtype}}/meson-logs/install-log.txt" DESTINATION "${CURRENT_BUILDTREES_DIR}")
file(RENAME "${CURRENT_BUILDTREES_DIR}/install-log.txt" "${CURRENT_BUILDTREES_DIR}/install-log-rel.txt") file(RENAME "${CURRENT_BUILDTREES_DIR}/install-log.txt" "${CURRENT_BUILDTREES_DIR}/install-log-${SUFFIX_${buildtype}}.txt")
endif() endif()
message(STATUS "Configuring ${TARGET_TRIPLET}-rel done") message(STATUS "Configuring ${TARGET_TRIPLET}-${SUFFIX_${buildtype}} done")
#Restore PKG_CONFIG_PATH #Restore PKG_CONFIG_PATH
if(BACKUP_ENV_PKG_CONFIG_PATH_RELEASE) if(BACKUP_ENV_PKG_CONFIG_PATH_${buildtype})
set(ENV{PKG_CONFIG_PATH} "${BACKUP_ENV_PKG_CONFIG_PATH_RELEASE}") set(ENV{PKG_CONFIG_PATH} "${BACKUP_ENV_PKG_CONFIG_PATH_${buildtype}}")
unset(BACKUP_ENV_PKG_CONFIG_PATH_RELEASE) unset(BACKUP_ENV_PKG_CONFIG_PATH_${buildtype})
else() else()
unset(ENV{PKG_CONFIG_PATH}) unset(ENV{PKG_CONFIG_PATH})
endif() endif()
endforeach()
endif()
if(VCPKG_TARGET_IS_OSX)
if(DEFINED _VCPKG_ENV_SDKROOT_BACKUP)
set(ENV{SDKROOT} "${_VCPKG_ENV_SDKROOT_BACKUP}")
else()
unset(ENV{SDKROOT})
endif()
if(DEFINED _VCPKG_ENV_MACOSX_DEPLOYMENT_TARGET_BACKUP)
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${_VCPKG_ENV_MACOSX_DEPLOYMENT_TARGET_BACKUP}")
else()
unset(ENV{MACOSX_DEPLOYMENT_TARGET})
endif()
endif()
endfunction() endfunction()

View File

@ -246,16 +246,19 @@ function(vcpkg_find_acquire_program VAR)
set(NOEXTRACT ON) set(NOEXTRACT ON)
set(HASH 22ea847d8017cd977664d0b13c889cfb13c89143212899a511be217345a4e243d4d8d4099700114a11d26a087e83eb1a3e2b03bdb5e0db48f10403184cd26619) set(HASH 22ea847d8017cd977664d0b13c889cfb13c89143212899a511be217345a4e243d4d8d4099700114a11d26a087e83eb1a3e2b03bdb5e0db48f10403184cd26619)
elseif(VAR MATCHES "MESON") elseif(VAR MATCHES "MESON")
set(MESON_VERSION 0.56.0) set(MESON_VERSION 0.56.01)
set(PROGNAME meson) set(PROGNAME meson)
set(REQUIRED_INTERPRETER PYTHON3) set(REQUIRED_INTERPRETER PYTHON3)
set(APT_PACKAGE_NAME "meson") set(APT_PACKAGE_NAME "meson")
set(BREW_PACKAGE_NAME "meson") set(BREW_PACKAGE_NAME "meson")
set(SCRIPTNAME meson meson.py) set(SCRIPTNAME meson meson.py)
set(PATHS ${DOWNLOADS}/tools/meson/meson-${MESON_VERSION}) set(PATHS ${DOWNLOADS}/tools/meson/meson-91876b40316962620c1705ae14075ab46f8dd644)
set(URL "https://github.com/mesonbuild/meson/releases/download/${MESON_VERSION}/meson-${MESON_VERSION}.tar.gz") set(URL "https://github.com/mesonbuild/meson/archive/91876b40316962620c1705ae14075ab46f8dd644.tar.gz")
set(ARCHIVE "meson-${MESON_VERSION}.tar.gz") set(ARCHIVE "meson-91876b40316962620c1705ae14075ab46f8dd644.tar.gz")
set(HASH da426e2ac0f657da5672d66143b8f4f45513c269a9a544e8b4c48b4a702743a50d35cbaa37ef4c4fbd7e18b8784c788314927a54faba6a14bb2d468eeaa87607) #set(PATHS ${DOWNLOADS}/tools/meson/meson-${MESON_VERSION})
#set(URL "https://github.com/mesonbuild/meson/releases/download/${MESON_VERSION}/meson-${MESON_VERSION}.tar.gz")
#set(ARCHIVE "meson-${MESON_VERSION}.tar.gz")
set(HASH 784b740a01de70312f9240d38b683b2065f40572c87d30929386fe417b2cc70bcc86213c86e143f349c78121c9cc6d7392526d6e53512ae22a6ec0db57f26e3e)
set(_vfa_SUPPORTED ON) set(_vfa_SUPPORTED ON)
set(VERSION_CMD --version) set(VERSION_CMD --version)
elseif(VAR MATCHES "FLEX" OR VAR MATCHES "BISON") elseif(VAR MATCHES "FLEX" OR VAR MATCHES "BISON")

View File

@ -15,6 +15,18 @@ function(vcpkg_install_meson)
vcpkg_find_acquire_program(NINJA) vcpkg_find_acquire_program(NINJA)
unset(ENV{DESTDIR}) # installation directory was already specified with '--prefix' option unset(ENV{DESTDIR}) # installation directory was already specified with '--prefix' option
if(VCPKG_TARGET_IS_OSX)
if(DEFINED ENV{SDKROOT})
set(_VCPKG_ENV_SDKROOT_BACKUP $ENV{SDKROOT})
endif()
set(ENV{SDKROOT} "${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}")
if(DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
set(_VCPKG_ENV_MACOSX_DEPLOYMENT_TARGET_BACKUP $ENV{MACOSX_DEPLOYMENT_TARGET})
endif()
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${VCPKG_DETECTED_CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
message(STATUS "Package ${TARGET_TRIPLET}-rel") message(STATUS "Package ${TARGET_TRIPLET}-rel")
vcpkg_execute_required_process( vcpkg_execute_required_process(
COMMAND ${NINJA} install -v COMMAND ${NINJA} install -v
@ -28,4 +40,42 @@ function(vcpkg_install_meson)
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME package-${TARGET_TRIPLET}-dbg LOGNAME package-${TARGET_TRIPLET}-dbg
) )
set(RENAMED_LIBS)
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL static)
# Meson names all static libraries lib<name>.a which basically breaks the world
file(GLOB_RECURSE LIBRARIES "${CURRENT_PACKAGES_DIR}*/**/lib*.a")
foreach(_library IN LISTS LIBRARIES)
get_filename_component(LIBDIR "${_library}" DIRECTORY )
get_filename_component(LIBNAME "${_library}" NAME)
string(REGEX REPLACE ".a$" ".lib" LIBNAMENEW "${LIBNAME}")
string(REGEX REPLACE "^lib" "" LIBNAMENEW "${LIBNAMENEW}")
file(RENAME "${_library}" "${LIBDIR}/${LIBNAMENEW}")
# For cmake fixes.
string(REGEX REPLACE ".a$" "" LIBRAWNAMEOLD "${LIBNAME}")
string(REGEX REPLACE ".lib$" "" LIBRAWNAMENEW "${LIBNAMENEW}")
list(APPEND RENAMED_LIBS ${LIBRAWNAMENEW})
set(${LIBRAWNAME}_OLD ${LIBRAWNAMEOLD})
set(${LIBRAWNAME}_NEW ${LIBRAWNAMENEW})
endforeach()
file(GLOB_RECURSE CMAKE_FILES "${CURRENT_PACKAGES_DIR}*/*.cmake")
foreach(_cmake IN LISTS CMAKE_FILES)
foreach(_lib IN LISTS RENAMED_LIBS)
vcpkg_replace_string("${_cmake}" "${${_lib}_OLD}" "${${_lib}_NEW}")
endforeach()
endforeach()
endif()
if(VCPKG_TARGET_IS_OSX)
if(DEFINED _VCPKG_ENV_SDKROOT_BACKUP)
set(ENV{SDKROOT} "${_VCPKG_ENV_SDKROOT_BACKUP}")
else()
unset(ENV{SDKROOT})
endif()
if(DEFINED _VCPKG_ENV_MACOSX_DEPLOYMENT_TARGET_BACKUP)
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${_VCPKG_ENV_MACOSX_DEPLOYMENT_TARGET_BACKUP}")
else()
unset(ENV{MACOSX_DEPLOYMENT_TARGET})
endif()
endif()
endfunction() endfunction()

View File

@ -9,6 +9,10 @@ list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING
CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_NAME
CMAKE_SYSTEM_PROCESSOR CMAKE_SYSTEM_PROCESSOR
CMAKE_HOST_SYSTEM_PROCESSOR) CMAKE_HOST_SYSTEM_PROCESSOR)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT)
endif()
# Programs to check # Programs to check
set(PROGLIST AR RANLIB STRIP NM OBJDUMP DLLTOOL MT LINKER) set(PROGLIST AR RANLIB STRIP NM OBJDUMP DLLTOOL MT LINKER)
foreach(prog IN LISTS PROGLIST) foreach(prog IN LISTS PROGLIST)