From 33fbf4c97a6d393af467f35f364572a06f1493d3 Mon Sep 17 00:00:00 2001 From: MarcasRealAccount Date: Wed, 7 Dec 2022 18:41:29 +0100 Subject: [PATCH] Add MSVC runtime library support --- cmake_project.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmake_project.lua b/cmake_project.lua index 2974342..eb00d43 100644 --- a/cmake_project.lua +++ b/cmake_project.lua @@ -25,6 +25,17 @@ m.nonldflags = { } } +m.msvcRuntimeLibraries = { + On = { + Debug = "MultiThreadedDebug", + Release = "MultiThreaded" + }, + Off = { + Debug = "MultiThreadedDebugDLL", + Release = "MultiThreadedDLL" + } +} + function cmake.generateProject(prj) prj.__cmake = {} prj.__cmake.files = {} @@ -123,6 +134,7 @@ m.configProps = function(prj, cfg) m.outputDirs, m.includeDirs, m.defines, + m.msvcRuntimeLibrary, m.libDirs, m.libs, m.buildOptions, @@ -237,6 +249,18 @@ function m.defines(prj, cfg) timer.stop() end +function m.msvcRuntimeLibrary(prj, cfg) + local timer = cmake.common.createTimer("p.extensions.cmake.project.runtimeLibrary", { prj.name, cmake.common.configName(cfg, #prj.workspace.platforms > 1) }) + local static = m.msvcRuntimeLibraries[cfg.staticruntime] + if static then + local runtime = static[cfg.runtime] + if runtime then + p.w("set_property(TARGET \"%s\" PROPERTY MSVC_RUNTIME_LIBRARY \"%s\")", prj.name, runtime) + end + end + timer.stop() +end + function m.libDirs(prj, cfg) local timer = cmake.common.createTimer("p.extensions.cmake.project.libDirs", { prj.name, cmake.common.configName(cfg, #prj.workspace.platforms > 1) }) if #cfg.libdirs > 0 then