Closed wagshiwei closed 4 months ago
Bot detected the issue body's language is not English, translate it automatically.
Title: Definition of batch processing target
Multiple targets require unified definition of different processes.
target("hello1")
set_kind("binary")
add_files("*.cpp","*.c")
target("hello2")
set_kind("binary")
add_files("*.cpp","*.c")
-- on_load
on_config(function (target)
import("core.project.task")
task.run("test")
end)
task("test")
on_run(function ()
import("core.project.project")
import("core.base.option")
for _, target0 in pairs(project.targets()) do
local targetname = target0:name()
print("target name:" .. targetname)
target0:add_defines("module_"..targetname) ----error report
end
end)
No response
No response
rule("module")
on_load(function (target)
target:set("kind", "static")
target:add("defines", target:name())
end)
rule_end()
add_rules("module")
target("a")
add_files("a.cpp")
target("b")
add_files("b.cpp")
我用的xcode,xcode是不是不支持生成workspace,只能生成单个target的proj文件,但是单个项目文件里也没有增加新的宏定义。CMakeLists.txt文件里也没有统一添加的宏定义
Bot detected the issue body's language is not English, translate it automatically.
The xcode I use does not support generating workspace. It can only generate a proj file for a single target, but no new macro definitions are added to a single project file. There is no uniformly added macro definition in the CMakeLists.txt file.
似乎是缓存问题,需要删掉CMakeLists.txt才会重新生成
Bot detected the issue body's language is not English, translate it automatically.
It seems to be a cache problem. You need to delete CMakeLists.txt before it can be regenerated.
add_files("*.cpp","*.c") ----为什么不能添加 h 文件
添加安装头文件用 add_headerfiles ,添加搜索路径用 add_includedirs 。。为什么要加到 add_files ,那里面要参与编译生成 obj 的。。.h 不会编译到 obj
另外 test 是内置 task xmake test
,不要去改写,换个名。
Bot detected the issue body's language is not English, translate it automatically.
add_files(".cpp",".c") ----Why can't I add h files?
Use add_headerfiles to add installation header files and add_includedirs to add search paths. . Why should it be added to add_files, which needs to be involved in compilation and generation of obj. . .h will not compile to obj
你在什么场景下需要该功能?
多target需要统一定义不同的处理
描述可能的解决方案