CMake build system for LAMMPS beta test

hi everybody,

thanks to the tireless work of richard berger (temple u) and christoph junghans (lanl), there is now an alternate build system based on CMake bundled with LAMMPS (as of patch 29 June 2018).

there are still some known issues (e.g. certain combinations of packages do not resolve dependencies correctly), but it is mostly functional and worth giving a try.
we plan to include this feature officially in the next stable release, and thus we need help testing this “in the wild”, since there are many more setups and systems around, than what we can test ourselves on.

the benefits of the CMake system are:

  • automatic detection of locally available features (MPI, OpenMP, gzip, png, jpeg etc.)
  • can output files for multiple build systems and IDEs, not just make
  • full out-of-source build (i.e. can be compiled in multiple different configurations from the same sources)
  • single step build (i.e. required libraries are configured/build automatically along the sources, even automatic download of dependent external libraries is supported in some cases)
  • convenient change of build options through a GUI (ccmake, cmake-gui)
  • easier integration into systems to build precompiled binary packages

to use the CMake build system, you have to remove all pieces of the conventional build: cd src; make clean-all ; make no-all ; make purge ; cd …
you can use only one of them at a time.

then create a build directory and call cmake like this: mkdir build-minimal; cd build-minimal; cmake …/cmake; make; cd …
you will then have an executable called “lmp” in the folder “build-minimal”
you can enable additional packages through using one of the GUIs or calling cmake with a corresponding flag: e.g. -DPKG_MOLECULE=yes to include the MOLECULE packages. there are also a few collection of settings available in …/cmake/presets
these can be used like this: cmake -C …/cmake/presets/std_nolib.cmake …/cmake

​or in a combination:
cmake -C …/cmake/presets/std_nolib.cmake …/cmake -DPKG_VORONOI​

​for more details, please see the cmake/README.md or ​https://github.com/lammps/lammps/tree/master/cmake

the LAMMPS developers welcome any serious suggestions for improvements, notifications of incomplete or inconsistent documentation, or on what would be considered reasonable default choices (e.g. which packages should be enabled by default, or which ones not). when reporting an issue, please test with the very latest master branch from github and report the hash fingerprint reported by: git branch -v

you can either respond to this e-mail or file an issue or pull request on the LAMMPS github project.
please consider helping us out with this for the benefit of all LAMMPS users and help us make the CMake support in the next stable release as solid and complete as possible.

thanks again to richard and christoph for their hard work and putting up with thickheaded old-fashioned make-junkies,
axel.

thanks again to richard and christoph for their hard work and putting up with thickheaded old->fashioned make-junkies,
axel.

Hey, I resemble that comment … :slight_smile:

Seriously, I encourage users to try out the new CMake option.
It’s a good solution to simplifying the complexity of all the options for
a LAMMPS build.

Steve

Thanks for your effort to allow CMake a possibility!

Just a question - what would this means to GPU packages in LAMMPS? As far as I am aware of, CMake doesn’t like having multiple compilers within one build. Are you planning to use GPU as ExternalProject?

Thanks,
Quang

Thanks for your effort to allow CMake a possibility!

Just a question - what would this means to GPU packages in LAMMPS? As far as I am aware of, CMake doesn’t like having multiple compilers within one build.

​why don’t you just give it a try and see for yourself.?​

This actually compiles nicely! I am currently helping out integrating GPU with a project, so definitely will be able to learn a thing or two from LAMMPS.

Anyhow, just notice a typo in the github’s README (https://github.com/lammps/lammps/tree/master/cmake) - at the GPU_ARCH for cuda, there should be underscores (i.e. sm_xx). Else, you received error:

➜ build git:(a52ddf875) cmake …/cmake -DPKG_GPU=on -DGPU_API=CUDA -DGPU_ARCH=sm60 -DGPU_PREC=DOUBLE_DOUBLE

[…]

➜ build git:(a52ddf875) make VERBOSE=1

include -I/usr/lib/x86_64-linux-gnu/openmpi/include
nvcc fatal : Value ‘sm60’ is not defined for option ‘gpu-architecture’
CMake Error at cuda_compile_cubin_1_generated_lal_pppm_f.cu.cubin.Release.cmake:211 (message):
Error generating
/home/qth20/Documents/lammps-sph/lammps/build/cuda_compile_cubin_1_generated_lal_pppm_f.cu.cubin

This will work:

➜ build git:(a52ddf875) cmake …/cmake -DPKG_GPU=on -DGPU_API=CUDA -DGPU_ARCH=sm_60 -DGPU_PREC=DOUBLE_DOUBLE

[100% compiled]

Thanks,
Quang