Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add object target kind to separate source files and compile flags #263

Closed
waruqi opened this issue Nov 20, 2018 · 1 comment
Closed

Add object target kind to separate source files and compile flags #263

waruqi opened this issue Nov 20, 2018 · 1 comment
Milestone

Comments

@waruqi
Copy link
Member

waruqi commented Nov 20, 2018

Separate compile flags

Only src/sub/*.c will be added -DBBB and -Ixxx flags.

target("demo")
    set_kind("binary")
    add_files("src/*.c")
    add_defines("AAA")
    add_deps("subfiles_with_other_flags")

target("subfiles_with_other_flags")
    set_kind("object")
    add_files("sub/*.c")
    add_defines("BBB")
    add_cxflags("-Ixxx")

Separate source files and generate the single target in different xmake.lua

./xmake.lua

target("demo")
    set_kind("binary")
    add_files("src/*.c")
    add_deps("subfiles")

./src/xmake.lua

target("subfiles")
    set_kind("object")
    add_files("sub/*.c")
@waruqi waruqi added this to the v2.2.3 milestone Nov 20, 2018
@waruqi
Copy link
Member Author

waruqi commented Nov 20, 2018

用于隔离不同源文件之间的flags等编译配置参数

虽然add_files("src/*.c", {cxflags = ""})这种方式也可以细粒度控制,但是不够灵活。通过object对象分离编译源码块,可以单独设置各种不同编译参数,也可以在根target上共享通用设置

用于在子目录独立xmake.lua文件中添加局部源文件来编译

不用生成独立静态库链接,最后会把所有对象文件合并直接生成最终target,虽然也可以通过target("xxx")重入的方式添加子源文件,但是这种方式下,编译flags设置是完全共享的,没法独立开来。

@waruqi waruqi closed this as completed Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant