From 4259988646af075ba542cbf364e4199086483b09 Mon Sep 17 00:00:00 2001 From: Joel Linn Date: Wed, 15 Sep 2021 12:15:02 +0200 Subject: [PATCH] Set per file build options --- cmake_project.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cmake_project.lua b/cmake_project.lua index 5a3c2ac..6c52dfe 100755 --- a/cmake_project.lua +++ b/cmake_project.lua @@ -158,7 +158,26 @@ function m.generate(prj) _p(2, '$<$:%s>', flag) end _p(1, ')') - _p(')') + + -- setting per fille build options + table.foreachi(prj._.files, function(node) + local fcfg = p.fileconfig.getconfig(node, cfg) + if fcfg then + toolset_flags = {} + if path.iscfile(fcfg.name) then + toolset_flags = toolset.getcflags(fcfg) + elseif path.iscppfile(fcfg.name) then + toolset_flags = toolset.getcppflags(fcfg) + end + file_build_options = table.concat(table.join(toolset_flags, fcfg.buildoptions), " ") + if file_build_options ~= "" then + _p(1, + 'set_source_files_properties("%s" PROPERTIES COMPILE_FLAGS "%s")', + path.getrelative(prj.workspace.location, fcfg.abspath), + file_build_options) + end + end + end) -- C++ standard -- only need to configure it specified