diff --git a/scripts/cmake/vcpkg_configure_meson.cmake b/scripts/cmake/vcpkg_configure_meson.cmake index 5bb34089c1..499d488252 100644 --- a/scripts/cmake/vcpkg_configure_meson.cmake +++ b/scripts/cmake/vcpkg_configure_meson.cmake @@ -54,13 +54,20 @@ function(vcpkg_internal_meson_generate_native_file _additional_binaries) #https: foreach(prog IN LISTS compiler) if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER) string(REPLACE "CXX" "CPP" mesonprog "${prog}") + string(REPLACE "RC" "windres" mesonprog "${mesonprog}") # https://mesonbuild.com/Windows-module.html 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") + if (NOT VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel)$") # for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456 + string(APPEND NATIVE "c_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") + endif() + endif() + if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS) + if (NOT VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Intel)$") # for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456 + string(APPEND NATIVE "cpp_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") + endif() endif() string(APPEND NATIVE "cmake = '${CMAKE_COMMAND}'\n") foreach(_binary IN LISTS ${_additional_binaries}) @@ -79,12 +86,14 @@ function(vcpkg_internal_meson_generate_native_file _additional_binaries) #https: 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(REMOVE_ITEM WIN_C_STANDARD_LIBRARIES "''") 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(REMOVE_ITEM WIN_CXX_STANDARD_LIBRARIES "''") list(JOIN WIN_CXX_STANDARD_LIBRARIES ", " WIN_CXX_STANDARD_LIBRARIES) string(APPEND NATIVE "cpp_winlibs = [${WIN_CXX_STANDARD_LIBRARIES}]\n") endif() @@ -121,11 +130,11 @@ function(vcpkg_internal_meson_generate_flags_properties_string _out_var _config) set(PATH_SUFFIX_DEBUG /debug) set(LIBPATH_${_config} "${L_FLAG}${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_config}}/lib") vcpkg_internal_meson_convert_compiler_flags_to_list(MESON_CFLAGS_${_config} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_config}}") - list(APPEND MESON_CFLAGS_${_config} "-I\"${CURRENT_INSTALLED_DIR}/include\"") + list(APPEND MESON_CFLAGS_${_config} "-I${CURRENT_INSTALLED_DIR}/include") vcpkg_internal_meson_convert_list_to_python_array(MESON_CFLAGS_${_config} ${MESON_CFLAGS_${_config}}) string(APPEND ${_out_var} "c_args = ${MESON_CFLAGS_${_config}}\n") vcpkg_internal_meson_convert_compiler_flags_to_list(MESON_CXXFLAGS_${_config} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_config}}") - list(APPEND MESON_CXXFLAGS_${_config} "-I\"${CURRENT_INSTALLED_DIR}/include\"") + list(APPEND MESON_CXXFLAGS_${_config} "-I${CURRENT_INSTALLED_DIR}/include") vcpkg_internal_meson_convert_list_to_python_array(MESON_CXXFLAGS_${_config} ${MESON_CXXFLAGS_${_config}}) string(APPEND ${_out_var} "cpp_args = ${MESON_CXXFLAGS_${_config}}\n") if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") @@ -277,13 +286,20 @@ function(vcpkg_internal_meson_generate_cross_file _additional_binaries) #https:/ foreach(prog IN LISTS compiler) if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER) string(REPLACE "CXX" "CPP" mesonprog "${prog}") + string(REPLACE "RC" "windres" mesonprog "${mesonprog}") # https://mesonbuild.com/Windows-module.html 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") + if (NOT VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel)$") # for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456 + string(APPEND CROSS "c_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") + endif() + endif() + if(VCPKG_DETECTED_CMAKE_LINKER AND VCPKG_TARGET_IS_WINDOWS) + if (NOT VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Intel)$") # for gcc and icc the linker flag -fuse-ld is used. See https://github.com/mesonbuild/meson/issues/8647#issuecomment-878673456 + string(APPEND CROSS "cpp_ld = '${VCPKG_DETECTED_CMAKE_LINKER}'\n") + endif() endif() foreach(_binary IN LISTS ${_additional_binaries}) string(APPEND CROSS "${_binary}\n") @@ -293,7 +309,7 @@ function(vcpkg_internal_meson_generate_cross_file _additional_binaries) #https:/ string(APPEND CROSS "[host_machine]\n") string(APPEND CROSS "endian = 'little'\n") - if(NOT VCPKG_CMAKE_SYSTEM_NAME) + if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_TARGET_IS_MINGW) set(MESON_SYSTEM_NAME "windows") else() string(TOLOWER "${VCPKG_CMAKE_SYSTEM_NAME}" MESON_SYSTEM_NAME) @@ -319,7 +335,7 @@ function(vcpkg_internal_meson_generate_cross_file _additional_binaries) #https:/ string(APPEND CROSS "cpu = '${BUILD_CPU}'\n") 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) + 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(_file "${CURRENT_BUILDTREES_DIR}/meson-cross-${TARGET_TRIPLET}.log") set(VCPKG_MESON_CROSS_FILE "${_file}" PARENT_SCOPE) file(WRITE "${_file}" "${CROSS}") diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index 1b2e1e561f..b6d5f0e415 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -20,7 +20,7 @@ foreach(prog IN LISTS PROGLIST) endforeach() set(COMPILERS ${VCPKG_LANGUAGES} RC) foreach(prog IN LISTS COMPILERS) - list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER CMAKE_${prog}_COMPILER_ID) endforeach() # Variables to check foreach(_lang IN LISTS VCPKG_LANGUAGES)