-
Notifications
You must be signed in to change notification settings - Fork 126
Add CMake build support for find_package(QUIP) #712
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
base: public
Are you sure you want to change the base?
Conversation
Enable LAMMPS and other CMake projects to use QUIP libraries via CMake's find_package() mechanism. Changes: - Add cmake/QUIPConfig.cmake.in template that creates imported targets (QUIP::fox, QUIP::libAtoms, QUIP::GAP, QUIP::Potentials, QUIP::Utils, QUIP::QUIP) for CMake consumers - Use Meson's cmake module to generate QUIPConfig.cmake and QUIPConfigVersion.cmake during installation - Add install: true to all library definitions so they are installed to the lib directory - Update fox and GAP submodules to include install: true After installation, CMake projects can use: find_package(QUIP REQUIRED) target_link_libraries(myapp QUIP::QUIP) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Tested and this should work with the LAMMPS QUIP plugin. LAMMPS's cmake/Modules/Packages/ML-QUIP.cmake needs modification to support Meson-built QUIP. The change is to use CONFIG mode first (for Meson-built QUIP) before falling back to MODULE mode (for legacy Make-built libquip.a): enable_language(Fortran)
-find_package(QUIP QUIET)
+
+# Try to find QUIP - first via CMake config files (Meson-built QUIP),
+# then via legacy FindQUIP module (Make-built libquip.a)
+find_package(QUIP QUIET CONFIG)
+if(NOT QUIP_FOUND)
+ find_package(QUIP QUIET MODULE)
+endif()
if(QUIP_FOUND)
...
else()
- find_package(QUIP REQUIRED)
+ # QUIP was already found at the top of this file, just link it
+ if(NOT QUIP_FOUND)
+ find_package(QUIP QUIET CONFIG)
+ if(NOT QUIP_FOUND)
+ find_package(QUIP REQUIRED MODULE)
+ endif()
+ endif()
target_link_libraries(lammps PRIVATE QUIP::QUIP ${LAPACK_LIBRARIES})
endif()This change is backward compatible - it will still work with legacy Make-built QUIP if no CMake config files are found. @bernstei if you would be willing to test this works for you too then we can think about whether/how to update LAMMPS. |
do you mean just as a test on an independent setup? Because the only thing I ever do with cmake is compile lammps |
|
Yes, just test the LAMMPS + QUIPS compilation with this branch independently. As you can see I got some AI coding assistance with the CMake/Meson bridge. I've run in manually myself but a second pair of eyes would be good. |
Sure, I'm happy to test that, but I'm a bit confused as to what exactly I should do. Do I just grab a recent lammps, make this modification, and everything should work? How does all this new stuff integrate with the auto download (or clone) and custom |
|
This will only work with the no-download route for now, and yes you'd need Meson to compile QUIP. We'd need to make more changes in LAMMPS to make it integrate with CMake+Meson QUIP build with the auto download route. Build and install QUIP with Meson: Build LAMMPS with the pre-built QUIP: Apply the ML-QUIP.cmake patch above then: |
|
I'm happy to test this procedure, assuming I can get meson to work |
|
Looks like it almost worked |
|
Ah, I can see why that would happen. The |
The f90wrap_stub library provides the f90wrap_abort implementation needed by libAtoms for non-Python usage. On macOS this wasn't caught because of -Wl,-undefined,dynamic_lookup, but Linux requires all symbols resolved at link time. Changes: - Install libf90wrap_stub.a alongside other libraries - Add QUIP::f90wrap_stub target to CMake config - Link f90wrap_stub into libAtoms interface dependencies Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
That problem should be fixed now. |
|
Compiles with the cmake file patch above and the latest commit of this branch. I haven't checked performance. |
Summary
Adds CMake package config support so LAMMPS and other CMake projects can use QUIP libraries via
find_package(QUIP).Closes #711
Changes
cmake/QUIPConfig.cmake.intemplate that creates imported targets:QUIP::fox,QUIP::libAtoms,QUIP::GAP,QUIP::Potentials,QUIP::UtilsQUIP::QUIP(unified interface target)QUIPConfig.cmakeandQUIPConfigVersion.cmakeduring installationinstall: trueto all library definitions so they are installed to the lib directoryinstall: trueUsage
After building and installing QUIP with Meson:
CMake projects can then use:
Submodule PRs
This PR depends on corresponding changes in the submodules:
Test plan
meson setupsucceeds with-Dgap=truemeson installinstalls all libraries and CMake config filesfind_package(QUIP)and access all variables/targets🤖 Generated with Claude Code