如何通过Premake在VS2019中为C/C++命令行添加/FS选项
How to Add the
/FS Compiler Option via Premake5 for Visual Studio 2019 Got it! To add the /FS compiler option (which maps directly to the Properties -> C/C++ -> Command Line -> Additional Options setting in Visual Studio 2019) to your project, you just need to add a buildoptions entry in your project configuration. It's best to wrap it in a filter to ensure it only applies to Visual Studio generators, so it doesn't interfere with other compilers like GCC or Clang.
Here's your modified premake.lua with the necessary change:
workspace "test_refactor_edit_control_01" platforms { "Win32", "64" } configurations { "Debug", "Release" } filter "platforms:Win32" architecture "x86" filter "platforms:64" architecture "x64" project "test_refactor_edit_control_01" location "test_refactor_edit_control_01" kind "WindowedApp" language "C++" staticruntime "Off" targetdir ("bin/" .. outputdir .. "/%{prj.name}") objdir ("bin-int/" .. outputdir .. "/%{prj.name}") -- Add /FS compiler option for Visual Studio only filter "action:vs*" buildoptions "/FS" -- Rest of your configuration goes here ...
Quick Explanation:
buildoptions "/FS"directly injects the/FSflag into the C/C++ command line additional options of your Visual Studio project, exactly like setting it manually in the IDE.- The
filter "action:vs*"ensures this setting only applies to any Visual Studio generator (including VS2019), keeping your configuration cross-compiler friendly. If your project is only targeting Visual Studio, you can skip the filter and just addbuildoptions "/FS"directly under the project block.
内容的提问来源于stack exchange,提问作者Ivan Ambic
相关产品推荐
相关产品推荐

