我使用 premake 作为构建系统,并且我有 Lua 脚本,但由于某种原因,当我打开 vs2022 并运行它时,有些事情没有做好。一些项目和项目有一个带有减号的红色圆圈。而且我的沙盒项目根本不在我的目录中。
我正在使用 premake5-beta beta2
这是我的lua脚本。
workspace "Almond"
architecture "x64"
configurations
{
"Debug",
"Release",
"Dist"
}
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
project "Almond"
location "Almond"
kind "SharedLib"
language "C++"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp"
}
filter "system:windows"
cppdialect "C++17"
staticruntime "On"
systemversion "latest"
defines
{
"AM_PLATFORM_WINDOWS",
"AM_BUILD_DLL"
}
postbuildcommands
{
("{COPY} %{cfg.buildtarget.relpath} ../bin/" .. outputdir .. "/Sandbox")
}
filter "configurations:Debug"
defines "AM_DEBUG"
symbols "On"
filter "configurations:Release"
defines "AM_RELEASE"
optimize "On"
filter "configurations:Dist"
defines "AM_DIST"
optimize "On"
project "Sanbox"
location "Sandbox"
kind "ConsoleApp"
language "C++"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp"
}
includedirs
{
"Almond/src"
}
links
{
"Almond"
}
filter "system:windows"
cppdialect "C++17"
staticruntime "On"
systemversion "latest"
defines
{
"AM_PLATFORM_WINDOWS"
}
filter "configurations:Debug"
defines "AM_DEBUG"
symbols "On"
filter "configurations:Release"
defines "AM_RELEASE"
optimize "On"
filter "configurations:Dist"
defines "AM_DIST"
optimize "On"
我以前从未使用过 premake,但我听说对于初学者来说它比 cmake 更简单。 “-thecherno”
您有 3 个问题:
'd'
)postbuildcommands
有 2 个问题:以下
postbuildcommands
应该可以解决问题:
postbuildcommands
{
"{MKDIR} %[bin/" .. outputdir .. "/Sandbox]",
"{COPYFILE} %[%{!cfg.buildtarget.abspath}] %[bin/" .. outputdir .. "/Sandbox]"
}
%[..]
就是正确制作相对于项目的路径(取绝对路径)%{!..}
是强制路径为绝对路径。