Skip to content

希望 [targets.<name>] 支持 cxxflags 按目标覆盖 #131

Description

@skyler-zbt

[build].cxxflags 对所有 target 一视同仁。实际项目中不同 target 经常需要不同编译参数。

场景 1:contracts 求值语义

# 所有 target 默认 enforce,test_contracts 需要 observe
[targets.test_contracts]
kind = "bin"
main = "tests/test_contracts.cpp"
cxxflags = ["-fcontract-evaluation-semantic=observe"]

场景 2:不同 feature 宏

[targets.server]
kind = "bin"
main = "src/server.cpp"
cxxflags = ["-DBUILD_SERVER=1", "-DPORT=8080"]

[targets.client]
kind = "bin"
main = "src/client.cpp"
cxxflags = ["-DBUILD_CLIENT=1"]

现状: 只能把标志放全局 [build].cxxflags,所有 target 共用。
** 同级构建系统都有此功能——xmake target:add("cxflags")、CMake target_compile_options、Cargo [profile.*.package.*]、Meson executable(..., cpp_args:)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions