Specifying options for dependencies #6127
Answered
by
waruqi
davidchisnall
asked this question in
Q&A
-
In a few cases, we’ve wanted to be able to specify that a target depends on another target and that the dependency must be built with a specific option. At the moment, we just end up documenting increasingly long Is there something I can use in a target to change the default for an option? Can I set it in |
Beta Was this translation helpful? Give feedback.
Answered by
waruqi
May 4, 2025
Replies: 1 comment 17 replies
-
option("foo", {description = "add foo dep", default = false})
target("foo")
set_default(false)
set_kind("static")
add_files("src/*.cpp")
target("test")
set_kind("binary")
add_files("src/*.cpp")
if has_config("foo") then
add_deps("foo")
end |
Beta Was this translation helpful? Give feedback.
17 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I still don't quite understand your question and requirements, but if my previous understanding is correct, it is not a good practice to modify the configuration in the dependent target by the parent target.
Of course, if you really want to do this, you can do everything in the script scope, there is no need to use option, it is global.