-
Notifications
You must be signed in to change notification settings - Fork 18
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
Logic simplification #511
Logic simplification #511
Conversation
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.
I'm afraid I don't agree with this change. DISABLE
should mean "don't use it, even if you can". With the proposed change, it becomes "if not disabled, it is required". That's the wrong semantics...
However, we seem to have 2 (almost independent) variables: DISABLE_CUDA
and USE_CUDA
. That sounds like a bad idea to me, which is maybe why you had a problem.
What about
if (NOT DISABLE_CUDA)
find_package(CUDA)
set (USE_CUDA CUDA_FOUND)
else()
set(USE_CUDA OFF)
endif()
if (USE_CUDA)
message(...)
endif()`
(note that in the above USE_CUDA
is not a cahced variable, hence not user-settable)
Of course, we wouldn't really need the variable USE_CUDA
as it's identical to CUDA_FOUND
, but I think the naming is more logical.
IMO, we should have With the status before this change, one may have requested CUDA to be enabled, or thought they had by setting |
I disagree 😉 . Although both methods are plausible, I'm fairly sure we have chosen the For me, the advantage if
They did not request it to be disabled... They requested CMake to find it and use it if it's present. Maybe my understanding if the English language is incorrect... Of course, we could have both: |
I see your point. The thing I really do not like is the fact that the outcome of |
Can easily write it at the end together with some of the other diagnostics. Even then the SuperBuild doesn't know if a particular project used CUDA or not, so I'm not sure if it's very helpful, but I certainly don't mind. We have a few other |
I think there's a couple of different issues that complicate this. This logic seems ambiguous, I don't know which order CMake evaluates the conditions in, and whether CUDA_FOUND is reset if cmake is reconfigured, but this may have been part of the issue: SIRF-SuperBuild/SuperBuild.cmake Line 52 in 1347466
This is maybe a separate issue but it took me a while to figure out what was going on and it's probably relevant to the variable naming and expected behaviour. Initially I ran cmake with the default SIRF-SuperBuild/SuperBuild/External_Gadgetron.cmake Lines 77 to 78 in 1347466
If we stick with |
I agree that that logic was not good. Moreover, both
yes. This will trip up many, but it is an independent problem of the "logic". We have the same problem with
I agree that this suggestion is another (semantically correct) interpretation of (set VAR VALUE CACHE <type> <docstring> FORCE) However, the SuperBuild cannot do that for the "external" projects, as we have no control over their CMake files, and hence no immediate control over their cached variables. It's possible this can be done with However, if you use that strategy, would you want Final remark, we have far too many variables now already. Adding even more (by making them not-advanced) could easily be non-productive... Summary: I agree it is not ideal, but I don't know how to do it better... |
Shall we close this? |
I'm fine with closing this, but I would remove That could be a different PR or this one. |
outdated and not agreed on the strategy |
Simplified logic slightly force a crash if
find_package(CUDA)
returns false if the user has requestedDISABLE_CUDA=OFF