[vcpkg scripts] Crosscompiling fixes (#26617)

* test osx stuff

* deactivate most of ci

* get trace output

* add required flags to the linker flags

* also look for --sysroot

* Link_args are always shared

* fix ar flags

* setup FOR_BUILD vars.

* try tricking the build.... but man configure scripts are stupid sometimes...

* try 2

* major meson rewrite

* fix duplicates

* revert --trace-expand

* update port version

* revert pipeline changes

* v db

* bump version

* v db

* set flags for rc compilers

* a few more ios fixes.

* v db

* fix osx/ios logic

* documentation and don't fatal_error in build/host machine entry calculation.

* add android/compiler target stuff from #26570

* remove extra endif

* v db

* add target param to linker flags.

* target in cpp flags

* Make vcpkg-cmake-get-vars more ios compatible

* Update scripts/get_cmake_vars/CMakeLists.txt

Co-authored-by: Matthias Kuhn <matthias@opengis.ch>

* More ios fixes

* fix target adding

* Fix broken loop

* v db

* v db

* bump date

* v db

* v db

* v db

* remove port-version 1

* v db

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
Co-authored-by: Matthias Kuhn <matthias@opengis.ch>
This commit is contained in:
Alexander Neumann 2022-10-13 18:40:52 +02:00 committed by GitHub
parent 6800713976
commit d8e60ef474
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 352 additions and 295 deletions

View file

@ -100,6 +100,11 @@ This field is optional.
Also available as build-type specific `VCPKG_MESON_CONFIGURE_OPTIONS_DEBUG` and `VCPKG_MESON_CONFIGURE_OPTIONS_RELEASE` variables.
### VCPKG_MESON_(CROSS|NATIVE)_FILE(_RELEASE|_DEBUG)
Provide an additional (configuration dependent) file as a meson cross/native file. Can be used to override settings provided by vcpkg since it will be passed after vcpkg's generated cross/native files are passed.
Especially usefull to provide your own build_machine and host_machine entries.
### VCPKG_CMAKE_CONFIGURE_OPTIONS
Set additional CMake configure options that are appended to the configure command (in [`vcpkg_cmake_configure`](../maintainers/vcpkg_cmake_configure.md)).

View file

@ -12,7 +12,7 @@ list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING
CMAKE_SIZEOF_VOID_P
MSVC
MSVC_VERSION)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(APPLE)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT)
endif()
@ -33,7 +33,8 @@ foreach(_lang IN LISTS VCPKG_LANGUAGES)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_COMPILE_FEATURES)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_EXTENSION)
# Probably never required since implicit.
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_COMPILER_TARGET)
# Probably never required since implicit.
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES)
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_INCLUDE_DIRECTORIES)
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_DIRECTORIES)
@ -101,18 +102,18 @@ if(APPLE)
string(APPEND EXTRA_FLAGS " -arch ${arch}")
endforeach()
if(CMAKE_OSX_DEPLOYMENT_TARGET)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
string(APPEND EXTRA_FLAGS " -mios-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
string(APPEND EXTRA_FLAGS " -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
list(GET VCPKG_LANGUAGES 0 lang)
string(APPEND EXTRA_FLAGS " ${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}")
unset(lang)
endif()
endif()
if(CMAKE_CXX_COMPILER_TARGET)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
string(APPEND EXTRA_FLAGS " \"${CMAKE_CXX_COMPILE_OPTIONS_TARGET}${CMAKE_CXX_COMPILER_TARGET}\"")
elseif(CMAKE_CXX_COMPILE_OPTIONS_TARGET)
string(APPEND EXTRA_FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_TARGET} \"${CMAKE_CXX_COMPILER_TARGET}\"")
set(target_param "")
list(GET VCPKG_LANGUAGES 0 lang)
if(CMAKE_${lang}_COMPILER_TARGET)
if (CMAKE_${lang}_COMPILER_ID STREQUAL Clang)
set(target_param "${CMAKE_${lang}_COMPILE_OPTIONS_TARGET}${CMAKE_${lang}_COMPILER_TARGET}")
elseif(CMAKE_${lang}_COMPILE_OPTIONS_TARGET)
set(target_param "${CMAKE_${lang}_COMPILE_OPTIONS_TARGET} ${CMAKE_${lang}_COMPILER_TARGET}")
endif()
endif()
if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
@ -126,12 +127,14 @@ if(CMAKE_SYSROOT AND CMAKE_CXX_COMPILE_OPTIONS_SYSROOT)
string(APPEND EXTRA_FLAGS " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
endif()
foreach(flags CXX C SHARED_LINKER EXE_LINKER)
set(${flags}_FLAGS "${CMAKE_${flags}_FLAGS} ${CMAKE_${flags}_FLAGS_${VCPKG_CONFIGS}} ${EXTRA_FLAGS}")
foreach(flags ${VCPKG_LANGUAGES} SHARED_LINKER EXE_LINKER STATIC_LINKER MODULE_LINKER)
set(${flags}_FLAGS "${target_param} ${CMAKE_${flags}_FLAGS} ${CMAKE_${flags}_FLAGS_${VCPKG_CONFIGS}} ${EXTRA_FLAGS}")
string(STRIP ${flags}_FLAGS "${${flags}_FLAGS}")
endforeach()
foreach(flags STATIC_LINKER RC)
set(${flags}_FLAGS "${CMAKE_${flags}_FLAGS} ${CMAKE_${flags}_FLAGS_${VCPKG_CONFIGS}}")
string(STRIP ${flags}_FLAGS "${${flags}_FLAGS}")
endforeach()
foreach(incdir IN LISTS CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES)
@ -142,7 +145,7 @@ foreach(incdir IN LISTS CMAKE_C_STANDARD_INCLUDE_DIRECTORIES)
string(APPEND C_FLAGS " \"${CMAKE_INCLUDE_FLAG_C}${incdir}\"")
endforeach()
foreach(flag CXX C SHARED_LINKER EXE_LINKER STATIC_LINKER RC)
foreach(flag ${VCPKG_LANGUAGES} SHARED_LINKER EXE_LINKER STATIC_LINKER MODULE_LINKER RC)
# When using MSVC, maybe transform /flags to -flags.
# When cross compiling, "/flags" may be an absolute path starting with /, so don't transform.
# Otherwise, transform to improve compatibility with scripts interpreting "/flags" as a path.

View file

@ -1,7 +1,6 @@
{
"name": "vcpkg-cmake-get-vars",
"version-date": "2022-05-10",
"port-version": 1,
"version-date": "2022-09-04",
"documentation": "https://vcpkg.io/en/docs/README.html",
"license": "MIT",
"dependencies": [

View file

@ -1,6 +1,6 @@
{
"name": "vcpkg-cmake",
"version-date": "2022-09-13",
"version-date": "2022-09-26",
"documentation": "https://vcpkg.io/en/docs/maintainers/ports/vcpkg-cmake.html",
"license": "MIT"
}

View file

@ -0,0 +1,42 @@
[binaries]
cmake = ['@CMAKE_COMMAND@']
python = ['@PYTHON3@']
ninja = ['@NINJA@']
pkgconfig= ['@PKGCONFIG@']
@MESON_MT@
@MESON_AR@
@MESON_RC@
@MESON_C@
@MESON_C_LD@
@MESON_CXX@
@MESON_CXX_LD@
@MESON_OBJC@
@MESON_OBJC_LD@
@MESON_OBJCPP@
@MESON_OBJCPP_LD@
@MESON_FC@
@MESON_FC_LD@
@MESON_WINDRES@
@MESON_ADDITIONAL_BINARIES@
[properties]
cmake_toolchain_file = '@SCRIPTS@/buildsystems/vcpkg.cmake'
[cmake]
VCPKG_TARGET_TRIPLET = '@TARGET_TRIPLET@'
VCPKG_HOST_TRIPLET = '@_HOST_TRIPLET@'
VCPKG_CHAINLOAD_TOOLCHAIN_FILE = '@VCPKG_CHAINLOAD_TOOLCHAIN_FILE@'
VCPKG_CRT_LINKAGE = '@VCPKG_CRT_LINKAGE@'
_VCPKG_INSTALLED_DIR = '@_VCPKG_INSTALLED_DIR@'
@MESON_HOST_MACHINE@
@MESON_BUILD_MACHINE@
[built-in options]
default_library = '@MESON_DEFAULT_LIBRARY@'
werror = false
@MESON_CFLAGS@
@MESON_CXXFLAGS@
@MESON_FCFLAGS@
@MESON_OBJCFLAGS@
@MESON_OBJCPPFLAGS@
# b_vscrt
@MESON_VSCRT_LINKAGE@
# c_winlibs/cpp_winlibs
@MESON_WINLIBS@

View file

@ -74,8 +74,8 @@ macro(z_vcpkg_determine_autotools_target_arch_mac out_var)
endmacro()
macro(z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags flag_suffix)
string(REGEX MATCHALL "( |^)-D[^ ]+" CPPFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}")
string(REGEX MATCHALL "( |^)-D[^ ]+" CXXPPFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${flag_suffix}}")
string(REGEX MATCHALL "( |^)(-D|-isysroot|--sysroot=|-isystem|-m?[Aa][Rr][Cc][Hh]|--target=|-target) ?[^ ]+" CPPFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}")
string(REGEX MATCHALL "( |^)(-D|-isysroot|--sysroot=|-isystem|-m?[Aa][Rr][Cc][Hh]|--target=|-target) ?[^ ]+" CXXPPFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${flag_suffix}}")
list(JOIN CXXPPFLAGS_${flag_suffix} "|" CXXREGEX)
if(CXXREGEX)
list(FILTER CPPFLAGS_${flag_suffix} INCLUDE REGEX "(${CXXREGEX})")
@ -384,7 +384,7 @@ function(vcpkg_configure_make)
# Currently needed for arm because objdump yields: "unrecognised machine type (0x1c4) in Import Library Format archive"
list(APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all)
endif()
elseif(NOT VCPKG_TARGET_IS_OSX)
else()
# Because OSX dosn't like CMAKE_C(XX)_COMPILER (cc) in CC/CXX and rather wants to have gcc/g++
function(z_vcpkg_make_set_env envvar cmakevar)
set(prog "${VCPKG_DETECTED_CMAKE_${cmakevar}} ${ARGN}")
@ -432,7 +432,7 @@ function(vcpkg_configure_make)
endif()
# macOS - cross-compiling support
if(VCPKG_TARGET_IS_OSX)
if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS)
if (requires_autoconfig AND NOT arg_BUILD_TRIPLET OR arg_DETERMINE_BUILD_TRIPLET)
z_vcpkg_determine_autotools_host_arch_mac(BUILD_ARCH) # machine you are building on => --build=
z_vcpkg_determine_autotools_target_arch_mac(TARGET_ARCH)
@ -441,7 +441,7 @@ function(vcpkg_configure_make)
# --target: the machine that CC will produce binaries for
# https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler
# Only for ports using autotools so we can assume that they follow the common conventions for build/target/host
if(NOT "${TARGET_ARCH}" STREQUAL "${BUILD_ARCH}") # we don't need to specify the additional flags if we build natively.
if(NOT "${TARGET_ARCH}" STREQUAL "${BUILD_ARCH}" OR NOT VCPKG_TARGET_IS_OSX) # we don't need to specify the additional flags if we build natively.
set(arg_BUILD_TRIPLET "--host=${TARGET_ARCH}-apple-darwin") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
endif()
debug_message("Using make triplet: ${arg_BUILD_TRIPLET}")
@ -754,10 +754,14 @@ function(vcpkg_configure_make)
# Setup environment
set(ENV{CPPFLAGS} "${CPPFLAGS_${current_buildtype}}")
set(ENV{CPPFLAGS_FOR_BUILD} "${CPPFLAGS_${current_buildtype}}")
set(ENV{CFLAGS} "${CFLAGS_${current_buildtype}}")
set(ENV{CFLAGS_FOR_BUILD} "${CFLAGS_${current_buildtype}}")
set(ENV{CXXFLAGS} "${CXXFLAGS_${current_buildtype}}")
#set(ENV{CXXFLAGS_FOR_BUILD} "${CXXFLAGS_${current_buildtype}}") -> doesn't exist officially
set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${current_buildtype}}")
set(ENV{LDFLAGS} "${LDFLAGS_${current_buildtype}}")
set(ENV{LDFLAGS_FOR_BUILD} "${LDFLAGS_${current_buildtype}}")
if(ARFLAGS_${current_buildtype} AND NOT (arg_USE_WRAPPERS AND VCPKG_TARGET_IS_WINDOWS))
# Target windows with wrappers enabled cannot forward ARFLAGS since it breaks the wrapper
set(ENV{ARFLAGS} "${ARFLAGS_${current_buildtype}}")
@ -767,6 +771,13 @@ function(vcpkg_configure_make)
# and libtool tries to avoid versioning for shared libraries and no symbolic links are created.
if(VCPKG_TARGET_IS_ANDROID)
set(ENV{LDFLAGS} "-avoid-version $ENV{LDFLAGS}")
set(ENV{LDFLAGS_FOR_BUILD} "-avoid-version $ENV{LDFLAGS_FOR_BUILD}")
endif()
if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS)
# configure not using all flags to check if compiler works ...
set(ENV{CC} "$ENV{CC} $ENV{CPPFLAGS} $ENV{CFLAGS}")
set(ENV{CC_FOR_BUILD} "$ENV{CC_FOR_BUILD} $ENV{CPPFLAGS} $ENV{CFLAGS}")
endif()
if(LINK_ENV_${current_buildtype})

View file

@ -1,5 +1,4 @@
function(z_vcpkg_append_proglist var_to_append additional_binaries)
string(APPEND "${var_to_append}" "[binaries]\n")
function(z_vcpkg_meson_set_proglist_variables config_type)
if(VCPKG_TARGET_IS_WINDOWS)
set(proglist MT AR)
else()
@ -8,85 +7,53 @@ function(z_vcpkg_append_proglist var_to_append additional_binaries)
foreach(prog IN LISTS proglist)
if(VCPKG_DETECTED_CMAKE_${prog})
if(meson_${prog})
string(APPEND "${var_to_append}" "${meson_${prog}} = '${VCPKG_DETECTED_CMAKE_${prog}}'\n")
else()
string(TOUPPER "MESON_${meson_${prog}}" var_to_set)
set("${var_to_set}" "${meson_${prog}} = ['${VCPKG_DETECTED_CMAKE_${prog}}']" PARENT_SCOPE)
elseif(${prog} STREQUAL AR AND VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${config_type})
# Probably need to move AR somewhere else
string(TOLOWER "${prog}" proglower)
string(APPEND "${var_to_append}" "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}}'\n")
z_vcpkg_meson_convert_compiler_flags_to_list(ar_flags "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${config_type}}")
list(PREPEND ar_flags "${VCPKG_DETECTED_CMAKE_${prog}}")
z_vcpkg_meson_convert_list_to_python_array(ar_flags ${ar_flags})
set("MESON_AR" "${proglower} = ${ar_flags}" PARENT_SCOPE)
else()
string(TOUPPER "MESON_${prog}" var_to_set)
string(TOLOWER "${prog}" proglower)
set("${var_to_set}" "${proglower} = ['${VCPKG_DETECTED_CMAKE_${prog}}']" PARENT_SCOPE)
endif()
endif()
endforeach()
set(programs C CXX RC)
set(meson_RC windres)
set(meson_CXX cpp)
foreach(prog IN LISTS programs)
if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER)
if(meson_${prog})
string(APPEND "${var_to_append}" "${meson_${prog}} = '${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}'\n")
else()
string(TOLOWER "${prog}" proglower)
string(APPEND "${var_to_append}" "${proglower} = '${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}'\n")
endif()
endif()
endforeach()
if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS)
# for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456
if (NOT VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel)$")
string(APPEND "${var_to_append}" "c_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n")
endif()
endif()
if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS)
# for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456
if (NOT VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Intel)$")
string(APPEND "${var_to_append}" "cpp_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n")
endif()
endif()
get_filename_component(CMAKE_PATH "${CMAKE_COMMAND}" DIRECTORY)
vcpkg_add_to_path("${CMAKE_PATH}" PREPEND) # Make CMake invokeable for Meson
string(APPEND "${var_to_append}" "cmake = '${CMAKE_COMMAND}'\n")
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")
string(APPEND "${var_to_append}" "python = '${PYTHON3}'\n")
vcpkg_find_acquire_program(NINJA)
get_filename_component(NINJA_PATH ${NINJA} DIRECTORY)
vcpkg_add_to_path(PREPEND "${NINJA_PATH}") # Prepend to use the correct ninja.
# string(APPEND "${var_to_append}" "ninja = '${NINJA}'\n") # This does not work due to meson issues
foreach(additional_binary IN LISTS additional_binaries)
string(APPEND "${var_to_append}" "${additional_binary}\n")
endforeach()
set("${var_to_append}" "${${var_to_append}}" PARENT_SCOPE)
endfunction()
function(z_vcpkg_meson_generate_native_file additional_binaries) #https://mesonbuild.com/Native-environments.html
set(native_config "")
z_vcpkg_append_proglist(native_config "${additional_binaries}")
string(APPEND native_config "[built-in options]\n") #https://mesonbuild.com/Builtin-options.html
if(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe")
# This is currently wrongly documented in the meson docs or buggy. The docs say: 'none' = no flags
# In reality however 'none' tries to deactivate eh and meson passes the flags for it resulting in a lot of warnings
# about overriden flags. Until this is fixed in meson vcpkg should not pass this here.
# string(APPEND native_config "cpp_eh='none'\n") # To make sure meson is not adding eh flags by itself using msvc
endif()
set(compilers "${arg_LANGUAGES}")
if(VCPKG_TARGET_IS_WINDOWS)
set(c_winlibs "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES}")
set(cpp_winlibs "${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
foreach(libvar IN ITEMS c_winlibs cpp_winlibs)
string(REGEX REPLACE "( |^)(-|/)" [[;\2]] "${libvar}" "${${libvar}}")
string(REPLACE ".lib " ".lib;" "${libvar}" "${${libvar}}")
vcpkg_list(REMOVE_ITEM "${libvar}" "")
vcpkg_list(JOIN "${libvar}" "', '" "${libvar}")
string(APPEND native_config "${libvar} = ['${${libvar}}']\n")
endforeach()
list(APPEND compilers RC)
endif()
set(native_config_name "${CURRENT_BUILDTREES_DIR}/meson-native-${TARGET_TRIPLET}.log")
set(vcpkg_meson_native_file "${native_config_name}" PARENT_SCOPE)
file(WRITE "${native_config_name}" "${native_config}")
set(meson_RC windres)
set(meson_Fortran fc)
set(meson_CXX cpp)
foreach(prog IN LISTS compilers)
if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER)
string(TOUPPER "MESON_${prog}" var_to_set)
if(meson_${prog})
set("${var_to_set}" "${meson_${prog}} = ['${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}']" PARENT_SCOPE)
if (DEFINED VCPKG_DETECTED_CMAKE_${prog}_COMPILER_ID AND NOT VCPKG_DETECTED_CMAKE_${prog}_COMPILER_ID MATCHES "^(GNU|Intel)$")
string(TOUPPER "MESON_${prog}_LD" var_to_set)
set(${var_to_set} "${meson_${prog}}_ld = ['${VCPKG_DETECTED_CMAKE_LINKER}']" PARENT_SCOPE)
endif()
elseif(${prog} MATCHES RC AND VCPKG_DETECTED_CMAKE_RC_FLAGS_${config_type})
z_vcpkg_meson_convert_compiler_flags_to_list(rc_flags "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${config_type}}")
list(PREPEND rc_flags "${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}")
z_vcpkg_meson_convert_list_to_python_array(rc_flags ${rc_flags})
set("${var_to_set}" "${meson_${prog}} = ${rc_flags}" PARENT_SCOPE)
else()
string(TOLOWER "${prog}" proglower)
set("${var_to_set}" "${proglower} = ['${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}']" PARENT_SCOPE)
if (DEFINED VCPKG_DETECTED_CMAKE_${prog}_COMPILER_ID AND NOT VCPKG_DETECTED_CMAKE_${prog}_COMPILER_ID MATCHES "^(GNU|Intel)$")
string(TOUPPER "MESON_${prog}_LD" var_to_set)
set(${var_to_set} "${proglower}_ld = ['${VCPKG_DETECTED_CMAKE_LINKER}']" PARENT_SCOPE)
endif()
endif()
endif()
endforeach()
endfunction()
function(z_vcpkg_meson_convert_compiler_flags_to_list out_var compiler_flags)
@ -105,9 +72,7 @@ function(z_vcpkg_meson_convert_list_to_python_array out_var)
endfunction()
# Generates the required compiler properties for meson
function(z_vcpkg_meson_generate_flags_properties_string out_var config_type)
set(result "")
function(z_vcpkg_meson_set_flags_variables config_type)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
set(libpath_flag /LIBPATH:)
else()
@ -119,77 +84,35 @@ function(z_vcpkg_meson_generate_flags_properties_string out_var config_type)
set(path_suffix "")
endif()
set(includepath "-I${CURRENT_INSTALLED_DIR}/include")
set(libpath "${libpath_flag}${CURRENT_INSTALLED_DIR}${path_suffix}/lib")
z_vcpkg_meson_convert_compiler_flags_to_list(cflags "${VCPKG_DETECTED_CMAKE_C_FLAGS_${config_type}}")
vcpkg_list(APPEND cflags "-I${CURRENT_INSTALLED_DIR}/include")
z_vcpkg_meson_convert_list_to_python_array(cflags ${cflags})
string(APPEND result "c_args = ${cflags}\n")
z_vcpkg_meson_convert_compiler_flags_to_list(cxxflags "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${config_type}}")
vcpkg_list(APPEND cxxflags "-I${CURRENT_INSTALLED_DIR}/include")
z_vcpkg_meson_convert_list_to_python_array(cxxflags ${cxxflags})
string(APPEND result "cpp_args = ${cxxflags}\n")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
foreach(lang IN LISTS arg_LANGUAGES)
z_vcpkg_meson_convert_compiler_flags_to_list(${lang}flags "${VCPKG_DETECTED_CMAKE_${lang}_FLAGS_${config_type}}")
if(lang MATCHES "^(C|CXX)$")
vcpkg_list(APPEND ${lang}flags "${includepath}")
endif()
z_vcpkg_meson_convert_list_to_python_array(${lang}flags ${${lang}flags})
set(lang_mapping "${lang}")
if(lang STREQUAL "Fortran")
set(lang_mapping "FC")
endif()
string(TOLOWER "${lang_mapping}" langlower)
if(lang STREQUAL "CXX")
set(langlower cpp)
endif()
set(MESON_${lang_mapping}FLAGS "${langlower}_args = ${${lang}flags}\n")
set(linker_flags "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${config_type}}")
else()
set(linker_flags "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${config_type}}")
endif()
z_vcpkg_meson_convert_compiler_flags_to_list(linker_flags "${linker_flags}")
if(VCPKG_TARGET_IS_OSX)
# macOS - append arch and isysroot if cross-compiling
if(NOT "${VCPKG_OSX_ARCHITECTURES}" STREQUAL "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}")
foreach(arch IN LISTS VCPKG_OSX_ARCHITECTURES)
vcpkg_list(APPEND linker_flags -arch "${arch}")
endforeach()
endif()
if(VCPKG_DETECTED_CMAKE_OSX_SYSROOT)
vcpkg_list(APPEND linker_flags -isysroot "${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}")
endif()
endif()
vcpkg_list(APPEND linker_flags "${libpath}")
z_vcpkg_meson_convert_list_to_python_array(linker_flags ${linker_flags})
string(APPEND result "c_link_args = ${linker_flags}\n")
string(APPEND result "cpp_link_args = ${linker_flags}\n")
set("${out_var}" "${result}" PARENT_SCOPE)
z_vcpkg_meson_convert_compiler_flags_to_list(linker_flags "${linker_flags}")
vcpkg_list(APPEND linker_flags "${libpath}")
z_vcpkg_meson_convert_list_to_python_array(linker_flags ${linker_flags})
string(APPEND MESON_${lang_mapping}FLAGS "${langlower}_link_args = ${linker_flags}")
set(MESON_${lang_mapping}FLAGS "${MESON_${lang_mapping}FLAGS}" PARENT_SCOPE)
endforeach()
endfunction()
function(z_vcpkg_meson_generate_native_file_config config_type) #https://mesonbuild.com/Native-environments.html
set(native_file "[properties]\n") #https://mesonbuild.com/Builtin-options.html
#Setup CMake properties
string(APPEND native_file "cmake_toolchain_file = '${SCRIPTS}/buildsystems/vcpkg.cmake'\n")
string(APPEND native_file "[cmake]\n")
if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
z_vcpkg_select_default_vcpkg_chainload_toolchain()
endif()
string(APPEND native_file "VCPKG_TARGET_TRIPLET = '${TARGET_TRIPLET}'\n")
string(APPEND native_file "VCPKG_CHAINLOAD_TOOLCHAIN_FILE = '${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}'\n")
string(APPEND native_file "VCPKG_CRT_LINKAGE = '${VCPKG_CRT_LINKAGE}'\n")
string(APPEND native_file "[built-in options]\n")
z_vcpkg_meson_generate_flags_properties_string(native_properties "${config_type}")
string(APPEND native_file "${native_properties}")
if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_CRT_LINKAGE STREQUAL "static")
set(crt_type mt)
else()
set(crt_type md)
endif()
if("${config_type}" STREQUAL "DEBUG")
string(APPEND crt_type "d")
endif()
string(APPEND native_file "b_vscrt = '${crt_type}'\n")
endif()
string(TOLOWER "${config_type}" lowerconfig)
set(native_config_name "${CURRENT_BUILDTREES_DIR}/meson-native-${TARGET_TRIPLET}-${lowerconfig}.log")
file(WRITE "${native_config_name}" "${native_file}")
set("vcpkg_meson_native_file_${config_type}" "${native_config_name}" PARENT_SCOPE)
endfunction()
function(z_vcpkg_meson_generate_cross_file additional_binaries) #https://mesonbuild.com/Cross-compilation.html
function(z_vcpkg_get_build_and_host_system build_system host_system is_cross) #https://mesonbuild.com/Cross-compilation.html
set(build_unknown FALSE)
if(CMAKE_HOST_WIN32)
if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
set(build_arch $ENV{PROCESSOR_ARCHITEW6432})
@ -209,7 +132,10 @@ function(z_vcpkg_meson_generate_cross_file additional_binaries) #https://mesonbu
set(build_cpu_fam arm)
set(build_cpu armv7hl)
else()
message(FATAL_ERROR "Unsupported host architecture ${build_arch}!")
if(NOT DEFINED VCPKG_MESON_CROSS_FILE OR NOT DEFINED VCPKG_MESON_NATIVE_FILE)
message(WARNING "Unsupported build architecture ${build_arch}! Please set VCPKG_MESON_(CROSS|NATIVE)_FILE to a meson file containing the build_machine entry!")
endif()
set(build_unknown TRUE)
endif()
elseif(CMAKE_HOST_UNIX)
# at this stage, CMAKE_HOST_SYSTEM_PROCESSOR is not defined
@ -217,7 +143,7 @@ function(z_vcpkg_meson_generate_cross_file additional_binaries) #https://mesonbu
COMMAND uname -m
OUTPUT_VARIABLE MACHINE
COMMAND_ERROR_IS_FATAL ANY)
# Show real machine architecture to visually understand whether we are in a native Apple Silicon terminal or running under Rosetta emulation
debug_message("Machine: ${MACHINE}")
@ -241,12 +167,43 @@ function(z_vcpkg_meson_generate_cross_file additional_binaries) #https://mesonbu
set(build_cpu loongarch64)
else()
# https://github.com/mesonbuild/meson/blob/master/docs/markdown/Reference-tables.md#cpu-families
message(FATAL_ERROR "Unhandled machine: ${MACHINE}")
if(NOT DEFINED VCPKG_MESON_CROSS_FILE OR NOT DEFINED VCPKG_MESON_NATIVE_FILE)
message(WARNING "Unhandled machine: ${MACHINE}! Please set VCPKG_MESON_(CROSS|NATIVE)_FILE to a meson file containing the build_machine entry!")
endif()
set(build_unknown TRUE)
endif()
else()
message(FATAL_ERROR "Failed to detect the host architecture!")
if(NOT DEFINED VCPKG_MESON_CROSS_FILE OR NOT DEFINED VCPKG_MESON_NATIVE_FILE)
message(WARNING "Failed to detect the build architecture! Please set VCPKG_MESON_(CROSS|NATIVE)_FILE to a meson file containing the build_machine entry!")
endif()
set(build_unknown TRUE)
endif()
set(build "[build_machine]\n") # Machine the build is performed on
string(APPEND build "endian = 'little'\n")
if(WIN32)
string(APPEND build "system = 'windows'\n")
elseif(DARWIN)
string(APPEND build "system = 'darwin'\n")
elseif(CYGWIN)
string(APPEND build "system = 'cygwin'\n")
elseif(UNIX)
string(APPEND build "system = 'linux'\n")
else()
set(build_unknown TRUE)
endif()
if(DEFINED build_cpu_fam)
string(APPEND build "cpu_family = '${build_cpu_fam}'\n")
endif()
if(DEFINED build_cpu)
string(APPEND build "cpu = '${build_cpu}'")
endif()
if(NOT build_unknown)
set(${build_system} "${build}" PARENT_SCOPE)
endif()
set(host_unkown FALSE)
if(VCPKG_TARGET_ARCHITECTURE MATCHES "(amd|AMD|x|X)64")
set(host_cpu_fam x86_64)
set(host_cpu x86_64)
@ -266,153 +223,172 @@ function(z_vcpkg_meson_generate_cross_file additional_binaries) #https://mesonbu
set(host_cpu_fam wasm32)
set(host_cpu wasm32)
else()
message(FATAL_ERROR "Unsupported target architecture ${VCPKG_TARGET_ARCHITECTURE}!" )
if(NOT DEFINED VCPKG_MESON_CROSS_FILE OR NOT DEFINED VCPKG_MESON_NATIVE_FILE)
message(WARNING "Unsupported target architecture ${VCPKG_TARGET_ARCHITECTURE}! Please set VCPKG_MESON_(CROSS|NATIVE)_FILE to a meson file containing the host_machine entry!" )
endif()
set(host_unkown TRUE)
endif()
set(cross_file "")
z_vcpkg_append_proglist(cross_file "${additional_binaries}")
string(APPEND cross_file "[properties]\n")
string(APPEND cross_file "[host_machine]\n")
string(APPEND cross_file "endian = 'little'\n")
set(host "[host_machine]\n") # host=target in vcpkg.
string(APPEND host "endian = 'little'\n")
if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_TARGET_IS_MINGW OR VCPKG_TARGET_IS_UWP)
set(meson_system_name "windows")
else()
string(TOLOWER "${VCPKG_CMAKE_SYSTEM_NAME}" meson_system_name)
endif()
string(APPEND cross_file "system = '${meson_system_name}'\n")
string(APPEND cross_file "cpu_family = '${host_cpu_fam}'\n")
string(APPEND cross_file "cpu = '${host_cpu}'\n")
string(APPEND cross_file "[build_machine]\n")
string(APPEND cross_file "endian = 'little'\n")
if(WIN32)
string(APPEND cross_file "system = 'windows'\n")
elseif(DARWIN)
string(APPEND cross_file "system = 'darwin'\n")
else()
string(APPEND cross_file "system = 'linux'\n")
endif()
if(DEFINED build_cpu_fam)
string(APPEND cross_file "cpu_family = '${build_cpu_fam}'\n")
endif()
if(DEFINED build_cpu)
string(APPEND cross_file "cpu = '${build_cpu}'\n")
string(APPEND host "system = '${meson_system_name}'\n")
string(APPEND host "cpu_family = '${host_cpu_fam}'\n")
string(APPEND host "cpu = '${host_cpu}'")
if(NOT host_unkown)
set(${host_system} "${host}" PARENT_SCOPE)
endif()
if(NOT build_cpu_fam MATCHES "${host_cpu_fam}"
OR VCPKG_TARGET_IS_ANDROID OR VCPKG_TARGET_IS_IOS OR VCPKG_TARGET_IS_UWP
OR (VCPKG_TARGET_IS_MINGW AND NOT WIN32))
set(native_config_name "${CURRENT_BUILDTREES_DIR}/meson-cross-${TARGET_TRIPLET}.log")
set(vcpkg_meson_cross_file "${native_config_name}" PARENT_SCOPE)
file(WRITE "${native_config_name}" "${cross_file}")
set(${is_cross} TRUE PARENT_SCOPE)
endif()
endfunction()
function(z_vcpkg_meson_generate_cross_file_config config_type) #https://mesonbuild.com/Native-environments.html
set(cross_${config_type}_log "[properties]\n") #https://mesonbuild.com/Builtin-options.html
string(APPEND cross_${config_type}_log "[built-in options]\n")
z_vcpkg_meson_generate_flags_properties_string(cross_properties ${config_type})
string(APPEND cross_${config_type}_log "${cross_properties}")
function(z_vcpkg_meson_setup_extra_windows_variables config_type)
## b_vscrt
if(VCPKG_CRT_LINKAGE STREQUAL "static")
set(crt_type "mt")
else()
set(crt_type "md")
endif()
if(config_type STREQUAL "DEBUG")
set(crt_type "${crt_type}d")
endif()
set(MESON_VSCRT_LINKAGE "b_vscrt = '${crt_type}'" PARENT_SCOPE)
## winlibs
separate_arguments(c_winlibs NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES}")
separate_arguments(cpp_winlibs NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
list(TRANSFORM c_winlibs REPLACE "^(-|/)" "")
list(TRANSFORM cpp_winlibs REPLACE "^(-|/)" "")
z_vcpkg_meson_convert_list_to_python_array(c_winlibs ${c_winlibs})
z_vcpkg_meson_convert_list_to_python_array(cpp_winlibs ${cpp_winlibs})
set(MESON_WINLIBS "c_winlibs = ${c_winlibs}\n")
string(APPEND MESON_WINLIBS "cpp_winlibs = ${cpp_winlibs}")
set(MESON_WINLIBS "${MESON_WINLIBS}" PARENT_SCOPE)
endfunction()
function(z_vcpkg_meson_setup_variables config_type)
set(meson_var_list VSCRT_LINKAGE WINLIBS MT AR RC C C_LD CXX CXX_LD OBJC OBJC_LD OBJCXX OBJCXX_LD FC FC_LD WINDRES CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS FCFLAGS SHARED_LINKER_FLAGS)
foreach(var IN LISTS meson_var_list)
set(MESON_${var} "")
endforeach()
if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_CRT_LINKAGE STREQUAL "static")
set(crt_type mt)
else()
set(crt_type md)
endif()
if(${config_type} STREQUAL "DEBUG")
set(crt_type ${crt_type}d)
endif()
set(c_winlibs "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES}")
set(cpp_winlibs "${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
foreach(libvar IN ITEMS c_winlibs cpp_winlibs)
string(REGEX REPLACE "( |^)(-|/)" [[;\2]] "${libvar}" "${${libvar}}")
string(REPLACE ".lib " ".lib;" "${libvar}" "${${libvar}}")
vcpkg_list(REMOVE_ITEM "${libvar}" "")
vcpkg_list(JOIN "${libvar}" "', '" "${libvar}")
string(APPEND cross_${config_type}_log "${libvar} = ['${${libvar}}']\n")
endforeach()
string(APPEND cross_${config_type}_log "b_vscrt = '${crt_type}'\n")
z_vcpkg_meson_setup_extra_windows_variables("${config_type}")
endif()
string(TOLOWER "${config_type}" lowerconfig)
set(native_config_name "${CURRENT_BUILDTREES_DIR}/meson-cross-${TARGET_TRIPLET}-${lowerconfig}.log")
set(VCPKG_MESON_CROSS_FILE_${config_type} "${native_config_name}" PARENT_SCOPE)
file(WRITE "${native_config_name}" "${cross_${config_type}_log}")
endfunction()
z_vcpkg_meson_set_proglist_variables("${config_type}")
z_vcpkg_meson_set_flags_variables("${config_type}")
foreach(var IN LISTS meson_var_list)
set(MESON_${var} "${MESON_${var}}" PARENT_SCOPE)
endforeach()
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 arg
"NO_PKG_CONFIG"
"SOURCE_PATH"
"OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;ADDITIONAL_NATIVE_BINARIES;ADDITIONAL_CROSS_BINARIES"
"OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;LANGUAGES;ADDITIONAL_BINARIES;ADDITIONAL_NATIVE_BINARIES;ADDITIONAL_CROSS_BINARIES"
)
if(NOT arg_LANGUAGES)
set(arg_LANGUAGES C CXX)
endif()
if(DEFINED arg_ADDITIONAL_NATIVE_BINARIES OR DEFINED arg_ADDITIONAL_CROSS_BINARIES)
message(WARNING "Options ADDITIONAL_(NATIVE|CROSS)_BINARIES have been deprecated. Only use ADDITIONAL_BINARIES!")
endif()
vcpkg_list(APPEND arg_ADDITIONAL_BINARIES ${arg_ADDITIONAL_NATIVE_BINARIES} ${arg_ADDITIONAL_CROSS_BINARIES})
vcpkg_list(REMOVE_DUPLICATES arg_ADDITIONAL_BINARIES)
vcpkg_list(JOIN arg_ADDITIONAL_BINARIES "\n" MESON_ADDITIONAL_BINARIES)
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
z_vcpkg_select_default_vcpkg_chainload_toolchain()
endif()
z_vcpkg_get_cmake_vars(cmake_vars_file)
debug_message("Including cmake vars from: ${cmake_vars_file}")
include("${cmake_vars_file}")
vcpkg_find_acquire_program(MESON)
get_filename_component(CMAKE_PATH "${CMAKE_COMMAND}" DIRECTORY)
vcpkg_add_to_path("${CMAKE_PATH}" PREPEND) # Make CMake invokeable for Meson
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")
vcpkg_find_acquire_program(NINJA)
get_filename_component(NINJA_PATH ${NINJA} DIRECTORY)
vcpkg_add_to_path(PREPEND "${NINJA_PATH}") # Prepend to use the correct ninja.
set(buildtypes "")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
set(buildname "DEBUG")
vcpkg_list(APPEND buildtypes "${buildname}")
set(path_suffix_${buildname} "debug/")
set(suffix_${buildname} "dbg")
set(meson_input_file_${buildname} "${CURRENT_BUILDTREES_DIR}/meson-${TARGET_TRIPLET}-${suffix_${buildname}}.log")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
set(buildname "RELEASE")
vcpkg_list(APPEND buildtypes "${buildname}")
set(path_suffix_${buildname} "")
set(suffix_${buildname} "rel")
set(meson_input_file_${buildname} "${CURRENT_BUILDTREES_DIR}/meson-${TARGET_TRIPLET}-${suffix_${buildname}}.log")
endif()
vcpkg_list(APPEND arg_OPTIONS --buildtype plain --backend ninja --wrap-mode nodownload)
# Allow overrides / additional configuration variables from triplets
if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS)
vcpkg_list(APPEND arg_OPTIONS ${VCPKG_MESON_CONFIGURE_OPTIONS})
endif()
if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS_RELEASE)
vcpkg_list(APPEND arg_OPTIONS_RELEASE ${VCPKG_MESON_CONFIGURE_OPTIONS_RELEASE})
endif()
if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS_DEBUG)
vcpkg_list(APPEND arg_OPTIONS_DEBUG ${VCPKG_MESON_CONFIGURE_OPTIONS_DEBUG})
z_vcpkg_get_build_and_host_system(MESON_HOST_MACHINE MESON_BUILD_MACHINE IS_CROSS)
if(IS_CROSS)
# VCPKG_CROSSCOMPILING is not used since it regresses a lot of ports in x64-windows-x triplets
# For consistency this should proably be changed in the future?
vcpkg_list(APPEND arg_OPTIONS --native "${SCRIPTS}/buildsystems/meson/none.txt")
vcpkg_list(APPEND arg_OPTIONS_DEBUG --cross "${meson_input_file_DEBUG}")
vcpkg_list(APPEND arg_OPTIONS_RELEASE --cross "${meson_input_file_RELEASE}")
else()
vcpkg_list(APPEND arg_OPTIONS_DEBUG --native "${meson_input_file_DEBUG}")
vcpkg_list(APPEND arg_OPTIONS_RELEASE --native "${meson_input_file_RELEASE}")
endif()
if(NOT vcpkg_meson_cross_file)
z_vcpkg_meson_generate_cross_file("${arg_ADDITIONAL_CROSS_BINARIES}")
# User provided cross/native files
if(VCPKG_MESON_NATIVE_FILE)
vcpkg_list(APPEND arg_OPTIONS_RELEASE --native "${VCPKG_MESON_NATIVE_FILE}")
endif()
# We must use uppercase `DEBUG` and `RELEASE` here because they matches the configuration data
if(NOT VCPKG_MESON_CROSS_FILE_DEBUG AND vcpkg_meson_cross_file)
z_vcpkg_meson_generate_cross_file_config(DEBUG)
if(VCPKG_MESON_NATIVE_FILE_RELEASE)
vcpkg_list(APPEND arg_OPTIONS_RELEASE --native "${VCPKG_MESON_NATIVE_FILE_RELEASE}")
endif()
if(NOT VCPKG_MESON_CROSS_FILE_RELEASE AND vcpkg_meson_cross_file)
z_vcpkg_meson_generate_cross_file_config(RELEASE)
if(VCPKG_MESON_NATIVE_FILE_DEBUG)
vcpkg_list(APPEND arg_OPTIONS_DEBUG --native "${VCPKG_MESON_NATIVE_FILE_DEBUG}")
endif()
if(vcpkg_meson_cross_file)
vcpkg_list(APPEND arg_OPTIONS --cross "${vcpkg_meson_cross_file}")
endif()
if(VCPKG_MESON_CROSS_FILE_DEBUG)
vcpkg_list(APPEND arg_OPTIONS_DEBUG --cross "${VCPKG_MESON_CROSS_FILE_DEBUG}")
if(VCPKG_MESON_CROSS_FILE)
vcpkg_list(APPEND arg_OPTIONS_RELEASE --cross "${VCPKG_MESON_CROSS_FILE}")
endif()
if(VCPKG_MESON_CROSS_FILE_RELEASE)
vcpkg_list(APPEND arg_OPTIONS_RELEASE --cross "${VCPKG_MESON_CROSS_FILE_RELEASE}")
endif()
if(VCPKG_MESON_CROSS_FILE_DEBUG)
vcpkg_list(APPEND arg_OPTIONS_DEBUG --cross "${VCPKG_MESON_CROSS_FILE_DEBUG}")
endif()
if(NOT vcpkg_meson_native_file AND NOT vcpkg_meson_cross_file)
z_vcpkg_meson_generate_native_file("${arg_ADDITIONAL_NATIVE_BINARIES}")
endif()
if(NOT vcpkg_meson_native_file_DEBUG AND NOT vcpkg_meson_cross_file)
z_vcpkg_meson_generate_native_file_config(DEBUG)
endif()
if(NOT vcpkg_meson_native_file_RELEASE AND NOT vcpkg_meson_cross_file)
z_vcpkg_meson_generate_native_file_config(RELEASE)
endif()
if(vcpkg_meson_native_file AND NOT vcpkg_meson_cross_file)
vcpkg_list(APPEND arg_OPTIONS --native "${vcpkg_meson_native_file}")
vcpkg_list(APPEND arg_OPTIONS_DEBUG --native "${vcpkg_meson_native_file_DEBUG}")
vcpkg_list(APPEND arg_OPTIONS_RELEASE --native "${vcpkg_meson_native_file_RELEASE}")
else()
vcpkg_list(APPEND arg_OPTIONS --native "${SCRIPTS}/buildsystems/meson/none.txt")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
vcpkg_list(APPEND arg_OPTIONS --default-library shared)
set(MESON_DEFAULT_LIBRARY shared)
else()
vcpkg_list(APPEND arg_OPTIONS --default-library static)
set(MESON_DEFAULT_LIBRARY static)
endif()
vcpkg_list(APPEND arg_OPTIONS --libdir lib) # else meson install into an architecture describing folder
@ -427,23 +403,18 @@ function(vcpkg_configure_meson)
vcpkg_list(APPEND arg_OPTIONS_DEBUG "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}']")
vcpkg_list(APPEND arg_OPTIONS_RELEASE "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/debug']")
endif()
set(buildtypes)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
set(buildname "DEBUG")
vcpkg_list(APPEND buildtypes ${buildname})
set(path_suffix_${buildname} "debug/")
set(suffix_${buildname} "dbg")
# Allow overrides / additional configuration variables from triplets
if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS)
vcpkg_list(APPEND arg_OPTIONS ${VCPKG_MESON_CONFIGURE_OPTIONS})
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
set(buildname "RELEASE")
vcpkg_list(APPEND buildtypes ${buildname})
set(path_suffix_${buildname} "")
set(suffix_${buildname} "rel")
if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS_RELEASE)
vcpkg_list(APPEND arg_OPTIONS_RELEASE ${VCPKG_MESON_CONFIGURE_OPTIONS_RELEASE})
endif()
if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS_DEBUG)
vcpkg_list(APPEND arg_OPTIONS_DEBUG ${VCPKG_MESON_CONFIGURE_OPTIONS_DEBUG})
endif()
vcpkg_backup_env_variables(VARS INCLUDE)
vcpkg_host_path_list(APPEND ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include")
# configure build
foreach(buildtype IN LISTS buildtypes)
message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${buildtype}}")
@ -457,6 +428,9 @@ function(vcpkg_configure_meson)
endif()
endif()
z_vcpkg_meson_setup_variables(${buildtype})
configure_file("${SCRIPTS}/buildsystems/meson/meson.template.in" "${meson_input_file_${buildtype}}" @ONLY)
vcpkg_execute_required_process(
COMMAND ${MESON} ${arg_OPTIONS} ${arg_OPTIONS_${buildtype}} ${arg_SOURCE_PATH}
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${suffix_${buildtype}}"
@ -473,6 +447,4 @@ function(vcpkg_configure_meson)
z_vcpkg_restore_pkgconfig_path()
endif()
endforeach()
vcpkg_restore_env_variables(VARS INCLUDE)
endfunction()

View file

@ -9,7 +9,7 @@ list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING
CMAKE_HOST_SYSTEM_NAME
CMAKE_SYSTEM_PROCESSOR
CMAKE_HOST_SYSTEM_PROCESSOR)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(APPLE)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT)
endif()
@ -30,7 +30,8 @@ foreach(_lang IN LISTS VCPKG_LANGUAGES)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_COMPILE_FEATURES)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_EXTENSION)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_COMPILER_TARGET)
# Probably never required since implicit.
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES)
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_INCLUDE_DIRECTORIES)
@ -44,7 +45,7 @@ list(APPEND VCPKG_DEFAULT_ENV_VARS_TO_CHECK PATH INCLUDE C_INCLUDE_PATH CPLUS_IN
list(REMOVE_DUPLICATES VCPKG_DEFAULT_ENV_VARS_TO_CHECK)
#Flags to check. Flags are a bit special since they are configuration aware.
set(FLAGS ${VCPKG_LANGUAGES} RC SHARED_LINKER STATIC_LINKER EXE_LINKER)
set(FLAGS ${VCPKG_LANGUAGES} RC SHARED_LINKER STATIC_LINKER EXE_LINKER MODULE_LINKER)
foreach(flag IN LISTS FLAGS)
list(APPEND VCPKG_DEFAULT_FLAGS_TO_CHECK CMAKE_${flag}_FLAGS)
endforeach()
@ -98,8 +99,9 @@ macro(_vcpkg_adjust_flags flag_var)
endif()
endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if("${flag_var}" IN_LIST VCPKG_LANG_FLAGS)
if(APPLE)
set(flags_to_add_osx_arch_sysroot "${VCPKG_LANG_FLAGS}" CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS)
if("${flag_var}" IN_LIST flags_to_add_osx_arch_sysroot)
# macOS - append arch and isysroot if cross-compiling
if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}")
foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES)
@ -108,10 +110,24 @@ macro(_vcpkg_adjust_flags flag_var)
endif()
string(APPEND ${flag_var} " -isysroot ${CMAKE_OSX_SYSROOT}")
if (CMAKE_OSX_DEPLOYMENT_TARGET)
string(APPEND ${flag_var} " -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
list(GET VCPKG_LANGUAGES 0 lang)
string(APPEND ${flag_var} " ${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}")
unset(lang)
endif()
endif()
unset(flags_to_add_osx_arch_sysroot)
endif()
set(flags_to_add_target "${VCPKG_LANG_FLAGS}" CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS)
list(GET VCPKG_LANGUAGES 0 lang)
if(CMAKE_${lang}_COMPILER_TARGET AND "${flag_var}" IN_LIST flags_to_add_target)
if (CMAKE_${lang}_COMPILER_ID STREQUAL Clang)
string(PREPEND ${flag_var} "${CMAKE_${lang}_COMPILE_OPTIONS_TARGET}${CMAKE_${lang}_COMPILER_TARGET} ")
elseif(CMAKE_${lang}_COMPILE_OPTIONS_TARGET)
string(PREPEND ${flag_var} "${CMAKE_${lang}_COMPILE_OPTIONS_TARGET} ${CMAKE_${lang}_COMPILER_TARGET} ")
endif()
endif()
unset(lang)
unset(flags_to_add_target)
endmacro()
foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK)
@ -129,7 +145,6 @@ foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK)
endforeach()
endforeach()
file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}")
# Programs:

View file

@ -7657,7 +7657,7 @@
"port-version": 0
},
"vcpkg-cmake": {
"baseline": "2022-09-13",
"baseline": "2022-09-26",
"port-version": 0
},
"vcpkg-cmake-config": {
@ -7665,8 +7665,8 @@
"port-version": 1
},
"vcpkg-cmake-get-vars": {
"baseline": "2022-05-10",
"port-version": 1
"baseline": "2022-09-04",
"port-version": 0
},
"vcpkg-get-python-packages": {
"baseline": "2022-06-30",

View file

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "898079c6021ced406d7c75f852e67a5e8861db9b",
"version-date": "2022-09-04",
"port-version": 0
},
{
"git-tree": "b50ca3d20736304215fbd82c102d4552457255bb",
"version-date": "2022-05-10",

View file

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "8827e6f24005c4f60cb0a579a3a0115ef3d7b6c3",
"version-date": "2022-09-26",
"port-version": 0
},
{
"git-tree": "72b6903c393330b7c9042096d84cbd733619644e",
"version-date": "2022-09-13",