-
Notifications
You must be signed in to change notification settings - Fork 197
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
Fix inconsistency between the building doc and CMakeLists.txt #1248
Fix inconsistency between the building doc and CMakeLists.txt #1248
Conversation
yong-wang
commented
Feb 6, 2023
- update the building doc to make it consistent with CMakeLists.txt
- fix typo in CMakeLists.txt
Pull requests from external contributors require approval from a |
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.
Thanks for the contribution! There's one default here that I'm not quite sure about, asked for some extra feedback.
cpp/CMakeLists.txt
Outdated
@@ -57,7 +57,7 @@ option(DISABLE_DEPRECATION_WARNINGS "Disable deprecaction warnings " ON) | |||
option(DISABLE_OPENMP "Disable OpenMP" OFF) | |||
option(RAFT_NVTX "Enable nvtx markers" OFF) | |||
|
|||
option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" ${BUILD_TESTS}) | |||
option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" OFF) |
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 think we probably want to leave this as defaulting to ${BUILD_TESTS}
, otherwise tests will be extremely slow to compile. Actually, perhaps this really should default to ON if we're building tests or benchmarks, since the same is true in either case. @cjnolet WDYT?
I'm not sure what the best way is to document this default; it may just have to be written in words in build.md rather than relying on a simple ON/OFF entry in the table.
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.
Yeah we definitely want to keep this defaulting to build tests (and I agree it probably should default BUILD_TESTS | BUILD_BENCH. We rely on this to make sure really expensive specializations are compiled once (in libraft-distance/libraft-nn) and reused.
As for the docs, I think we could update the description in this table to maybe mention that it defaults to ON because BUILD_TESTS defaults to on.
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.
How about filling the "Default Value" column with ${BUILD_TESTS}
in the table? Does it look reasonable?
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 searched the web but didn't find any easy way to evaluate things like BUILD_TESTS OR BUILD_BENCH
inside an option()
.
I'm not familiar with CMake. Any suggestion?
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.
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.
CMake doesn't support that kind of expression evaluation. AFAIK the canonical solution would be
set(RAFT_COMPILE_LIBRARIES_DEFAULT OFF)
if(${BUILD_TESTS} OR ${BUILD_BENCH})
set(RAFT_COMPILE_LIBRARIES_DEFAULT OFF)
endif()
option(RAFT_COMPILE_LIBRARIES <description> ${RAFT_COMPILE_LIBRARIES_DEFAULT})
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.
Regarding the table, I think no matter what you put in the column you'll probably need to explain it a bit in words.
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.
This sounds exactly like the use case for cmake_dependent_option
which allows for complex initialization of cache variables.
include(CMakeDependentOption)
cmake_dependent_option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" ON "BUILD_TESTS OR BUILD_BENCH" OFF )
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.
Thanks for the suggestions.
I tried cmake_dependent_option
, but when both BUILD_TESTS
and BUILD_BENCH
are OFF
, could not set RAFT_COMPILE_LIBRARIES
to ON
from the command line. According to CMake doc, RAFT_COMPILE_LIBRARIES
is hidden from the user in this case.
So I used Vyas' way to set the default value. Also updated the table.
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 was not aware of cmake_dependent_option
, that's cool. It does seem from the docs like the way the option may be hidden is incompatible with our needs in this case, though.
ok to test |
/ok to test |
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.
This solution looks fine to me. If @robertmaynard would prefer using cmake_dependent_option
and has a way to get that working, that works for me too. I don't have a strong preference. Thanks for the contribution @yong-wang!
/merge |