diff --git a/getucrtinfo.bat b/getucrtinfo.bat new file mode 100644 index 0000000..35911fa --- /dev/null +++ b/getucrtinfo.bat @@ -0,0 +1,4 @@ +@echo off +call "%VS140COMNTOOLS%vcvarsqueryregistry.bat" +echo %UniversalCRTSdkDir% +echo %UCRTVersion% diff --git a/shared_msvc.gradle b/shared_msvc.gradle index 04017fb..56821d9 100644 --- a/shared_msvc.gradle +++ b/shared_msvc.gradle @@ -119,5 +119,22 @@ rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind -> } } + // Detect and setup UCRT paths + def ucrtInfo = "getucrtinfo.bat".execute().text + def m = ucrtInfo =~ /^(.*)\r\n(.*)?$/ + if (!m.find()) { + return cfg + } + def kitPath = m.group(1) + def ucrtVersion = m.group(2) + def ucrtCheckFile = new File("${kitPath}Include/${ucrtVersion}/ucrt/stdio.h"); + if (!ucrtCheckFile.exists()) { + return cfg + } + + cfg.compilerOptions.args "/FS", "/I${kitPath}Include/${ucrtVersion}/ucrt"; + cfg.linkerOptions.args("/LIBPATH:${kitPath}Lib/${ucrtVersion}/ucrt/x86"); + return cfg } +