Closed Latias94 closed 6 months ago
workaround
add_rules("mode.debug", "mode.release")
set_languages("c++23")
set_runtimes("MTd")
set_optimize("none")
add_requires("glslang")
-- add_requires("vulkansdk")
target("main")
set_kind("binary")
add_files("src/*.cpp")
add_deps("shader_compiler")
set_rundir("$(projectdir)")
-- add_packages("vulkansdk")
add_links(path.unix([[C:\Users\star\scoop\apps\vulkan\current\lib\vulkan-1.lib]]))
target("shader_compiler")
set_kind("static")
add_files("src/shader_compiler.cpp")
add_files("$(projectdir)/vendor/glslang/**.cpp")
add_packages("glslang", {public = true})
$ xmake -r
[ 30%]: compiling.release src\shader_compiler.cpp
[ 40%]: compiling.release vendor\glslang\ResourceLimits.cpp
[ 50%]: compiling.release src\main.cpp
[ 60%]: compiling.release src\shader_compiler.cpp
[ 70%]: archiving.release shader_compiler.lib
[ 90%]: linking.release main.exe
[100%]: build ok, spent 1.375s
package rule?
rule("vulkansdk")
on_config(function (target)
import("lib.detect.find_library")
import("detect.sdks.find_vulkansdk")
local vulkansdk = find_vulkansdk()
if vulkansdk then
target:add("runevs", "PATH", vulkansdk.bindir)
target:add("includedirs", vulkansdk.includedirs)
local utils = {}
table.insert(utils, target:is_plat("windows") and "vulkan-1" or "vulkan")
for _, util in ipairs(utils) do
if not find_library(util, vulkansdk.linkdirs) then
wprint(format("The library %s for %s is not found!", util, target:arch()))
return
end
target:add("links", path.join(vulkansdk.linkdirs[1], util .. (target:is_plat("windows") and ".lib" or ".so")))
end
end
end)
Thanks, I build success with minor modified rule target:add("links", ..., {public = true})
.
I am looking forward to an official solution in the xmake-repo. For now, I will use this workaround.
Xmake Version
v2.9.1+HEAD.0c79f6162,
Operating System Version and Architecture
Windows 11
Describe Bug
This is a follow-up issue to Shaderc install failed with MDd. I'm experiencing a compilation error when using glslang together with libsdl (vulkan=true) and a non-MD vs runtime.
Minimal Reproduction Project:
test_glslang.zip
The issue seems related to the point raised by @star-hengxing in this comment.
@SirLynix, could you help look into this?
Expected Behavior
compile success
Project Configuration
Additional Information and Error Logs