diff options
| author | ruki <[email protected]> | 2020-12-24 23:23:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-24 23:23:10 +0800 |
| commit | 621e3706b229c39cfe4c94bfa9417405cde883fb (patch) | |
| tree | b6fcac4ae1120ed64af8dcaff032cda6d73393bb | |
| parent | 70865b36f34647bda2bdd218b428bcca0cecc9da (diff) | |
fix vs_runtime values
| -rw-r--r-- | xmake/actions/require/impl/package.lua | 2 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 13 | ||||
| -rw-r--r-- | xmake/platforms/windows/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/utils/compiler_runtime/xmake.lua | 2 |
5 files changed, 16 insertions, 8 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua index ccb12ac7a..2d63775ce 100644 --- a/xmake/actions/require/impl/package.lua +++ b/xmake/actions/require/impl/package.lua @@ -243,7 +243,7 @@ function _add_package_configurations(package) package:add("configs", "cxflags", {builtin = true, description = "Set the C/C++ compiler flags."}) package:add("configs", "cxxflags", {builtin = true, description = "Set the C++ compiler flags."}) package:add("configs", "asflags", {builtin = true, description = "Set the assembler flags."}) - package:add("configs", "vs_runtime", {builtin = true, description = "Set vs compiler runtime.", default = get_config("vs_runtime") or "MT", values = {"MT", "MD"}}) + package:add("configs", "vs_runtime", {builtin = true, description = "Set vs compiler runtime.", default = get_config("vs_runtime") or "MT", values = {"MT", "MTd", "MD", "MDd"}}) end -- select package version diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 6aaeb2f08..52c9a0c7c 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1099,10 +1099,9 @@ function _instance:_generate_build_configs(configs) local ld = self:build_getenv("ld") local vs_runtime = self:config("vs_runtime") if vs_runtime and ld and path.basename(ld:lower()) == "link" then -- for msvc? - local vs_runtime_cxflags = "/" .. vs_runtime .. (self:debug() and "d" or "") configs.cxflags = table.wrap(configs.cxflags) - table.insert(configs.cxflags, vs_runtime_cxflags) - if vs_runtime == "MT" then + table.insert(configs.cxflags, "/" .. vs_runtime) + if vs_runtime:startswith("MT") then configs.ldflags = table.wrap(configs.ldflags) table.insert(configs.ldflags, "-nodefaultlib:msvcrt.lib") end diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 3835e0d3b..a126fe514 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -197,10 +197,19 @@ function _get_configs_for_windows(package, configs, opt) end end 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 if vs_runtime then - table.insert(configs, '-DCMAKE_CXX_FLAGS_DEBUG="/' .. vs_runtime .. 'd"') + table.insert(configs, '-DCMAKE_CXX_FLAGS_DEBUG="/' .. vs_runtime .. '"') table.insert(configs, '-DCMAKE_CXX_FLAGS_RELEASE="/' .. vs_runtime .. '"') - table.insert(configs, '-DCMAKE_C_FLAGS_DEBUG="/' .. vs_runtime .. 'd"') + table.insert(configs, '-DCMAKE_C_FLAGS_DEBUG="/' .. vs_runtime .. '"') table.insert(configs, '-DCMAKE_C_FLAGS_RELEASE="/' .. vs_runtime .. '"') end _get_configs_for_generic(package, configs, opt) diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index 5a2169e29..589522730 100644 --- a/xmake/platforms/windows/xmake.lua +++ b/xmake/platforms/windows/xmake.lua @@ -52,7 +52,7 @@ platform("windows") , {nil, "vs_sdkver", "kv", nil, "The Windows SDK Version of Visual Studio" , " e.g. --vs_sdkver=10.0.15063.0" } , {nil, "vs_runtime", "kv", nil, "The Runtime library of Visual Studio" - , values = {"MT", "MD"} } + , values = {"MT", "MTd", "MD", "MDd"} } , {category = "Cuda SDK Configuration" } , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } diff --git a/xmake/rules/utils/compiler_runtime/xmake.lua b/xmake/rules/utils/compiler_runtime/xmake.lua index a9ca1ac49..a00ef170e 100644 --- a/xmake/rules/utils/compiler_runtime/xmake.lua +++ b/xmake/rules/utils/compiler_runtime/xmake.lua @@ -25,7 +25,7 @@ rule("utils.compiler.runtime") -- set vs runtime local vs_runtime = get_config("vs_runtime") if vs_runtime and target:is_plat("windows") and not target:get("runtimes") then - target:set("runtimes", vs_runtime .. (is_mode("debug") and "d" or "")) + target:set("runtimes", vs_runtime) end end) |
