Templated targets
#5206
-
Suppose you have several build targets that are completely identical in terms of multiple compiled files and linked libraries, but differ minorly in, for example, the value of one macro. Example:
Is there any way to make a template build target to reduce the amount of identical code? |
Beta Was this translation helpful? Give feedback.
Answered by
waruqi
Jun 10, 2024
Replies: 1 comment
-
use function to wrap it. function mytarget(name)
target(name)
set_kind("binary")
add_files("vector.cpp")
add_files("set.cpp")
add_files("main.cpp")
add_links({"custom_library", "another_custom_library"})
end
mytarget("target-milk")
add_defines("MILK")
mytarget("target-cheese")
add_defines("CHEESE") or define rule and use |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jj683
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use function to wrap it.
or define rule and use
add_rules("xxx")
for each targets