-
Notifications
You must be signed in to change notification settings - Fork 1.4k
CMake config: Fix usage issues #1257
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
Fix error on repeated find_package(ggml). For simplicity, check only for the top-level ggml::ggml.
|
Tested with the standalone example in vcpkg. |
|
Let me also adopt find_dependency. This is useful even when eventually switching to exported CMake config. |
Use set and append to control link lib variables. Apply more $<LINK_ONLY...>.
|
The point of That's why a config package must not use CMake can provide quite useful diagnostics for why it didn't consider a particular config package. |
| set_and_check(GGML_LIB_DIR "@PACKAGE_GGML_LIB_INSTALL_DIR@") | ||
| #set_and_check(GGML_BIN_DIR "@PACKAGE_GGML_BIN_INSTALL_DIR@") | ||
|
|
||
| if(NOT TARGET ggml::ggml) |
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 added the if, but I didn't add indent to the inner code. If desired, I can change the inner lines, too.
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.
Yes, let's indent.
| list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES ${BLAS_LIBRARIES}) | ||
| list(APPEND GGML_CPU_INTERFACE_LINK_OPTIONS ${BLAS_LINKER_FLAGS}) |
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.
Should this go to GGML_BLAS_INTERFACE_LINK_LIBRARIES/OPTIONS instead?
|
Gentle ping. |
| find_dependency(hip) | ||
| find_dependency(hipblas) | ||
| find_dependency(rocblas) |
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.
These are no longer "required" - isn't this a problem? My understanding is if we can't find a required dependency, CMake should stop immediately and report the error.
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.
These are no longer "required" - isn't this a problem?
No.
My understanding is if we can't find a required dependency, CMake should stop immediately and report the error.
No. CMake config files are used via find_package().
- Nothing is required unless the consumer said
REQUIRED. - A single failing package in CONFIG mode is the end for the current config, but not the end of the search.
And find_dependency (without REQUIRED!) is the missing link.
- It knows how to deal with the consumer's
REQUIRED. - It logs why it didn't consider a particular config (with regard to transitive dependencies).
This is standard CMake.
https://cmake.org/cmake/help/latest/module/CMakeFindDependencyMacro.html
ggerganov
left a comment
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.
Ok, let's give this a try - will merge after the indentation.
I don't understand most of the changes here, but you seem to be fluent in this stuff. If something breaks will ping you.
| set_and_check(GGML_LIB_DIR "@PACKAGE_GGML_LIB_INSTALL_DIR@") | ||
| #set_and_check(GGML_BIN_DIR "@PACKAGE_GGML_BIN_INSTALL_DIR@") | ||
|
|
||
| if(NOT TARGET ggml::ggml) |
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.
Yes, let's indent.
Okay. FTR the experience is from packaging in vcpkg (static and dynamic, multi-config/MSVC, multi-platform, pkgconfig and cmake...). The ultimate goal is to use proper export of CMake config. And to have the fixes and the testing here. The changes to test static libs are waiting (https://github.com/dg0yt/ggml/pull/1/files), but it won't be green until some problems are resolved. |
Don't try to create targets if they already exist. (Not just theory: Multiple calls to find_package occur with transitive dependencies.)
Add missing link libs for CUDA and OpenCL, mirroring the setup during the build.
Don't link OpenMP when it wasn't used at build time. Fixes static linkage with AppleClang.