From a43151eb994e783441f03ab2103038dbba19310c Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 24 Dec 2020 23:37:38 +0800 Subject: [PATCH] improve vs runtime --- .github/workflows/windows.yml | 5 +++-- packages/f/fmt/xmake.lua | 12 +++++++++++- scripts/test.lua | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ccb4fe8aa..50556d77e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -11,6 +11,7 @@ jobs: os: [windows-latest] kind: [static, shared] arch: [x64, x86] + vs_runtime: [MT, MD] runs-on: ${{ matrix.os }} @@ -18,9 +19,9 @@ jobs: - uses: actions/checkout@v1 - uses: xmake-io/github-action-setup-xmake@v1 with: - xmake-version: branch@dev + xmake-version: branch@cache - name: Tests run: | - xmake l ./scripts/test.lua -D -a ${{ matrix.arch }} -k ${{ matrix.kind }} --vs_sdkver=10.0.19041.0 + xmake l ./scripts/test.lua -D -a ${{ matrix.arch }} -k ${{ matrix.kind }} --vs_runtime=${{ matrix.vs_runtime }} --vs_sdkver=10.0.19041.0 diff --git a/packages/f/fmt/xmake.lua b/packages/f/fmt/xmake.lua index 3d7e96a16..b95f14697 100644 --- a/packages/f/fmt/xmake.lua +++ b/packages/f/fmt/xmake.lua @@ -30,7 +30,17 @@ package("fmt") io.gsub("CMakeLists.txt", "MASTER_PROJECT AND CMAKE_GENERATOR MATCHES \"Visual Studio\"", "0") local configs = {"-DFMT_TEST=OFF", "-DFMT_DOC=OFF", "-DFMT_FUZZ=OFF"} if package:is_plat("windows") then - table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" .. (package:debug() and "Debug" or "") .. (package:config("vs_runtime"):startswith("MT") and "" or "DLL")) + -- TODO we will remove it after xmake/2.5.1 + local vs_runtime = package:config("vs_runtime") + if vs_runtime == "MT" then + table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded") + elseif vs_runtime == "MTd" then + table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug") + elseif vs_runtime == "MD" then + table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL") + elseif vs_runtime == "MDd" then + table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL") + end end table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) diff --git a/scripts/test.lua b/scripts/test.lua index 3252b81b1..804d9945c 100644 --- a/scripts/test.lua +++ b/scripts/test.lua @@ -19,6 +19,7 @@ local options = , {nil, "ndk", "kv", nil, "Set the android NDK directory." } , {nil, "sdk", "kv", nil, "Set the SDK directory of cross toolchain." } , {nil, "vs_sdkver", "kv", nil, "Set the Windows SDK version." } +, {nil, "vs_runtime", "kv", nil, "Set the VS Runtime library." } , {nil, "mingw", "kv", nil, "Set the MingW directory." } , {nil, "toolchain", "kv", nil, "Set the toolchain name." } , {nil, "packages", "vs", nil, "The package list." } @@ -52,6 +53,9 @@ function _require_packages(argv, packages) if argv.vs_sdkver then table.insert(config_argv, "--vs_sdkver=" .. argv.vs_sdkver) end + if argv.vs_runtime then + table.insert(config_argv, "--vs_runtime=" .. argv.vs_runtime) + end if argv.mingw then table.insert(config_argv, "--mingw=" .. argv.mingw) end