mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-14 07:02:19 +08:00
[vcpkg] Meson osx sysroot (#21772)
* [get_cmake_vars] add -isysroot flag independednt of crosscompiling Even without crosscompiling it is possible to specify a VCPKG_OSX_SYSROOT or a SDKROOT this should be popagated to autotools and meson builds as well. * [meson] add -arch and -isysroot to linker flags in case of osx crosscompile * [meson] avoid DEPRECATION warning about flags in the [properties] section * [meson] don't set OSXROOT evironment varibale * [meson] don't set MACOSX_DEPLOYMENT_TARGET environment variable cmake appends the -mmacosx-version-min flag c/cxx flags, overriding the value set via VCPKG_C_FLAGS. By setting the environment variable, the VCPKG_C_FLAGS value was used for meson builds. Now the same value is taken for both. * [meson/make] Add CMAKE_OSX_DEPLOYMENT_TARGET to VCPKG_DETECTED_CMAKE_C_FLAGS This is done in the same way in CMake internally
This commit is contained in:
parent
3f3efccadd
commit
a34997af6c
@ -179,6 +179,17 @@ function(z_vcpkg_meson_generate_flags_properties_string out_var config_type)
|
||||
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")
|
||||
@ -188,8 +199,6 @@ 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
|
||||
z_vcpkg_meson_generate_flags_properties_string(native_properties "${config_type}")
|
||||
string(APPEND native_file "${native_properties}")
|
||||
#Setup CMake properties
|
||||
string(APPEND native_file "cmake_toolchain_file = '${SCRIPTS}/buildsystems/vcpkg.cmake'\n")
|
||||
string(APPEND native_file "[cmake]\n")
|
||||
@ -219,6 +228,8 @@ function(z_vcpkg_meson_generate_native_file_config config_type) #https://mesonbu
|
||||
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)
|
||||
@ -348,9 +359,9 @@ 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}")
|
||||
string(APPEND cross_${config_type}_log "[built-in options]\n")
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
if(VCPKG_CRT_LINKAGE STREQUAL "static")
|
||||
set(crt_type mt)
|
||||
@ -464,16 +475,6 @@ function(vcpkg_configure_meson)
|
||||
set(suffix_${buildname} "rel")
|
||||
endif()
|
||||
|
||||
if(VCPKG_TARGET_IS_OSX)
|
||||
vcpkg_backup_env_variables(VARS SDKROOT MACOSX_DEPLOYMENT_TARGET)
|
||||
|
||||
set(ENV{SDKROOT} "${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}")
|
||||
set(VCPKG_DETECTED_CMAKE_OSX_SYSROOT "${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}" PARENT_SCOPE)
|
||||
|
||||
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()
|
||||
|
||||
vcpkg_backup_env_variables(VARS INCLUDE)
|
||||
vcpkg_host_path_list(APPEND ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include")
|
||||
# configure build
|
||||
@ -512,8 +513,5 @@ function(vcpkg_configure_meson)
|
||||
vcpkg_restore_env_variables(VARS PKG_CONFIG PKG_CONFIG_PATH)
|
||||
endforeach()
|
||||
|
||||
if(VCPKG_TARGET_IS_OSX)
|
||||
vcpkg_restore_env_variables(VARS SDKROOT MACOSX_DEPLOYMENT_TARGET)
|
||||
endif()
|
||||
vcpkg_restore_env_variables(VARS INCLUDE)
|
||||
endfunction()
|
||||
|
@ -101,7 +101,10 @@ macro(_vcpkg_adjust_flags flag_var)
|
||||
foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES)
|
||||
string(APPEND ${flag_var} " -arch ${arch}")
|
||||
endforeach()
|
||||
string(APPEND ${flag_var} " -isysroot ${CMAKE_OSX_SYSROOT}")
|
||||
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}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user