diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index c5b2e59127e6eb..b7b623f1a89a24 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -354,7 +354,7 @@ function(vcpkg_configure_make) endif() endif() endforeach() - if (_csc_AUTOCONFIG OR _csc_USE_WRAPPERS) # without autotools we assume a custom configure script which correctly handles cl and lib. Otherwise the port needs to set CC|CXX|AR and probably CPP + if ((_csc_AUTOCONFIG OR _csc_USE_WRAPPERS) AND (NOT VCPKG_TARGET_IS_MINGW)) # without autotools we assume a custom configure script which correctly handles cl and lib. Otherwise the port needs to set CC|CXX|AR and probably CPP _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E") _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}") @@ -372,6 +372,10 @@ function(vcpkg_configure_make) _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "${VCPKG_DETECTED_CMAKE_C_COMPILER}") _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER}") _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") + if(VCPKG_TARGET_IS_MINGW AND (_csc_AUTOCONFIG OR _csc_USE_WRAPPERS)) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV RC "${VCPKG_DETECTED_CMAKE_RC_COMPILER}") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV WINDRES "${VCPKG_DETECTED_CMAKE_RC_COMPILER}") + endif() if(VCPKG_DETECTED_CMAKE_AR) _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${VCPKG_DETECTED_CMAKE_AR}") else() @@ -384,8 +388,14 @@ function(vcpkg_configure_make) else() _vcpkg_append_to_configure_environment(CONFIGURE_ENV RANLIB ":") endif() - if(VCPKG_DETECTED_CMAKE_OBJDUMP) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all + if(VCPKG_DETECTED_CMAKE_OBJDUMP AND NOT VCPKG_TARGET_IS_MINGW) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all _vcpkg_append_to_configure_environment(CONFIGURE_ENV OBJDUMP "${VCPKG_DETECTED_CMAKE_OBJDUMP}") # Trick to ignore the RANLIB call + elseif(VCPKG_TARGET_IS_MINGW) + # ensure the objdump from the vcpkg-acquired msys is used, or mingw / msys "clang" environments may fail + find_program(MSYSROOT_OBJDUMP "objdump" HINTS "${MSYS_ROOT}/usr/bin" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH) + if (MSYSROOT_OBJDUMP) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV OBJDUMP "${MSYSROOT_OBJDUMP}") + endif() endif() if(VCPKG_DETECTED_CMAKE_STRIP) # If required set the ENV variable STRIP in the portfile correctly _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP "${VCPKG_DETECTED_CMAKE_STRIP}") @@ -394,7 +404,15 @@ function(vcpkg_configure_make) list(APPEND _csc_OPTIONS ac_cv_prog_ac_ct_STRIP=:) endif() if(VCPKG_DETECTED_CMAKE_NM) # If required set the ENV variable NM in the portfile correctly - _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "${VCPKG_DETECTED_CMAKE_NM}") + if (NOT VCPKG_TARGET_IS_MINGW) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "${VCPKG_DETECTED_CMAKE_NM}") + else() + # ensure the nm from the vcpkg-acquired msys is used + find_program(MSYSROOT_NM "nm" HINTS "${MSYS_ROOT}/usr/bin" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH) + if (MSYSROOT_NM) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "${MSYSROOT_NM}") + endif() + endif() else() # Would be better to have a true nm here! Some symbols (mainly exported variables) get not properly imported with dumpbin as nm # and require __declspec(dllimport) for some reason (same problem CMake has with WINDOWS_EXPORT_ALL_SYMBOLS) @@ -557,6 +575,9 @@ function(vcpkg_configure_make) # Note: Env LIBPATH;LIB are on the search path for libtool by default on windows. # It even does unix/dos-short/unix transformation with the path to get rid of spaces. endif() + if (VCPKG_TARGET_IS_MINGW) + list(REMOVE_ITEM ALL_LIBS_LIST "-luuid") + endif() set(_lprefix) if(_VCPKG_TRANSFORM_LIBS) set(_lprefix "-l")