(这是使用 Premake5 alpha 二进制文件,可在网站上下载)
我正在尝试将我现有的 VS 解决方案移植到使用 premake5。
它使用 MS 风格的预编译头文件(stdafx.h/stdafx.cpp)。
当我指定这是我的测试项目时:
pchheader "stdafx.h"
pchsource "stdafx.cpp"
它确实将项目设置为使用预编译头文件,但没有设置 stdafx.cpp 以生成预编译头文件(/Yc)。相反,项目中的所有文件都在尝试使用(/Yu)并且没有人生成 PCH。所以它没有建立..
我猜这确实有效,我在这里缺少什么黑魔法?
这是我的整个 premake5 文件供参考
-- premake5.lua
solution "Cloud"
configurations { "Debug", "Release", "Final" }
platforms { "Win32_AVX2", "Win64_AVX2"}
location "premake"
flags{"MultiProcessorCompile", "ExtraWarnings", "FatalCompileWarnings", "FatalLinkWarnings", "FloatFast"}
startproject "Cloud"
vectorextensions "AVX2"
filter { "platforms:Win32" }
system "Windows"
architecture "x32"
filter { "platforms:Win64" }
system "Windows"
architecture "x64"
filter "configurations:Debug"
defines { "DEBUG" }
flags { "Symbols" }
filter "configurations:Release"
defines { "NDEBUG" }
flags{"Symbols"}
optimize "Speed"
filter "configurations:Final"
defines { "NDEBUG" }
flags{"LinkTimeOptimization"}
optimize "Speed"
group "app"
--primary executable
project "Cloud"
location "../src_test/cloud"
kind "ConsoleApp"
language "C++"
targetdir "..//%{cfg.buildcfg}"
pchheader "stdafx.h"
pchsource "stdafx.cpp"
vpaths{
{["src/pch/*"] = "../src_test/cloud/stdafx.*"},
{["src/*"] = "../src_test/cloud/**.cpp"},
{["module/*"] = "../src_test/cloud/Module*.h"},
{["core/*"] = "../src_test/cloud/Core*.h"},
{["headers*"] = "../src_test/cloud/*.h"},
--{["src_c/*"] = "../src_test/cloud/**.c"}
}
files { "../src_test/cloud/*.h", "../src_test/cloud/*.c", "../src_test/cloud/*.cpp", "../src_test/cloud/*.hpp" }
一个相关问题:如何禁用项目中特定文件的预编译标头使用?如果包含 PCH,我的某些文件将无法构建,因此我已在现有解决方案/项目中手动禁用它们。
谢谢!