-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CMake] Passthrough variables for packages to subbuilds #107611
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
Conversation
These packaged are imported by LLVMConfig.cmake and so we should be passing through the necessary variables from the parent build into the subbuilds. We use `CMAKE_CACHE_DEFAULT_ARGS` so subbuilds can override these variables if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you happen to know which order CMake passes in the -C
arg for CMAKE_CACHE_DEFAULT_ARGS
vs. the arguments inside CMAKE_ARGS
? If the -C
goes before CMAKE_ARGS
(which I suspect), there's a potential interaction with https://reviews.llvm.org/D158791; if you want to use that mechanism to override any of these variables, you'll have to specify FORCE
. That's fine, just something that came to mind.
get_property(is_value_set CACHE ${variable} PROPERTY VALUE SET) | ||
if(${is_value_set}) | ||
get_property(value CACHE ${variable} PROPERTY VALUE) | ||
list(APPEND CMAKE_CACHE_DEFAULT_ARGS "-D${variable}:STRING=${value}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not need to replace ;
with |
to have list variables be passed through correctly? The documentation isn't clear on whether LIST_SEPARATOR
applies to CMAKE_CACHE_DEFAULT_ARGS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I read as well but I wasn't sure if it's needed or not so I tested and it looks like it's not required.
The following example:
ExternalProject_Add(test
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test
CMAKE_ARGS -Done=a|b|c
CMAKE_CACHE_ARGS -Dtwo:STRING=a;b;c
CMAKE_CACHE_DEFAULT_ARGS -Dthree:STRING=a|b|c
LIST_SEPARATOR |
)
produces the following cache file:
set(two "a;b;c" CACHE STRING "Initial cache" FORCE)
set(three "a;b;c" CACHE STRING "Initial cache" )
It looks like the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that sounds like a good direction then.
These packaged are imported by LLVMConfig.cmake and so we should be passing through the necessary variables from the parent build into the subbuilds.
We use
CMAKE_CACHE_DEFAULT_ARGS
so subbuilds can override these variables if needed.