[vcpkg] vcpkg_configure_meson: cross-compile fixes for Android (#16260)

* [vcpkg] vcpkg_configure_meson: cross-compile fixes

This change includes two fixes to the meson cross-compile config.

The first change fixes the regex used to partition linker flag
options so that it supports double-hyphen prefixes.

The second change ensures that the cross file is always generated
when the target platform is either Android or iOS, even if the
host and target CPU architectures are the same.

* Use helper function instead of regex replace

Use vcpkg_internal_meson_convert_compiler_flags_to_list to partition
compiler flags into a list, instead of string(REGEX REPLACE ...).
This commit is contained in:
Jesse Towner 2021-02-20 21:29:35 -08:00 committed by GitHub
parent 77c6c34223
commit a037d82649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,7 +128,7 @@ function(vcpkg_internal_meson_generate_native_file_config _config) #https://meso
else()
set(LINKER_FLAGS_${_config} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${_config}}")
endif()
string(REGEX REPLACE "( |^)(-|/)" ";\\2" LINKER_FLAGS_${_config} "${LINKER_FLAGS_${_config}}")
vcpkg_internal_meson_convert_compiler_flags_to_list(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}}")
@ -278,7 +278,7 @@ function(vcpkg_internal_meson_generate_cross_file _additional_binaries) #https:/
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)
if(NOT BUILD_CPU_FAM STREQUAL HOST_CPU_FAM OR VCPKG_TARGET_IS_ANDROID OR VCPKG_TARGET_IS_IOS)
set(_file "${CURRENT_BUILDTREES_DIR}/meson-cross-${TARGET_TRIPLET}.log")
set(VCPKG_MESON_CROSS_FILE "${_file}" PARENT_SCOPE)
file(WRITE "${_file}" "${CROSS}")
@ -316,7 +316,7 @@ function(vcpkg_internal_meson_generate_cross_file_config _config) #https://meson
else()
set(LINKER_FLAGS_${_config} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${_config}}")
endif()
string(REGEX REPLACE "( |^)(-|/)" ";\\2" LINKER_FLAGS_${_config} "${LINKER_FLAGS_${_config}}")
vcpkg_internal_meson_convert_compiler_flags_to_list(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}}")