diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index a4fc5b7b4f111296f4ae1ddcf5dad2cc2a74fa22..87f3dd1f228c3c3c03256cc37c15375a2c2f9f96 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -22,7 +22,6 @@ src/SPIN/* @julient31
src/USER-CGDNA/* @ohenrich
src/USER-CGSDK/* @akohlmey
src/USER-COLVARS/* @giacomofiorin
-src/USER-DPD/* @timattox
src/USER-INTEL/* @wmbrownintel
src/USER-MANIFOLD/* @Pakketeretet2
src/USER-MEAMC/* @martok
@@ -46,7 +45,7 @@ src/GPU/pair_vashishta_gpu.* @andeplane
src/KOKKOS/pair_vashishta_kokkos.* @andeplane
src/MANYBODY/pair_vashishta_table.* @andeplane
src/MANYBODY/pair_atm.* @sergeylishchuk
-src/USER-MISC/fix_bond_react.* @jrgissing
+src/USER-REACTION/fix_bond_react.* @jrgissing
src/USER-MISC/*_grem.* @dstelter92
src/USER-MISC/compute_stress_mop*.* @RomainVermorel
@@ -119,6 +118,7 @@ tools/emacs/* @HaoZeke
# cmake
cmake/* @junghans @rbberger
+cmake/Modules/Packages/USER-COLVARS.cmake @junghans @rbberger @giacomofiorin
# python
python/* @rbberger
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 0f15bf02be262268e29d00fa3c1558e0f357cb63..08522c6d15b86c7c83a9beb153a5dbc366a2f4d1 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -73,7 +73,7 @@ Here is a checklist of steps you need to follow to submit a single file or user
* If you want your contribution to be added as a user-contributed feature, and it is a single file (actually a `.cpp` and `.h` file) it can be rapidly added to the USER-MISC directory. Include the one-line entry to add to the USER-MISC/README file in that directory, along with the 2 source files. You can do this multiple times if you wish to contribute several individual features.
* If you want your contribution to be added as a user-contribution and it is several related features, it is probably best to make it a user package directory with a name like USER-FOO. In addition to your new files, the directory should contain a README text file. The README should contain your name and contact information and a brief description of what your new package does. If your files depend on other LAMMPS style files also being installed (e.g. because your file is a derived class from the other LAMMPS class), then an Install.sh file is also needed to check for those dependencies. See other README and Install.sh files in other USER directories as examples. Send us a tarball of this USER-FOO directory.
* Your new source files need to have the LAMMPS copyright, GPL notice, and your name and email address at the top, like other user-contributed LAMMPS source files. They need to create a class that is inside the LAMMPS namespace. If the file is for one of the USER packages, including USER-MISC, then we are not as picky about the coding style (see above). I.e. the files do not need to be in the same stylistic format and syntax as other LAMMPS files, though that would be nice for developers as well as users who try to read your code.
-* You **must** also create or extend a documentation file for each new command or style you are adding to LAMMPS. For simplicity and convenience, the documentation of groups of closely related commands or styles may be combined into a single file. This will be one file for a single-file feature. For a package, it might be several files. These are files in the [reStructuredText](https://docutils.sourceforge.io/rst.html) markup language, that are then converted to HTML and PDF. The tools for this conversion are included in the source distribution, and the translation can be as simple as doing "make html pdf" in the doc folder. Thus the documentation source files must be in the same format and style as other `.rst` files in the lammps/doc/src directory for similar commands and styles; use one or more of them as a starting point. An introduction to reStructuredText can be found at [https://docutils.sourceforge.io/docs/user/rst/quickstart.html](https://docutils.sourceforge.io/docs/user/rst/quickstart.html). As appropriate, the text files can include mathematical expressions in MathJAX markup or links to equations (see doc/Eqs/*.tex for examples, we auto-create the associated JPG files), or figures (see doc/JPG for examples), or even additional PDF files with further details (see doc/PDF for examples). The doc page should also include literature citations as appropriate; see the bottom of doc/fix_nh.rst for examples and the earlier part of the same file for how to format the cite itself. The "Restrictions" section of the doc page should indicate that your command is only available if LAMMPS is built with the appropriate USER-MISC or USER-FOO package. See other user package doc files for examples of how to do this. The prerequisite for building the HTML format files are Python 3.x and virtualenv. Please run at least `make html` and `make spelling` and carefully inspect and proofread the resulting HTML format doc page as well as the output produced to the screen. Make sure that all spelling errors are fixed or the necessary false positives are added to the `doc/utils/sphinx-config/false_positives.txt` file. For new styles, those usually also need to be added to lists on the respective overview pages. This can be checked for also with `make style_check`.
+* You **must** also create or extend a documentation file for each new command or style you are adding to LAMMPS. For simplicity and convenience, the documentation of groups of closely related commands or styles may be combined into a single file. This will be one file for a single-file feature. For a package, it might be several files. These are files in the [reStructuredText](https://docutils.sourceforge.io/rst.html) markup language, that are then converted to HTML and PDF. The tools for this conversion are included in the source distribution, and the translation can be as simple as doing "make html pdf" in the doc folder. Thus the documentation source files must be in the same format and style as other `.rst` files in the lammps/doc/src directory for similar commands and styles; use one or more of them as a starting point. An introduction to reStructuredText can be found at [https://docutils.sourceforge.io/docs/user/rst/quickstart.html](https://docutils.sourceforge.io/docs/user/rst/quickstart.html). The text files can include mathematical expressions and symbol in ".. math::" sections or ":math:" expressions or figures (see doc/JPG for examples), or even additional PDF files with further details (see doc/PDF for examples). The doc page should also include literature citations as appropriate; see the bottom of doc/fix_nh.rst for examples and the earlier part of the same file for how to format the cite itself. The "Restrictions" section of the doc page should indicate that your command is only available if LAMMPS is built with the appropriate USER-MISC or USER-FOO package. See other user package doc files for examples of how to do this. The prerequisite for building the HTML format files are Python 3.x and virtualenv. Please run at least `make html`, `make pdf` and `make spelling` and carefully inspect and proofread the resulting HTML format doc page as well as the output produced to the screen. Make sure that all spelling errors are fixed or the necessary false positives are added to the `doc/utils/sphinx-config/false_positives.txt` file. For new styles, those usually also need to be added to lists on the respective overview pages. This can be checked for also with `make style_check`.
* For a new package (or even a single command) you should include one or more example scripts demonstrating its use. These should run in no more than a couple minutes, even on a single processor, and not require large data files as input. See directories under examples/USER for examples of input scripts other users provided for their packages. These example inputs are also required for validating memory accesses and testing for memory leaks with valgrind
* If there is a paper of yours describing your feature (either the algorithm/science behind the feature itself, or its initial usage, or its implementation in LAMMPS), you can add the citation to the *.cpp source file. See src/USER-EFF/atom_vec_electron.cpp for an example. A LaTeX citation is stored in a variable at the top of the file and a single line of code that references the variable is added to the constructor of the class. Whenever a user invokes your feature from their input script, this will cause LAMMPS to output the citation to a log.cite file and prompt the user to examine the file. Note that you should only use this for a paper you or your group authored. E.g. adding a cite in the code for a paper by Nose and Hoover if you write a fix that implements their integrator is not the intended usage. That kind of citation should just be in the doc page you provide.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 91b7e2bf4893f3848a5b643135301881915beaee..0d1d3b036419b5e80963d9eff2bf2ce3631a9a2c 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -9,24 +9,24 @@ assignees: ''
**Summary**
-_Please provide a clear and concise description of what the bug is._
+
**LAMMPS Version and Platform**
-_Please specify precisely which LAMMPS version this issue was detected with (the first line of the output) and what platform (operating system and its version, hardware) you are running on. If possible, test with the most recent LAMMPS patch version_
+
**Expected Behavior**
-_Describe the expected behavior. Quote from the LAMMPS manual where needed, or explain why the expected behavior is meaningful, especially when it differs from the manual_
+
**Actual Behavior**
-_Describe the actual behavior, how it differs from the expected behavior, and how this can be observed. Try to be specific and do **not** use vague terms like "doesn't work" or "wrong result". Do not assume that the person reading this has any experience with or knowledge of your specific area of research._
+
**Steps to Reproduce**
-_Describe the steps required to (quickly) reproduce the issue. You can attach (small) files to the section below or add URLs where to download an archive with all necessary files. Please try to create an input set that is as minimal and small as possible and reproduces the bug as quickly as possible. **NOTE:** the less effort and time it takes to reproduce your reported bug, the more likely it becomes, that somebody will look into it and fix the problem._
+
**Further Information, Files, and Links**
-_Put any additional information here, attach relevant text or image files and URLs to external sites, e.g. relevant publications_
+
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index a3a70c0d5a5237f643d7b14dc95bd534d64ba6b0..0334e086fc9e1309ca13bdf18a9fce2ca81900a8 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -9,12 +9,12 @@ assignees: ''
**Summary**
-_Please provide a brief and concise description of the suggested feature or change_
+
**Detailed Description**
-_Please explain how you would like to see LAMMPS enhanced, what feature(s) you are looking for, what specific problems this will solve. If possible, provide references to relevant background information like publications or web pages, and whether you are planning to implement the enhancement yourself or would like to participate in the implementation. If applicable add a reference to an existing bug report or issue that this will address._
+
**Further Information, Files, and Links**
-_Put any additional information here, attach relevant text or image files and URLs to external sites, e.g. relevant publications_
+
diff --git a/.github/ISSUE_TEMPLATE/generic.md b/.github/ISSUE_TEMPLATE/generic.md
index 15d2763919fdc531040b3110eec19832720c09dd..9e5d908bbc283da20d6665b1e804204483459727 100644
--- a/.github/ISSUE_TEMPLATE/generic.md
+++ b/.github/ISSUE_TEMPLATE/generic.md
@@ -9,13 +9,13 @@ assignees: ''
**Summary**
-_Please provide a clear and concise description of what this issue report is about._
+
**LAMMPS Version and Platform**
-_Please specify precisely which LAMMPS version this issue was detected with (the first line of the output) and what platform (operating system and its version, hardware) you are running on. If possible, test with the most recent LAMMPS patch version_
+
**Details**
-_Please explain the issue in detail here_
+
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 9e43aa024440acc0557054f75e991aaf724c7171..6ef945d8d480edc99eb123a3a8634ddc5ee833f6 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,14 +1,14 @@
**Summary**
-_Briefly describe the new feature(s), enhancement(s), or bugfix(es) included in this pull request._
+
**Related Issues**
-_If this addresses an open GitHub issue for this project, please mention the issue number here, and describe the relation. Use the phrases `fixes #221` or `closes #135`, when you want an issue to be automatically closed when the pull request is merged_
+
**Author(s)**
-_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request. If this pull request adds new files to the distribution, please also provide a suitable "long-lived" e-mail address (ideally something that can outlive your institution's e-mail, in case you change jobs) for the *corresponding* author, i.e. the person the LAMMPS developers can contact directly with questions and requests related to maintenance and support of this contributed code._
+
**Licensing**
@@ -16,15 +16,15 @@ By submitting this pull request, I agree, that my contribution will be included
**Backward Compatibility**
-_Please state whether any changes in the pull request will break backward compatibility for inputs, and - if yes - explain what has been changed and why_
+
**Implementation Notes**
-_Provide any relevant details about how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected_
+
**Post Submission Checklist**
-_Please check the fields below as they are completed **after** the pull request has been submitted. Delete lines that don't apply_
+
- [ ] The feature or features in this pull request is complete
- [ ] Licensing information is complete
@@ -39,6 +39,6 @@ _Please check the fields below as they are completed **after** the pull request
**Further Information, Files, and Links**
-_Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)_
+
diff --git a/.github/PULL_REQUEST_TEMPLATE/bug_fix.md b/.github/PULL_REQUEST_TEMPLATE/bug_fix.md
index cea04c68735160a1357446dd05772f9b83f2b397..a5a0b8c489843399dac6f16540bb29c6e65f19f5 100644
--- a/.github/PULL_REQUEST_TEMPLATE/bug_fix.md
+++ b/.github/PULL_REQUEST_TEMPLATE/bug_fix.md
@@ -9,15 +9,15 @@ assignees: ''
**Summary**
-_Briefly describe the bug or bugs, that are eliminated by this pull request._
+
**Related Issue(s)**
-_If this request addresses or is related to an existing (open) GitHub issue, e.g. a bug report, mention the issue number number here following a pound sign (aka hashmark), e.g.`#222`._
+
**Author(s)**
-_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request_
+
**Licensing**
@@ -25,18 +25,18 @@ By submitting this pull request I implicitly accept, that my submission is subje
**Backward Compatibility**
-_Please state whether any changes in the pull request break backward compatibility for inputs, and - if yes - explain what has been changed and why_
+
**Detailed Description**
-_Provide any relevant details about how the fixed bug can be reproduced, how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected_
+
## Post Submission Checklist
-_Please check the fields below as they are completed *after* the pull request is submitted_
+
- [ ] The code in this pull request is complete
- [ ] The source code follows the LAMMPS formatting guidelines
## Further Information, Files, and Links
-_Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. to download input decks for testing)_
+
diff --git a/.github/PULL_REQUEST_TEMPLATE/maintenance_refactoring.md b/.github/PULL_REQUEST_TEMPLATE/maintenance_refactoring.md
index b3599cb36d5c62f23a020687db7f20531ce6b4a4..b7bf40a1e87b893f4db58e833a7cf8cc97eaba17 100644
--- a/.github/PULL_REQUEST_TEMPLATE/maintenance_refactoring.md
+++ b/.github/PULL_REQUEST_TEMPLATE/maintenance_refactoring.md
@@ -9,15 +9,15 @@ assignees: ''
**Summary**
-_Briefly describe the included changes._
+
**Related Issue(s)**
-_If this request addresses or is related to an existing (open) GitHub issue, e.g. a bug report, mention the issue number number here following a pound sign (aka hashmark), e.g.`#222`.
+
**Licensing**
@@ -25,11 +25,11 @@ By submitting this pull request I implicitly accept, that my submission is subje
**Detailed Description**
-_Provide any relevant details about the included changes._
+
## Post Submission Checklist
-_Please check the fields below as they are completed *after* the pull request is submitted_
+
- [ ] The pull request is complete
- [ ] The source code follows the LAMMPS formatting guidelines
diff --git a/.github/PULL_REQUEST_TEMPLATE/new_feature.md b/.github/PULL_REQUEST_TEMPLATE/new_feature.md
index e9d16a0fc7fff973034c4edce0c41c5818ae9ad7..563a9be4aad9651b7a88cae94a9e0806e48900c5 100644
--- a/.github/PULL_REQUEST_TEMPLATE/new_feature.md
+++ b/.github/PULL_REQUEST_TEMPLATE/new_feature.md
@@ -9,34 +9,34 @@ assignees: ''
**Summary**
-_Briefly describe the new feature(s) included in this pull request._
+
**Related Issues**
-_If this addresses an existing (open) GitHub issue, e.g. a feature request, mention the issue number here following a pound sign (aka hashmark), e.g. `#331`._
+
**Author(s)**
-_Please state name and affiliation of the author or authors that should be credited with the features added in this pull request. Please provide a suitable "long-lived" e-mail address (e.g. from gmail, yahoo, outlook, etc.) for the *corresponding* author, i.e. the person the LAMMPS developers can contact directly with questions and requests related to maintenance and support of this code. now and in the future_
+
**Licensing**
-_Please add *yes* or *no* to the following two statements (please contact @lammps/core if you have questions about this)_
+
My contribution may be licensed as GPL v2 (default LAMMPS license):
My contribution may be licensed as LGPL (for use as a library with proprietary software):
**Backward Compatibility**
-_Please state if any of the changes in this pull request will affect backward compatibility for inputs, and - if yes - explain what has been changed and why_
+
**Implementation Notes**
-_Provide any relevant details about how the new features are implemented, how correctness was verified, what platforms (OS, compiler, MPI, hardware, number of processors, accelerator(s)) it was tested on_
+
## Post Submission Checklist
-_Please check the fields below as they are completed *after* the pull request has been submitted_
+
- [ ] The feature or features in this pull request is complete
- [ ] Licensing information is complete
@@ -51,6 +51,6 @@ _Please check the fields below as they are completed *after* the pull request ha
## Further Information, Files, and Links
-_Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)_
+
diff --git a/.github/PULL_REQUEST_TEMPLATE/update_enhancement.md b/.github/PULL_REQUEST_TEMPLATE/update_enhancement.md
index 52ef91e6c10909afe74c89a04fb390459267b955..9edfb587c04470dfa00bf0a63ad127e6944b2f92 100644
--- a/.github/PULL_REQUEST_TEMPLATE/update_enhancement.md
+++ b/.github/PULL_REQUEST_TEMPLATE/update_enhancement.md
@@ -9,11 +9,11 @@ assignees: ''
**Summary**
-_Briefly describe what kind of updates or enhancements for a package or feature are included. If you are not the original author of the package or feature, please mention, whether your contribution was created independently or in collaboration/cooperation with the original author._
+
**Author(s)**
-_Please state name and affiliation of the author or authors that should be credited with the changes in this pull request_
+
**Licensing**
@@ -21,15 +21,15 @@ By submitting this pull request I implicitly accept, that my submission is subje
**Backward Compatibility**
-_Please state whether any changes in the pull request break backward compatibility for inputs, and - if yes - explain what has been changed and why_
+
**Implementation Notes**
-_Provide any relevant details about how the changes are implemented, how correctness was verified, how other features - if any - in LAMMPS are affected_
+
**Post Submission Checklist**
-_Please check the fields below as they are completed_
+
- [ ] The feature or features in this pull request is complete
- [ ] Suitable updates to the existing docs are included
- [ ] One or more example input decks are included
@@ -37,6 +37,6 @@ _Please check the fields below as they are completed_
**Further Information, Files, and Links**
-_Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)_
+
diff --git a/.gitignore b/.gitignore
index f9dda49da647a4fd029fc9a905d869cc3bb47dee..5c90b0f39c11771629f97608e916077b46999ffe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@
*.d
*.x
*.exe
+*.sif
*.dll
*.pyc
__pycache__
@@ -26,6 +27,7 @@ vgcore.*
.vagrant
\#*#
.#*
+.vscode
.DS_Store
.DS_Store?
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 92293f294b96f2b77671cf1927259df4e8552f06..d9c82678eb85857a8e43a8702e72cd89417eef56 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -2,7 +2,7 @@
# CMake build system
# This file is part of LAMMPS
# Created by Christoph Junghans and Richard Berger
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.10)
project(lammps CXX)
set(SOVERSION 0)
@@ -21,22 +21,16 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "default install path" FORCE )
endif()
-# To avoid conflicts with the conventional Makefile build system, we build everything here
-file(GLOB LIB_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp)
-file(GLOB LMP_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp)
-list(REMOVE_ITEM LIB_SOURCES ${LMP_SOURCES})
-
# Cmake modules/macros are in a subdirectory to keep this file cleaner
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
include(LAMMPSUtils)
-get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION)
+get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h PROJECT_VERSION)
include(PreventInSourceBuilds)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
- #release comes with -O3 by default
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE)
@@ -52,116 +46,85 @@ check_for_autogen_files(${LAMMPS_SOURCE_DIR})
include(CheckCCompilerFlag)
include(CheckIncludeFileCXX)
+# set required compiler flags and compiler/CPU arch specific optimizations
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict -std=c++11")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4)
+ set(CMAKE_TUNE_DEFAULT "-xCOMMON-AVX512")
+ else()
+ set(CMAKE_TUNE_DEFAULT "-xHost")
+ endif()
endif()
-option(DISABLE_CXX11_REQUIREMENT "Disable check that requires C++11 for compiling LAMMPS" OFF)
-if(DISABLE_CXX11_REQUIREMENT)
- add_definitions(-DLAMMPS_CXX98)
-# else()
-# set(CMAKE_CXX_STANDARD 11)
+if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+ set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native")
endif()
-# GNU compiler features
+if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+ set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native")
+endif()
+
+# we require C++11 without extensions
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+# GNU compiler specific features for testing
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
- option(ENABLE_COVERAGE "Enable code coverage" OFF)
+ option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF)
mark_as_advanced(ENABLE_COVERAGE)
if(ENABLE_COVERAGE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif()
- option(ENABLE_SANITIZE_ADDRESS "Enable address sanitizer" OFF)
- mark_as_advanced(ENABLE_SANITIZE_ADDRESS)
- if(ENABLE_SANITIZE_ADDRESS)
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
- endif()
- option(ENABLE_SANITIZE_UNDEFINED "Enable undefined behavior sanitizer" OFF)
- mark_as_advanced(ENABLE_SANITIZE_UNDEFINED)
- if(ENABLE_SANITIZE_UNDEFINED)
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
- endif()
- option(ENABLE_SANITIZE_THREAD "Enable thread sanitizer" OFF)
- mark_as_advanced(ENABLE_SANITIZE_THREAD)
- if(ENABLE_SANITIZE_THREAD)
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
- endif()
endif()
########################################################################
# User input options #
########################################################################
-option(BUILD_EXE "Build lmp binary" ON)
-if(BUILD_EXE)
- set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary (WON'T enable any features automatically")
- mark_as_advanced(LAMMPS_MACHINE)
- if(LAMMPS_MACHINE)
- set(LAMMPS_MACHINE "_${LAMMPS_MACHINE}")
- endif()
- set(LAMMPS_BINARY lmp${LAMMPS_MACHINE})
+set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary (WON'T enable any features automatically")
+mark_as_advanced(LAMMPS_MACHINE)
+if(LAMMPS_MACHINE)
+ set(LAMMPS_MACHINE "_${LAMMPS_MACHINE}")
endif()
+set(LAMMPS_BINARY lmp${LAMMPS_MACHINE})
-option(BUILD_LIB "Build LAMMPS library" OFF)
-if(BUILD_LIB)
- option(BUILD_SHARED_LIBS "Build shared library" OFF)
- if(BUILD_SHARED_LIBS) # for all pkg libs, mpi_stubs and linalg
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
- endif()
- set(LAMMPS_LIB_SUFFIX "" CACHE STRING "Suffix to append to liblammps and pkg-config file")
- mark_as_advanced(LAMMPS_LIB_SUFFIX)
- if(LAMMPS_LIB_SUFFIX)
- set(LAMMPS_LIB_SUFFIX "_${LAMMPS_LIB_SUFFIX}")
- endif()
+option(BUILD_SHARED_LIBS "Build shared library" OFF)
+if(BUILD_SHARED_LIBS) # for all pkg libs, mpi_stubs and linalg
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF)
-if(NOT BUILD_EXE AND NOT BUILD_LIB)
- message(FATAL_ERROR "You need to at least enable one of two following options: BUILD_LIB or BUILD_EXE")
-endif()
-
-option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF)
include(GNUInstallDirs)
+file(GLOB ALL_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp)
+file(GLOB MAIN_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp)
+list(REMOVE_ITEM ALL_SOURCES ${MAIN_SOURCES})
+add_library(lammps ${ALL_SOURCES})
+add_executable(lmp ${MAIN_SOURCES})
+target_link_libraries(lmp PRIVATE lammps)
+set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY})
+install(TARGETS lmp EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR})
-set(LAMMPS_LINK_LIBS)
-set(LAMMPS_DEPS)
-set(LAMMPS_API_DEFINES)
+option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF)
-set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE
+set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE
GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MOLECULE PERI POEMS QEQ
REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI
- USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS
+ USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESODPD USER-CGSDK USER-COLVARS
USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB
USER-MANIFOLD USER-MEAMC USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE
- USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REAXC
- USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF
- USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS)
-set(ACCEL_PACKAGES USER-OMP KOKKOS OPT USER-INTEL GPU)
-foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES})
+ USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REACTION
+ USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY
+ USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS)
+set(SUFFIX_PACKAGES CORESHELL USER-OMP KOKKOS OPT USER-INTEL GPU)
+foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
option(PKG_${PKG} "Build ${PKG} Package" OFF)
endforeach()
-######################################################
-# download and unpack support binaries for compilation
-# of windows binaries.
-######################################################
-if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- set(LAMMPS_THIRDPARTY_URL "http://download.lammps.org/thirdparty")
- file(DOWNLOAD "${LAMMPS_THIRDPARTY_URL}/opencl-win-devel.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/opencl-win-devel.tar.gz"
- EXPECTED_MD5 2c00364888d5671195598b44c2e0d44d)
- execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf opencl-win-devel.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
- set(OpenCL_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win32/libOpenCL.dll")
- elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
- set(OpenCL_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win64/libOpenCL.dll")
- endif()
- set(OpenCL_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/include")
-endif()
-
-######################################################
######################################################
# packages with special compiler needs or external libs
######################################################
-include_directories(${LAMMPS_SOURCE_DIR})
+target_include_directories(lammps PUBLIC $)
if(PKG_USER-ADIOS)
# The search for ADIOS2 must come before MPI because
@@ -169,27 +132,47 @@ if(PKG_USER-ADIOS)
# script that defines the MPI::MPI_C target
enable_language(C)
find_package(ADIOS2 REQUIRED)
- list(APPEND LAMMPS_LINK_LIBS adios2::adios2)
+ target_link_libraries(lammps PRIVATE adios2::adios2)
+endif()
+
+if(NOT CMAKE_CROSSCOMPILING)
+ set(MPI_CXX_SKIP_MPICXX TRUE)
+ find_package(MPI QUIET)
+ option(BUILD_MPI "Build MPI version" ${MPI_FOUND})
+else()
+ option(BUILD_MPI "Build MPI version" OFF)
endif()
-# do MPI detection after language activation, if MPI for these language is required
-set(MPI_CXX_SKIP_MPICXX TRUE)
-find_package(MPI QUIET)
-option(BUILD_MPI "Build MPI version" ${MPI_FOUND})
if(BUILD_MPI)
- find_package(MPI REQUIRED)
- include_directories(${MPI_CXX_INCLUDE_PATH})
- list(APPEND LAMMPS_LINK_LIBS ${MPI_CXX_LIBRARIES})
- option(LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF)
- if(LAMMPS_LONGLONG_TO_LONG)
- add_definitions(-DLAMMPS_LONGLONG_TO_LONG)
+ # We use a non-standard procedure to cross-compile with MPI on Windows
+ if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)
+ include(MPI4WIN)
+ target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
+ else()
+ find_package(MPI REQUIRED)
+ target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
+ option(LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF)
+ if(LAMMPS_LONGLONG_TO_LONG)
+ target_compile_definitions(lammps PRIVATE -DLAMMPS_LONGLONG_TO_LONG)
+ endif()
endif()
else()
enable_language(C)
file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c)
add_library(mpi_stubs STATIC ${MPI_SOURCES})
- include_directories(${LAMMPS_SOURCE_DIR}/STUBS)
- list(APPEND LAMMPS_LINK_LIBS mpi_stubs)
+ if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS mpi_stubs EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+ set_target_properties(mpi_stubs PROPERTIES OUTPUT_NAME lammps_mpi_stubs${LAMMPS_MACHINE})
+ target_include_directories(mpi_stubs PUBLIC $ $)
+ install(FILES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps/mpi)
+ if(BUILD_SHARED_LIBS)
+ target_link_libraries(lammps PRIVATE mpi_stubs)
+ target_include_directories(lammps INTERFACE $ $)
+ else()
+ target_link_libraries(lammps PUBLIC mpi_stubs)
+ endif()
+ add_library(MPI::MPI_CXX ALIAS mpi_stubs)
endif()
set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)")
@@ -197,8 +180,7 @@ set(LAMMPS_SIZES_VALUES smallbig bigbig smallsmall)
set_property(CACHE LAMMPS_SIZES PROPERTY STRINGS ${LAMMPS_SIZES_VALUES})
validate_option(LAMMPS_SIZES LAMMPS_SIZES_VALUES)
string(TOUPPER ${LAMMPS_SIZES} LAMMPS_SIZES)
-add_definitions(-DLAMMPS_${LAMMPS_SIZES})
-set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_${LAMMPS_SIZES}")
+target_compile_definitions(lammps PUBLIC -DLAMMPS_${LAMMPS_SIZES})
# posix_memalign is not available on Windows
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
@@ -207,13 +189,12 @@ else()
set(LAMMPS_MEMALIGN "64" CACHE STRING "enables the use of the posix_memalign() call instead of malloc() when large chunks or memory are allocated by LAMMPS. Set to 0 to disable")
endif()
if(NOT ${LAMMPS_MEMALIGN} STREQUAL "0")
- add_definitions(-DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN})
+ target_compile_definitions(lammps PRIVATE -DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN})
endif()
option(LAMMPS_EXCEPTIONS "enable the use of C++ exceptions for error messages (useful for library interface)" OFF)
if(LAMMPS_EXCEPTIONS)
- add_definitions(-DLAMMPS_EXCEPTIONS)
- set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_EXCEPTIONS")
+ target_compile_definitions(lammps PUBLIC -DLAMMPS_EXCEPTIONS)
endif()
# "hard" dependencies between packages resulting
@@ -224,27 +205,36 @@ pkg_depends(USER-LB MPI)
pkg_depends(USER-PHONON KSPACE)
pkg_depends(USER-SCAFACOS MPI)
+# detect if we may enable OpenMP support by default
+set(BUILD_OMP_DEFAULT OFF)
find_package(OpenMP QUIET)
-
-# TODO: this is a temporary workaround until a better solution is found. AK 2019-05-30
-# GNU GCC 9.x uses settings incompatible with our use of 'default(none)' in OpenMP pragmas
-# where we assume older GCC semantics. For the time being, we disable OpenMP by default
-# for GCC 9.x and beyond. People may manually turn it on, but need to run the script
-# src/USER-OMP/hack_openmp_for_pgi_gcc9.sh on all sources to make it compatible with gcc 9.
-if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.99.9))
- option(BUILD_OMP "Build with OpenMP support" OFF)
-else()
- option(BUILD_OMP "Build with OpenMP support" ${OpenMP_FOUND})
+if(OpenMP_FOUND)
+ check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE)
+ if(HAVE_OMP_H_INCLUDE)
+ set(BUILD_OMP_DEFAULT ON)
+ endif()
endif()
+option(BUILD_OMP "Build with OpenMP support" ${BUILD_OMP_DEFAULT})
+
if(BUILD_OMP)
find_package(OpenMP REQUIRED)
check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE)
if(NOT HAVE_OMP_H_INCLUDE)
- message(FATAL_ERROR "Cannot find required 'omp.h' header file")
+ message(FATAL_ERROR "Cannot find the 'omp.h' header file required for full OpenMP support")
+ endif()
+
+ if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.99.9)) OR
+ ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.99.9)) OR
+ ((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18.99.9))
+ )
+ # GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts.
+ # Intel 18.0 was tested to support both, so we switch to OpenMP 4+ from 19.x onward to be safe.
+ target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=4)
+ else()
+ target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=3)
endif()
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+ target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX)
endif()
if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE)
@@ -252,14 +242,19 @@ if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE)
find_package(LAPACK)
find_package(BLAS)
if(NOT LAPACK_FOUND OR NOT BLAS_FOUND)
- if(CMAKE_GENERATOR STREQUAL "Ninja")
- status(FATAL_ERROR "Cannot build internal linear algebra library with Ninja build tool due to lack for Fortran support")
+ include(CheckGeneratorSupport)
+ if(NOT CMAKE_GENERATOR_SUPPORT_FORTRAN)
+ status(FATAL_ERROR "Cannot build internal linear algebra library as CMake build tool lacks Fortran support")
endif()
enable_language(Fortran)
file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.[fF])
add_library(linalg STATIC ${LAPACK_SOURCES})
- set(BLAS_LIBRARIES linalg)
- set(LAPACK_LIBRARIES linalg)
+ if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS linalg EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+ set_target_properties(linalg PROPERTIES OUTPUT_NAME lammps_linalg${LAMMPS_MACHINE})
+ set(BLAS_LIBRARIES "$")
+ set(LAPACK_LIBRARIES "$")
else()
list(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif()
@@ -270,9 +265,13 @@ find_package(JPEG QUIET)
option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND})
if(WITH_JPEG)
find_package(JPEG REQUIRED)
- add_definitions(-DLAMMPS_JPEG)
- include_directories(${JPEG_INCLUDE_DIR})
- list(APPEND LAMMPS_LINK_LIBS ${JPEG_LIBRARIES})
+ target_compile_definitions(lammps PRIVATE -DLAMMPS_JPEG)
+ if(CMAKE_VERSION VERSION_LESS 3.12)
+ target_include_directories(lammps PRIVATE ${JPEG_INCLUDE_DIR})
+ target_link_libraries(lammps PRIVATE ${JPEG_LIBRARIES})
+ else()
+ target_link_libraries(lammps PRIVATE JPEG::JPEG)
+ endif()
endif()
find_package(PNG QUIET)
@@ -285,9 +284,8 @@ endif()
if(WITH_PNG)
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)
- include_directories(${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
- add_definitions(-DLAMMPS_PNG)
+ target_link_libraries(lammps PRIVATE PNG::PNG ZLIB::ZLIB)
+ target_compile_definitions(lammps PRIVATE -DLAMMPS_PNG)
endif()
find_program(GZIP_EXECUTABLE gzip)
@@ -297,7 +295,7 @@ if(WITH_GZIP)
if(NOT GZIP_FOUND)
message(FATAL_ERROR "gzip executable not found")
endif()
- add_definitions(-DLAMMPS_GZIP)
+ target_compile_definitions(lammps PRIVATE -DLAMMPS_GZIP)
endif()
find_program(FFMPEG_EXECUTABLE ffmpeg)
@@ -307,7 +305,7 @@ if(WITH_FFMPEG)
if(NOT FFMPEG_FOUND)
message(FATAL_ERROR "ffmpeg executable not found")
endif()
- add_definitions(-DLAMMPS_FFMPEG)
+ target_compile_definitions(lammps PRIVATE -DLAMMPS_FFMPEG)
endif()
if(BUILD_SHARED_LIBS)
@@ -320,29 +318,25 @@ else()
set(CUDA_REQUEST_PIC)
endif()
-include(Packages/KSPACE)
-include(Packages/PYTHON)
-include(Packages/VORONOI)
-include(Packages/USER-COLVARS)
-include(Packages/USER-MOLFILE)
-include(Packages/USER-NETCDF)
-include(Packages/USER-PLUMED)
-include(Packages/USER-QMMM)
-include(Packages/USER-QUIP)
-include(Packages/USER-SCAFACOS)
-include(Packages/USER-SMD)
-include(Packages/USER-VTK)
-include(Packages/KIM)
-include(Packages/LATTE)
-include(Packages/MESSAGE)
-include(Packages/MSCG)
-include(Packages/COMPRESS)
-
-# the windows version of LAMMPS requires a couple extra libraries
-if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- list(APPEND LAMMPS_LINK_LIBS -lwsock32 -lpsapi)
-endif()
+foreach(PKG_WITH_INCL KSPACE PYTHON VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM
+ USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS)
+ if(PKG_${PKG_WITH_INCL})
+ include(Packages/${PKG_WITH_INCL})
+ endif()
+endforeach()
+set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler specific optimization or instrumentation")
+separate_arguments(CMAKE_TUNE_FLAGS)
+include(CheckCXXCompilerFlag)
+foreach(_FLAG ${CMAKE_TUNE_FLAGS})
+ string(REGEX REPLACE "[=\"]" "" _FLAGX ${_FLAG})
+ check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAGX})
+ if(COMPILER_SUPPORTS${_FLAGX})
+ target_compile_options(lammps PRIVATE ${_FLAG})
+ else()
+ message(WARNING "${_FLAG} found in CMAKE_TUNE_FLAGS, but not supported by the compiler, skipping")
+ endif()
+endforeach()
########################################################################
# Basic system tests (standard libraries, headers, functions, types) #
########################################################################
@@ -355,18 +349,7 @@ endforeach(HEADER)
set(MATH_LIBRARIES "m" CACHE STRING "math library")
mark_as_advanced( MATH_LIBRARIES )
-include(CheckLibraryExists)
-if (CMAKE_VERSION VERSION_LESS "3.4")
- enable_language(C) # check_library_exists isn't supported without a C compiler before v3.4
-endif()
-# RB: disabled this check because it breaks with KOKKOS CUDA enabled
-#foreach(FUNC sin cos)
-# check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES})
-# if(NOT FOUND_${FUNC}_${MATH_LIBRARIES})
-# message(FATAL_ERROR "Could not find needed math function - ${FUNC}")
-# endif(NOT FOUND_${FUNC}_${MATH_LIBRARIES})
-#endforeach(FUNC)
-list(APPEND LAMMPS_LINK_LIBS ${MATH_LIBRARIES})
+target_link_libraries(lammps PRIVATE ${MATH_LIBRARIES})
######################################
# Generate Basic Style files
@@ -377,7 +360,7 @@ RegisterStyles(${LAMMPS_SOURCE_DIR})
##############################################
# add sources of enabled packages
############################################
-foreach(PKG ${DEFAULT_PACKAGES})
+foreach(PKG ${STANDARD_PACKAGES})
set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG})
file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp)
@@ -390,8 +373,8 @@ foreach(PKG ${DEFAULT_PACKAGES})
# detects styles in package and adds them to global list
RegisterStyles(${${PKG}_SOURCES_DIR})
- list(APPEND LIB_SOURCES ${${PKG}_SOURCES})
- include_directories(${${PKG}_SOURCES_DIR})
+ target_sources(lammps PRIVATE ${${PKG}_SOURCES})
+ target_include_directories(lammps PRIVATE ${${PKG}_SOURCES_DIR})
endif()
RegisterPackages(${${PKG}_SOURCES_DIR})
@@ -400,12 +383,12 @@ endforeach()
# packages that need defines set
foreach(PKG MPIIO)
if(PKG_${PKG})
- add_definitions(-DLMP_${PKG})
+ target_compile_definitions(lammps PRIVATE -DLMP_${PKG})
endif()
endforeach()
# dedicated check for entire contents of accelerator packages
-foreach(PKG ${ACCEL_PACKAGES})
+foreach(PKG ${SUFFIX_PACKAGES})
set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG})
file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp)
@@ -420,16 +403,19 @@ endforeach()
##############################################
# add lib sources of (simple) enabled packages
############################################
-foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-QMMM)
+foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD)
if(PKG_${SIMPLE_LIB})
string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}")
string(TOLOWER "${PKG_LIB}" PKG_LIB)
file(GLOB_RECURSE ${PKG_LIB}_SOURCES
- ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.F
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp)
add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES})
- list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB})
+ if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS ${PKG_LIB} EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+ set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_MACHINE})
+ target_link_libraries(lammps PRIVATE ${PKG_LIB})
if(PKG_LIB STREQUAL awpmd)
target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include)
elseif(PKG_LIB STREQUAL h5md)
@@ -441,30 +427,40 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-QMMM)
endforeach()
if(PKG_USER-AWPMD)
- target_link_libraries(awpmd ${LAPACK_LIBRARIES})
+ target_link_libraries(awpmd PRIVATE ${LAPACK_LIBRARIES})
endif()
if(PKG_USER-ATC)
if(LAMMPS_SIZES STREQUAL BIGBIG)
message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG")
endif()
- target_link_libraries(atc ${LAPACK_LIBRARIES})
+ target_link_libraries(atc PRIVATE ${LAPACK_LIBRARIES} MPI::MPI_CXX)
+ target_include_directories(atc PRIVATE ${LAMMPS_SOURCE_DIR})
+ target_compile_definitions(atc PRIVATE -DLAMMPS_${LAMMPS_SIZES})
endif()
-include(Packages/USER-H5MD)
+if(PKG_USER-H5MD)
+ include(Packages/USER-H5MD)
+endif()
######################################################################
# packages which selectively include variants based on enabled styles
# e.g. accelerator packages
######################################################################
-include(Packages/CORESHELL)
-include(Packages/QEQ)
-include(Packages/USER-OMP)
-include(Packages/USER-SDPD)
-include(Packages/KOKKOS)
-include(Packages/OPT)
-include(Packages/USER-INTEL)
-include(Packages/GPU)
+foreach(PKG_WITH_INCL CORESHELL QEQ USER-OMP USER-SDPD KOKKOS OPT USER-INTEL GPU)
+ if(PKG_${PKG_WITH_INCL})
+ include(Packages/${PKG_WITH_INCL})
+ endif()
+endforeach()
+
+######################################################################
+# the windows version of LAMMPS requires a couple extra libraries
+# and the MPI library - if use - has to be linked right before those
+# and after everything else that is compiled locally
+######################################################################
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+ target_link_libraries(lammps PRIVATE -lwsock32 -lpsapi)
+endif()
######################################################
# Generate style headers based on global list of
@@ -476,14 +472,14 @@ set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles)
GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR})
GeneratePackagesHeaders(${LAMMPS_STYLE_HEADERS_DIR})
-include_directories(${LAMMPS_STYLE_HEADERS_DIR})
+target_include_directories(lammps PRIVATE ${LAMMPS_STYLE_HEADERS_DIR})
######################################
# Generate lmpinstalledpkgs.h
######################################
set(temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n")
set(temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] = {\n")
-set(temp_PKG_LIST ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES})
+set(temp_PKG_LIST ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
list(SORT temp_PKG_LIST)
foreach(PKG ${temp_PKG_LIST})
if(PKG_${PKG})
@@ -505,7 +501,7 @@ add_custom_target(gitversion COMMAND ${CMAKE_COMMAND}
-DLAMMPS_STYLE_HEADERS_DIR="${LAMMPS_STYLE_HEADERS_DIR}"
-P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/generate_lmpgitversion.cmake)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${LAMMPS_STYLE_HEADERS_DIR}/gitversion.h)
-list(APPEND LAMMPS_DEPS gitversion)
+add_dependencies(lammps gitversion)
###########################################
# Actually add executable and lib to build
@@ -513,95 +509,64 @@ list(APPEND LAMMPS_DEPS gitversion)
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
list (FIND LANGUAGES "Fortran" _index)
if (${_index} GREATER -1)
- list(APPEND LAMMPS_LINK_LIBS ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
-endif()
-list(REMOVE_DUPLICATES LAMMPS_LINK_LIBS)
-if(BUILD_LIB)
- add_library(lammps ${LIB_SOURCES})
- target_link_libraries(lammps ${LAMMPS_LINK_LIBS})
- if(LAMMPS_DEPS)
- add_dependencies(lammps ${LAMMPS_DEPS})
- endif()
- set(LAMMPS_CXX_HEADERS
- ${LAMMPS_SOURCE_DIR}/angle.h
- ${LAMMPS_SOURCE_DIR}/atom.h
- ${LAMMPS_SOURCE_DIR}/bond.h
- ${LAMMPS_SOURCE_DIR}/citeme.h
- ${LAMMPS_SOURCE_DIR}/comm.h
- ${LAMMPS_SOURCE_DIR}/compute.h
- ${LAMMPS_SOURCE_DIR}/dihedral.h
- ${LAMMPS_SOURCE_DIR}/domain.h
- ${LAMMPS_SOURCE_DIR}/error.h
- ${LAMMPS_SOURCE_DIR}/fix.h
- ${LAMMPS_SOURCE_DIR}/force.h
- ${LAMMPS_SOURCE_DIR}/group.h
- ${LAMMPS_SOURCE_DIR}/improper.h
- ${LAMMPS_SOURCE_DIR}/input.h
- ${LAMMPS_SOURCE_DIR}/kspace.h
- ${LAMMPS_SOURCE_DIR}/lammps.h
- ${LAMMPS_SOURCE_DIR}/lattice.h
- ${LAMMPS_SOURCE_DIR}/lmppython.h
- ${LAMMPS_SOURCE_DIR}/memory.h
- ${LAMMPS_SOURCE_DIR}/modify.h
- ${LAMMPS_SOURCE_DIR}/neighbor.h
- ${LAMMPS_SOURCE_DIR}/neigh_list.h
- ${LAMMPS_SOURCE_DIR}/output.h
- ${LAMMPS_SOURCE_DIR}/pair.h
- ${LAMMPS_SOURCE_DIR}/pointers.h
- ${LAMMPS_SOURCE_DIR}/region.h
- ${LAMMPS_SOURCE_DIR}/timer.h
- ${LAMMPS_SOURCE_DIR}/universe.h
- ${LAMMPS_SOURCE_DIR}/update.h
- ${LAMMPS_SOURCE_DIR}/variable.h)
-
- set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_LIB_SUFFIX})
- set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION})
- install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
- install(FILES ${LAMMPS_SOURCE_DIR}/library.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
- install(FILES ${LAMMPS_CXX_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
- configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc @ONLY)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
- configure_file(FindLAMMPS.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindLAMMPS${LAMMPS_LIB_SUFFIX}.cmake @ONLY)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FindLAMMPS${LAMMPS_LIB_SUFFIX}.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Modules)
-else()
- list(APPEND LMP_SOURCES ${LIB_SOURCES})
-endif()
-
-if(BUILD_EXE)
- add_executable(lmp ${LMP_SOURCES})
- if(BUILD_LIB)
- target_link_libraries(lmp lammps)
- else()
- target_link_libraries(lmp ${LAMMPS_LINK_LIBS})
- if(LAMMPS_DEPS)
- add_dependencies(lmp ${LAMMPS_DEPS})
- endif()
- endif()
-
- set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY})
- install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR})
- install(FILES ${LAMMPS_DOC_DIR}/lammps.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME ${LAMMPS_BINARY}.1)
+ target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
endif()
+set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h compute.h dihedral.h domain.h error.h fix.h force.h group.h improper.h
+ input.h info.h kspace.h lammps.h lattice.h library.h lmppython.h lmptype.h memory.h modify.h neighbor.h neigh_list.h output.h
+ pair.h pointers.h region.h timer.h universe.h update.h variable.h)
+if(LAMMPS_EXCEPTIONS)
+ list(APPEND LAMMPS_CXX_HEADERS exceptions.h)
+endif()
+
+set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_MACHINE})
+set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION})
+install(TARGETS lammps EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+target_include_directories(lammps PUBLIC $)
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps)
+foreach(_HEADER ${LAMMPS_CXX_HEADERS})
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_SOURCE_DIR}/${_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} DEPENDS ${LAMMPS_SOURCE_DIR}/${_HEADER})
+ add_custom_target(${_HEADER} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER})
+ add_dependencies(lammps ${_HEADER})
+ install(FILES ${LAMMPS_SOURCE_DIR}/${_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
+endforeach()
+target_include_directories(lammps INTERFACE $)
+add_library(LAMMPS::lammps ALIAS lammps)
+get_target_property(LAMMPS_DEFINES lammps INTERFACE_COMPILE_DEFINITIONS)
+set(LAMMPS_API_DEFINES)
+foreach(_DEF ${LAMMPS_DEFINES})
+ set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -D${_DEF}")
+endforeach()
+configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+install(EXPORT LAMMPS_Targets FILE LAMMPS_Targets.cmake NAMESPACE LAMMPS:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
+file(GLOB MODULE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Modules/Find*.cmake)
+install(FILES ${MODULE_FILES} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
+include(CMakePackageConfigHelpers)
+configure_file(LAMMPSConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake @ONLY)
+write_basic_package_version_file("LAMMPSConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
+install(FILES ${LAMMPS_DOC_DIR}/lammps.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME ${LAMMPS_BINARY}.1)
if(BUILD_TOOLS)
add_executable(binary2txt ${LAMMPS_TOOLS_DIR}/binary2txt.cpp)
+ target_compile_definitions(binary2txt PRIVATE -DLAMMPS_${LAMMPS_SIZES})
install(TARGETS binary2txt DESTINATION ${CMAKE_INSTALL_BINDIR})
- # ninja-build currently does not support fortran. thus we skip building this tool
- if(CMAKE_GENERATOR STREQUAL "Ninja")
- message(STATUS "Skipping building 'chain.x' with Ninja build tool due to lack of Fortran support")
- else()
+ include(CheckGeneratorSupport)
+ if(CMAKE_GENERATOR_SUPPORT_FORTRAN)
enable_language(Fortran)
add_executable(chain.x ${LAMMPS_TOOLS_DIR}/chain.f)
- target_link_libraries(chain.x ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
+ target_link_libraries(chain.x PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
install(TARGETS chain.x DESTINATION ${CMAKE_INSTALL_BINDIR})
+ else()
+ message(WARNING "CMake build doesn't support fortran, skipping building 'chain.x'")
endif()
enable_language(C)
get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE)
file(GLOB MSI2LMP_SOURCES ${MSI2LMP_SOURCE_DIR}/[^.]*.c)
add_executable(msi2lmp ${MSI2LMP_SOURCES})
- target_link_libraries(msi2lmp m)
+ target_link_libraries(msi2lmp PRIVATE ${MATH_LIBRARIES})
install(TARGETS msi2lmp DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${LAMMPS_DOC_DIR}/msi2lmp.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
endif()
@@ -631,12 +596,19 @@ install(
# conventional build. Only available, if a shared library is built.
# This is primarily for people that only want to use the Python wrapper.
###############################################################################
-if(BUILD_LIB AND BUILD_SHARED_LIBS)
- find_package(PythonInterp)
- if (PYTHONINTERP_FOUND)
+if(BUILD_SHARED_LIBS)
+ if(CMAKE_VERSION VERSION_LESS 3.12)
+ find_package(PythonInterp) # Deprecated since version 3.12
+ if(PYTHONINTERP_FOUND)
+ set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
+ endif()
+ else()
+ find_package(Python COMPONENTS Interpreter)
+ endif()
+ if (Python_EXECUTABLE)
add_custom_target(
install-python
- ${PYTHON_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h
+ ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h
-m ${LAMMPS_PYTHON_DIR}/lammps.py
-l ${CMAKE_BINARY_DIR}/liblammps${CMAKE_SHARED_LIBRARY_SUFFIX}
WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR}
@@ -657,10 +629,17 @@ endif()
# LAMMPS for package managers and with different prefix settings.
# This requires either a shared library or that the PYTHON package is included.
###############################################################################
-if((BUILD_LIB AND BUILD_SHARED_LIBS) OR (PKG_PYTHON))
- find_package(PythonInterp)
- if (PYTHONINTERP_FOUND)
- execute_process(COMMAND ${PYTHON_EXECUTABLE}
+if(BUILD_SHARED_LIBS OR PKG_PYTHON)
+ if(CMAKE_VERSION VERSION_LESS 3.12)
+ find_package(PythonInterp) # Deprecated since version 3.12
+ if(PYTHONINTERP_FOUND)
+ set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
+ endif()
+ else()
+ find_package(Python COMPONENTS Interpreter)
+ endif()
+ if (Python_EXECUTABLE)
+ execute_process(COMMAND ${Python_EXECUTABLE}
-c "import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))"
OUTPUT_VARIABLE PYTHON_DEFAULT_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set(PYTHON_INSTDIR ${PYTHON_DEFAULT_INSTDIR} CACHE PATH "Installation folder for LAMMPS Python module")
@@ -674,69 +653,103 @@ include(CodeCoverage)
###############################################################################
# Print package summary
###############################################################################
-foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES})
+foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
if(PKG_${PKG})
message(STATUS "Building package: ${PKG}")
endif()
endforeach()
-get_directory_property(CPPFLAGS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
+get_target_property(DEFINES lammps COMPILE_DEFINITIONS)
include(FeatureSummary)
-feature_summary(DESCRIPTION "The following packages have been found:" WHAT PACKAGES_FOUND)
+feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND)
message(STATUS "<<< Build configuration >>>
- Build type ${CMAKE_BUILD_TYPE}
- Install path ${CMAKE_INSTALL_PREFIX}
- Compilers and Flags:
- C++ Compiler ${CMAKE_CXX_COMPILER}
- Type ${CMAKE_CXX_COMPILER_ID}
- Version ${CMAKE_CXX_COMPILER_VERSION}
- C++ Flags ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}
- Defines ${CPPFLAGS}")
+ Build type: ${CMAKE_BUILD_TYPE}
+ Install path: ${CMAKE_INSTALL_PREFIX}
+ Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}
+-- <<< Compilers and Flags: >>>
+-- C++ Compiler: ${CMAKE_CXX_COMPILER}
+ Type: ${CMAKE_CXX_COMPILER_ID}
+ Version: ${CMAKE_CXX_COMPILER_VERSION}
+ C++ Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}
+ Defines: ${DEFINES}")
+get_target_property(OPTIONS lammps COMPILE_OPTIONS)
+if(OPTIONS)
+ message(" Options: ${OPTIONS}")
+endif()
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
list (FIND LANGUAGES "Fortran" _index)
if (${_index} GREATER -1)
- message(STATUS "Fortran Compiler ${CMAKE_Fortran_COMPILER}
- Type ${CMAKE_Fortran_COMPILER_ID}
- Version ${CMAKE_Fortran_COMPILER_VERSION}
- Fortran Flags ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}")
+ message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER}
+ Type: ${CMAKE_Fortran_COMPILER_ID}
+ Version: ${CMAKE_Fortran_COMPILER_VERSION}
+ Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}")
endif()
list (FIND LANGUAGES "C" _index)
if (${_index} GREATER -1)
- message(STATUS "C Compiler ${CMAKE_C_COMPILER}
- Type ${CMAKE_C_COMPILER_ID}
- Version ${CMAKE_C_COMPILER_VERSION}
- C Flags ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BTYPE}}")
+ message(STATUS "C compiler: ${CMAKE_C_COMPILER}
+ Type: ${CMAKE_C_COMPILER_ID}
+ Version: ${CMAKE_C_COMPILER_VERSION}
+ C Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BTYPE}}")
endif()
+message(STATUS "<<< Linker flags: >>>")
+message(STATUS "Executable name: ${LAMMPS_BINARY}")
if(CMAKE_EXE_LINKER_FLAGS)
- message(STATUS "Linker flags:
- Executable ${CMAKE_EXE_LINKER_FLAGS}")
+ message(STATUS "Executable linker flags: ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(BUILD_SHARED_LIBS)
- message(STATUS "Shared libraries ${CMAKE_SHARED_LINKER_FLAGS}")
+ message(STATUS "Shared library flags: ${CMAKE_SHARED_LINKER_FLAGS}")
else()
- message(STATUS "Static libraries ${CMAKE_STATIC_LINKER_FLAGS}")
+ message(STATUS "Static library flags: ${CMAKE_STATIC_LINKER_FLAGS}")
endif()
-message(STATUS "Link libraries: ${LAMMPS_LINK_LIBS}")
if(BUILD_MPI)
- message(STATUS "Using mpi with headers in ${MPI_CXX_INCLUDE_PATH} and ${MPI_CXX_LIBRARIES}")
+ message(STATUS "<<< MPI flags >>>
+-- MPI_defines: ${MPI_CXX_COMPILE_DEFINITIONS}
+-- MPI includes: ${MPI_CXX_INCLUDE_PATH}
+-- MPI libraries: ${MPI_CXX_LIBRARIES};${MPI_Fortran_LIBRARIES}")
endif()
if(PKG_GPU)
- message(STATUS "GPU Api: ${GPU_API}")
+ message(STATUS "<<< GPU package settings >>>
+-- GPU API: ${GPU_API}")
if(GPU_API STREQUAL "CUDA")
- message(STATUS "GPU Arch: ${GPU_ARCH}")
+ message(STATUS "GPU architecture: ${GPU_ARCH}")
elseif(GPU_API STREQUAL "OPENCL")
- message(STATUS "OCL Tune: ${OCL_TUNE}")
+ message(STATUS "OpenCL tuning: ${OCL_TUNE}")
+ elseif(GPU_API STREQUAL "HIP")
+ message(STATUS "HIP platform: ${HIP_PLATFORM}")
+ message(STATUS "HIP architecture: ${HIP_ARCH}")
+ if(HIP_USE_DEVICE_SORT)
+ message(STATUS "HIP GPU sorting: on")
+ else()
+ message(STATUS "HIP GPU sorting: off")
+ endif()
endif()
- message(STATUS "GPU Precision: ${GPU_PREC}")
+ message(STATUS "GPU precision: ${GPU_PREC}")
endif()
if(PKG_KOKKOS)
message(STATUS "Kokkos Arch: ${KOKKOS_ARCH}")
endif()
if(PKG_KSPACE)
- message(STATUS "Using ${FFT} as primary FFT library")
+ message(STATUS "<<< FFT settings >>>
+-- Primary FFT lib: ${FFT}")
if(FFT_SINGLE)
message(STATUS "Using single precision FFTs")
else()
message(STATUS "Using double precision FFTs")
endif()
+ if(FFT_FFTW_THREADS OR FFT_MKL_THREADS)
+ message(STATUS "Using threaded FFTs")
+ else()
+ message(STATUS "Using non-threaded FFTs")
+ endif()
+ if(PKG_KOKKOS)
+ if(Kokkos_ENABLE_CUDA)
+ if (${FFT} STREQUAL "KISS")
+ message(STATUS "Kokkos FFT: KISS")
+ else()
+ message(STATUS "Kokkos FFT: cuFFT")
+ endif()
+ else()
+ message(STATUS "Kokkos FFT: ${FFT}")
+ endif()
+ endif()
endif()
diff --git a/cmake/FindLAMMPS.cmake.in b/cmake/FindLAMMPS.cmake.in
deleted file mode 100644
index 586df83c2d080197ea0256794febd395ab81cc63..0000000000000000000000000000000000000000
--- a/cmake/FindLAMMPS.cmake.in
+++ /dev/null
@@ -1,48 +0,0 @@
-# - Find liblammps
-# Find the native liblammps headers and libraries.
-#
-# The following variables will set:
-# LAMMPS_INCLUDE_DIRS - where to find lammps/library.h, etc.
-# LAMMPS_LIBRARIES - List of libraries when using lammps.
-# LAMMPS_API_DEFINES - lammps library api defines
-# LAMMPS_VERSION - lammps library version
-# LAMMPS_FOUND - True if liblammps found.
-#
-# In addition a LAMMPS::LAMMPS imported target is getting created.
-#
-# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-# http://lammps.sandia.gov, Sandia National Laboratories
-# Steve Plimpton, sjplimp@sandia.gov
-#
-# Copyright (2003) Sandia Corporation. Under the terms of Contract
-# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-# certain rights in this software. This software is distributed under
-# the GNU General Public License.
-#
-# See the README file in the top-level LAMMPS directory.
-#
-
-find_package(PkgConfig)
-
-pkg_check_modules(PC_LAMMPS liblammps@LAMMPS_LIB_SUFFIX@)
-find_path(LAMMPS_INCLUDE_DIR lammps/library.h HINTS ${PC_LAMMPS_INCLUDE_DIRS} @CMAKE_INSTALL_FULL_INCLUDEDIR@)
-
-set(LAMMPS_VERSION @LAMMPS_VERSION@)
-set(LAMMPS_API_DEFINES @LAMMPS_API_DEFINES@)
-
-find_library(LAMMPS_LIBRARY NAMES lammps@LAMMPS_LIB_SUFFIX@ HINTS ${PC_LAMMPS_LIBRARY_DIRS} @CMAKE_INSTALL_FULL_LIBDIR@)
-
-set(LAMMPS_INCLUDE_DIRS "${LAMMPS_INCLUDE_DIR}")
-set(LAMMPS_LIBRARIES "${LAMMPS_LIBRARY}")
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set LAMMPS_FOUND to TRUE
-# if all listed variables are TRUE
-find_package_handle_standard_args(LAMMPS REQUIRED_VARS LAMMPS_LIBRARY LAMMPS_INCLUDE_DIR VERSION_VAR LAMMPS_VERSION)
-
-mark_as_advanced(LAMMPS_INCLUDE_DIR LAMMPS_LIBRARY)
-
-if(LAMMPS_FOUND AND NOT TARGET LAMMPS::LAMMPS)
- add_library(LAMMPS::LAMMPS UNKNOWN IMPORTED)
- set_target_properties(LAMMPS::LAMMPS PROPERTIES IMPORTED_LOCATION "${LAMMPS_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${LAMMPS_INCLUDE_DIR}" INTERFACE_COMPILE_DEFINITIONS "${LAMMPS_API_DEFINES}")
-endif()
diff --git a/cmake/LAMMPSConfig.cmake.in b/cmake/LAMMPSConfig.cmake.in
new file mode 100644
index 0000000000000000000000000000000000000000..7cd782b3b8eb4585dd3eb4d1c75e852abf64fd29
--- /dev/null
+++ b/cmake/LAMMPSConfig.cmake.in
@@ -0,0 +1,87 @@
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
+include(CMakeFindDependencyMacro)
+if(@BUILD_MPI@)
+ find_dependency(MPI REQUIRED CXX)
+endif()
+if(@PKG_KSPACE@)
+ if(@FFT@ STREQUAL "FFTW3")
+ find_dependency(@FFTW@ REQUIRED MODULE)
+ endif()
+endif()
+if(NOT @BUILD_SHARED_LIBS@)
+ if(@BUILD_OMP@)
+ find_dependency(OpenMP REQUIRED)
+ endif()
+ if(@WITH_JPEG@)
+ find_dependency(JPEG REQUIRED)
+ endif()
+ if(@WITH_PNG@)
+ find_dependency(PNG REQUIRED)
+ find_dependency(ZLIB REQUIRED)
+ endif()
+ if(@PKG_KIM@)
+ find_dependency(PkgConfig REQUIRED)
+ pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=@KIM-API_MIN_VERSION@)
+ if(@CURL_FOUND@)
+ find_dependency(CURL REQUIRED)
+ endif()
+ endif()
+ if(@PKG_USER-SMD@)
+ find_dependency(Eigen3 NO_MODULE REQUIRED)
+ endif()
+ if(@PKG_USER-SCAFACOS@)
+ find_dependency(PkgConfig REQUIRED)
+ find_ependency(GSL REQUIRED)
+ find_dependency(MPI REQUIRED C Fortran)
+ pkg_check_modules(SCAFACOS REQUIRED IMPORTED_TARGET scafacos)
+ endif()
+ if(@PKG_PYTHON@ AND NOT CMAKE_VERSION VERSION_LESS 3.12)
+ find_package(Python REQUIRED COMPONENTS Development)
+ endif()
+ if(@PKG_COMPRESS@)
+ find_dependency(ZLIB REQUIRED)
+ endif()
+ if(@PKG_KOKKOS@)
+ if(@EXTERNAL_KOKKOS@)
+ find_dependency(Kokkos 3 REQUIRED)
+ endif()
+ endif()
+ if(@PKG_VORONOI@)
+ find_dependency(VORO REQUIRED)
+ endif()
+ if(@PKG_USER-INTEL@)
+ if(@INTEL_LRT_MODE@ STREQUAL "THREADS")
+ find_dependency(Threads REQUIRED)
+ endif()
+ if(@TBB_MALLOC_FOUND@)
+ find_ependency(TBB_MALLOC REQUIRED)
+ endif()
+ endif()
+ if(@PKG_USER-ADIOS@)
+ find_ependency(ADIOS2 REQUIRED)
+ endif()
+ if(@PKG_LATTE@)
+ find_ependency(LATTE REQUIRED)
+ endif()
+ if(@PKG_MESSAGE@)
+ if(@MESSAGE_ZMQ@)
+ find_ependency(ZMQ REQUIRED)
+ endif()
+ endif()
+ if(@PKG_MSCG@)
+ find_ependency(GSL REQUIRED)
+ find_ependency(MSCG REQUIRED)
+ endif()
+ if(@USER-NETCDF@)
+ if(@NETCDF_FOUND@)
+ find_ependency(NetCDF REQUIRED)
+ endif()
+ if(@PNETCDF_FOUND@)
+ find_ependency(PNetCDF REQUIRED)
+ endif()
+ endif()
+ if(@PKG_QUIP@)
+ find_ependency(QUIP REQUIRED)
+ endif()
+endif()
+include("${CMAKE_CURRENT_LIST_DIR}/LAMMPS_Targets.cmake")
diff --git a/cmake/Modules/CheckGeneratorSupport.cmake b/cmake/Modules/CheckGeneratorSupport.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..62d33036a5cf49c8514f1740bf3d89ec2d58776c
--- /dev/null
+++ b/cmake/Modules/CheckGeneratorSupport.cmake
@@ -0,0 +1,21 @@
+# ninja-build<1.10 does not support fortran.
+if(CMAKE_GENERATOR STREQUAL "Ninja")
+ set(CMAKE_GENERATOR_SUPPORT_FORTRAN FALSE)
+ execute_process(COMMAND "${CMAKE_MAKE_PROGRAM}" --version
+ OUTPUT_VARIABLE NINJA_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE _Ninja_version_result
+ )
+ if(_Ninja_version_result)
+ message(WARNING "Unable to determine ninja version: ${_Ninja_version_result}, assuming fortran isn't supported")
+ elseif(NINJA_VERSION VERSION_LESS "1.10")
+ message(WARNING "Ninja build tool too old, to compile Fortran code, please install ninja-1.10 or newer")
+ else()
+ set(CMAKE_GENERATOR_SUPPORT_FORTRAN TRUE)
+ endif()
+else()
+ set(CMAKE_GENERATOR_SUPPORT_FORTRAN TRUE)
+ if(NOT CMAKE_GENERATOR STREQUAL "Unix Makefiles")
+ message(WARNING "Assuming fortran is supported for ${CMAKE_GENERATOR}")
+ endif()
+endif()
diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake
index feff66a9b2520b4f54b214d7873337ae48269064..929d6ebd4bd9d7903494c5a1f4f5e5e82a934221 100644
--- a/cmake/Modules/Documentation.cmake
+++ b/cmake/Modules/Documentation.cmake
@@ -1,10 +1,8 @@
###############################################################################
# Build documentation
###############################################################################
-option(BUILD_DOC "Build LAMMPS documentation" OFF)
+option(BUILD_DOC "Build LAMMPS HTML documentation" OFF)
if(BUILD_DOC)
- include(ProcessorCount)
- ProcessorCount(NPROCS)
find_package(PythonInterp 3 REQUIRED)
set(VIRTUALENV ${PYTHON_EXECUTABLE} -m virtualenv)
@@ -26,15 +24,49 @@ if(BUILD_DOC)
COMMAND ${DOCENV_BINARY_DIR}/pip install --upgrade ${LAMMPS_DOC_DIR}/utils/converters
)
+ # download mathjax distribution and unpack to folder "mathjax"
+ file(DOWNLOAD "https://github.com/mathjax/MathJax/archive/3.0.5.tar.gz"
+ "${CMAKE_CURRENT_BINARY_DIR}/mathjax.tar.gz"
+ EXPECTED_MD5 5d9d3799cce77a1a95eee6be04eb68e7)
+
+ if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mathjax)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf mathjax.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ file(GLOB MATHJAX_VERSION_DIR ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E rename ${MATHJAX_VERSION_DIR} ${CMAKE_CURRENT_BINARY_DIR}/mathjax)
+ endif()
+ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/_static/mathjax)
+ file(COPY ${CMAKE_CURRENT_BINARY_DIR}/mathjax/es5 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/html/_static/mathjax/)
+
+ # note, this may run in parallel with other tasks, so we must not use multiple processes here
add_custom_command(
OUTPUT html
DEPENDS ${DOC_SOURCES} docenv requirements.txt
- COMMAND ${DOCENV_BINARY_DIR}/sphinx-build -j ${NPROCS} -b html -c ${LAMMPS_DOC_DIR}/utils/sphinx-config -d ${CMAKE_BINARY_DIR}/doctrees ${LAMMPS_DOC_DIR}/src html
+ COMMAND ${DOCENV_BINARY_DIR}/sphinx-build -b html -c ${LAMMPS_DOC_DIR}/utils/sphinx-config -d ${CMAKE_BINARY_DIR}/doctrees ${LAMMPS_DOC_DIR}/src html
)
+ # copy selected image files to html output tree
+ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/html/JPG)
+ set(HTML_EXTRA_IMAGES balance_nonuniform.jpg balance_rcb.jpg
+ balance_uniform.jpg bow_tutorial_01.png bow_tutorial_02.png
+ bow_tutorial_03.png bow_tutorial_04.png bow_tutorial_05.png
+ dump1.jpg dump2.jpg examples_mdpd.gif gran_funnel.png gran_mixer.png
+ hop1.jpg hop2.jpg saed_ewald_intersect.jpg saed_mesh.jpg
+ screenshot_atomeye.jpg screenshot_gl.jpg screenshot_pymol.jpg
+ screenshot_vmd.jpg sinusoid.jpg xrd_mesh.jpg)
+ set(HTML_IMAGE_TARGETS "")
+ foreach(_IMG ${HTML_EXTRA_IMAGES})
+ string(PREPEND _IMG JPG/)
+ list(APPEND HTML_IMAGE_TARGETS "html/${_IMG}")
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/${_IMG}
+ DEPENDS ${LAMMPS_DOC_DIR}/src/${_IMG} html/JPG
+ COMMAND ${CMAKE_COMMAND} -E copy ${LAMMPS_DOC_DIR}/src/${_IMG} ${CMAKE_BINARY_DIR}/html/${_IMG}
+ )
+ endforeach()
+
add_custom_target(
doc ALL
- DEPENDS html
+ DEPENDS html html/_static/mathjax/es5 ${HTML_IMAGE_TARGETS}
SOURCES ${LAMMPS_DOC_DIR}/utils/requirements.txt ${DOC_SOURCES}
)
diff --git a/cmake/Modules/FindCUB.cmake b/cmake/Modules/FindCUB.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..848e68e81512144ad56124bdf0dcbcce0f6fa50e
--- /dev/null
+++ b/cmake/Modules/FindCUB.cmake
@@ -0,0 +1,16 @@
+# - Find CUB
+# Find the CUB header library
+#
+# CUB_INCLUDE_DIRS - where to find cub/cub.cuh
+# CUB_FOUND - True if CUB found.
+#
+
+find_path(CUB_INCLUDE_DIR cub.cuh PATH_SUFFIXES cub)
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set CUB_FOUND to TRUE
+# if all listed variables are TRUE
+
+find_package_handle_standard_args(CUB DEFAULT_MSG CUB_INCLUDE_DIR)
+
+mark_as_advanced(CUB_INCLUDE_DIR)
diff --git a/cmake/Modules/FindFFTW3.cmake b/cmake/Modules/FindFFTW3.cmake
index 552bcc4257adf0833a2d4d25bcbce3974a27ec7c..708ec495091352fded80d323b37942bdb17e086f 100644
--- a/cmake/Modules/FindFFTW3.cmake
+++ b/cmake/Modules/FindFFTW3.cmake
@@ -1,20 +1,18 @@
# - Find fftw3
-# Find the native FFTW3 headers and libraries.
+# Find the native double precision FFTW3 headers and libraries.
#
-# FFTW3_INCLUDE_DIRS - where to find fftw3.h, etc.
-# FFTW3_LIBRARIES - List of libraries when using fftw3.
-# FFTW3_FOUND - True if fftw3 found.
+# FFTW3_INCLUDE_DIRS - where to find fftw3.h, etc.
+# FFTW3_LIBRARIES - List of libraries when using fftw3.
+# FFTW3_OMP_LIBRARIES - List of libraries when using fftw3.
+# FFTW3_FOUND - True if fftw3 found.
#
find_package(PkgConfig)
pkg_check_modules(PC_FFTW3 fftw3)
find_path(FFTW3_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3_INCLUDE_DIRS})
-
find_library(FFTW3_LIBRARY NAMES fftw3 HINTS ${PC_FFTW3_LIBRARY_DIRS})
-
-set(FFTW3_LIBRARIES ${FFTW3_LIBRARY})
-set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR})
+find_library(FFTW3_OMP_LIBRARY NAMES fftw3_omp HINTS ${PC_FFTW3_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE
@@ -22,4 +20,28 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARY FFTW3_INCLUDE_DIR)
-mark_as_advanced(FFTW3_INCLUDE_DIR FFTW3_LIBRARY )
+# Copy the results to the output variables and target.
+if(FFTW3_FOUND)
+ set(FFTW3_LIBRARIES ${FFTW3_LIBRARY} )
+ set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR} )
+
+ if(NOT TARGET FFTW3::FFTW3)
+ add_library(FFTW3::FFTW3 UNKNOWN IMPORTED)
+ set_target_properties(FFTW3::FFTW3 PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${FFTW3_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIRS}")
+ endif()
+ if(FFTW3_OMP_LIBRARY)
+ set(FFTW3_OMP_LIBRARIES ${FFTW3_OMP_LIBRARY})
+ if(NOT TARGET FFTW3::FFTW3_OMP)
+ add_library(FFTW3::FFTW3_OMP UNKNOWN IMPORTED)
+ set_target_properties(FFTW3::FFTW3_OMP PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${FFTW3_OMP_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIRS}")
+ endif()
+ endif()
+endif()
+
+mark_as_advanced(FFTW3_INCLUDE_DIR FFTW3_LIBRARY FFTW3_OMP_LIBRARY)
diff --git a/cmake/Modules/FindFFTW3F.cmake b/cmake/Modules/FindFFTW3F.cmake
index 92d1e85e791ec362a15909bd09dccdc046efc2a5..3dbcdaa04e190c79d80281e9f91fa166755f585a 100644
--- a/cmake/Modules/FindFFTW3F.cmake
+++ b/cmake/Modules/FindFFTW3F.cmake
@@ -1,8 +1,8 @@
-# - Find fftw3f
-# Find the native FFTW3F headers and libraries.
+# Find the native single precision FFTW3 headers and libraries.
#
# FFTW3F_INCLUDE_DIRS - where to find fftw3f.h, etc.
# FFTW3F_LIBRARIES - List of libraries when using fftw3f.
+# FFTW3F_OMP_LIBRARIES - List of libraries when using fftw3.
# FFTW3F_FOUND - True if fftw3f found.
#
@@ -10,11 +10,8 @@ find_package(PkgConfig)
pkg_check_modules(PC_FFTW3F fftw3f)
find_path(FFTW3F_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3F_INCLUDE_DIRS})
-
find_library(FFTW3F_LIBRARY NAMES fftw3f HINTS ${PC_FFTW3F_LIBRARY_DIRS})
-
-set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY})
-set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR})
+find_library(FFTW3F_OMP_LIBRARY NAMES fftw3f_omp HINTS ${PC_FFTW3F_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set FFTW3F_FOUND to TRUE
@@ -22,4 +19,28 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW3F DEFAULT_MSG FFTW3F_LIBRARY FFTW3F_INCLUDE_DIR)
-mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY )
+# Copy the results to the output variables and target.
+if(FFTW3F_FOUND)
+ set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY} )
+ set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR} )
+
+ if(NOT TARGET FFTW3F::FFTW3F)
+ add_library(FFTW3F::FFTW3F UNKNOWN IMPORTED)
+ set_target_properties(FFTW3F::FFTW3F PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${FFTW3F_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${FFTW3F_INCLUDE_DIRS}")
+ endif()
+ if(FFTW3F_OMP_LIBRARY)
+ set(FFTW3F_OMP_LIBRARIES ${FFTW3F_OMP_LIBRARY})
+ if(NOT TARGET FFTW3F::FFTW3F_OMP)
+ add_library(FFTW3F::FFTW3F_OMP UNKNOWN IMPORTED)
+ set_target_properties(FFTW3F::FFTW3F_OMP PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${FFTW3F_OMP_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${FFTW3F_INCLUDE_DIRS}")
+ endif()
+ endif()
+endif()
+
+mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY FFTW3F_OMP_LIBRARY)
diff --git a/cmake/Modules/FindKIM-API.cmake b/cmake/Modules/FindKIM-API.cmake
deleted file mode 100644
index 17c195e62f515752d893118cd9a0d08e0ad8ae58..0000000000000000000000000000000000000000
--- a/cmake/Modules/FindKIM-API.cmake
+++ /dev/null
@@ -1,85 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the Common Development
-# and Distribution License Version 1.0 (the "License").
-#
-# You can obtain a copy of the license at
-# http://www.opensource.org/licenses/CDDL-1.0. See the License for the
-# specific language governing permissions and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each file and
-# include the License file in a prominent location with the name LICENSE.CDDL.
-# If applicable, add the following below this CDDL HEADER, with the fields
-# enclosed by brackets "[]" replaced with your own identifying information:
-#
-# Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved.
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright (c) 2013--2019, Regents of the University of Minnesota.
-# All rights reserved.
-#
-# Contributors:
-# Richard Berger
-# Christoph Junghans
-# Ryan S. Elliott
-#
-
-# - Find KIM-API
-#
-# sets standard pkg_check_modules variables plus:
-#
-# KIM-API-CMAKE_C_COMPILER
-# KIM-API-CMAKE_CXX_COMPILER
-# KIM-API-CMAKE_Fortran_COMPILER
-#
-
-function(_KIMAPI_GET_VERSION _OUT_ver _version_hdr)
- if(NOT EXISTS ${_version_hdr})
- message(FATAL_ERROR "Header file ${_version_hdr} not found (check value of KIM-API_INCLUDE_DIR)")
- endif()
- foreach(_var KIM_VERSION_MAJOR KIM_VERSION_MINOR KIM_VERSION_PATCH)
- file(STRINGS ${_version_hdr} _contents REGEX "#define ${_var}[ \t]+")
- if(_contents)
- string(REGEX REPLACE ".*#define ${_var}[ \t]+([0-9]+).*" "\\1" _${_var} "${_contents}")
- if(${_${_var}} STREQUAL "")
- message(FATAL_ERROR "Version parsing failed for ${_var} in ${_version_hdr}, got empty return!")
- elseif(NOT ${_${_var}} MATCHES "^[0-9]+$")
- message(FATAL_ERROR "Version parsing failed for ${_var} in ${_version_hdr}, excepted a number but got ${_${_var}}!")
- endif()
- else()
- message(FATAL_ERROR "No ${_var} line found in include file ${_version_hdr}")
- endif()
- endforeach()
- set(${_OUT_ver} ${_KIM_VERSION_MAJOR}.${_KIM_VERSION_MINOR}.${_KIM_VERSION_PATCH} PARENT_SCOPE)
-endfunction()
-
-if(KIM-API_FIND_QUIETLY)
- set(REQ_OR_QUI "QUIET")
-else()
- set(REQ_OR_QUI "REQUIRED")
-endif()
-
-find_package(PkgConfig ${REQ_OR_QUI})
-include(FindPackageHandleStandardArgs)
-
-pkg_check_modules(KIM-API ${REQ_OR_QUI} libkim-api>=2.0)
-
-if(KIM-API_FOUND)
- pkg_get_variable(KIM-API-CMAKE_C_COMPILER libkim-api CMAKE_C_COMPILER)
- pkg_get_variable(KIM-API-CMAKE_CXX_COMPILER libkim-api CMAKE_CXX_COMPILER)
- pkg_get_variable(KIM-API_CMAKE_Fortran_COMPILER libkim-api CMAKE_Fortran_COMPILER)
-endif()
-
-if(KIM-API_INCLUDEDIR)
- _KIMAPI_GET_VERSION(KIM-API_VERSION ${KIM-API_INCLUDEDIR}/KIM_Version.h)
-else()
- set(KIM-API_VERSION 0)
-endif()
-
-# handle the QUIETLY and REQUIRED arguments and set KIM-API_FOUND to TRUE
-# if all listed variables are TRUE
-find_package_handle_standard_args(KIM-API REQUIRED_VARS KIM-API_LIBRARIES VERSION_VAR KIM-API_VERSION)
diff --git a/cmake/Modules/FindLATTE.cmake b/cmake/Modules/FindLATTE.cmake
index 74d5173bf0725ae74f0eaf08214b8b593a74e473..ac5c639b79313019ba9880f1f178ce1449034ef1 100644
--- a/cmake/Modules/FindLATTE.cmake
+++ b/cmake/Modules/FindLATTE.cmake
@@ -7,12 +7,21 @@
find_library(LATTE_LIBRARY NAMES latte)
-set(LATTE_LIBRARIES ${LATTE_LIBRARY})
-
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LATTE_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(LATTE DEFAULT_MSG LATTE_LIBRARY)
+# Copy the results to the output variables and target.
+if(LATTE_FOUND)
+ set(LATTE_LIBRARIES ${LATTE_LIBRARY})
+
+ if(NOT TARGET LATTE::latte)
+ add_library(LATTE::latte UNKNOWN IMPORTED)
+ set_target_properties(LATTE::latte PROPERTIES
+ IMPORTED_LOCATION "${LATTE_LIBRARY}")
+ endif()
+endif()
+
mark_as_advanced(LATTE_LIBRARY)
diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake
index 4246062103f943c2c54347c2cbc796db96cff54e..e3dc60ad9749a2c0d5ddf6e1c30132af03a6c00e 100644
--- a/cmake/Modules/FindMKL.cmake
+++ b/cmake/Modules/FindMKL.cmake
@@ -10,13 +10,22 @@ find_path(MKL_INCLUDE_DIR mkl_dfti.h HINTS $ENV{MKLROOT}/include)
find_library(MKL_LIBRARY NAMES mkl_rt HINTS $ENV{MKLROOT}/lib $ENV{MKLROOT}/lib/intel64)
-set(MKL_LIBRARIES ${MKL_LIBRARY})
-set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR})
-
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set MKL_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(MKL DEFAULT_MSG MKL_LIBRARY MKL_INCLUDE_DIR)
+if(MKL_FOUND)
+ set(MKL_LIBRARIES ${MKL_LIBRARY})
+ set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR})
+
+ if(NOT TARGET MKL::MKL)
+ add_library(MKL::MKL UNKNOWN IMPORTED)
+ set_target_properties(MKL::MKL PROPERTIES
+ IMPORTED_LOCATION "${MKL_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${MKL_INCLUDE_DIR}")
+ endif()
+endif()
+
mark_as_advanced(MKL_INCLUDE_DIR MKL_LIBRARY )
diff --git a/cmake/Modules/FindMSCG.cmake b/cmake/Modules/FindMSCG.cmake
index 311ff7803836aa43c2c48bd4040a60686b1803db..b301303dbec9dbdb186d44b39f806d1c60e2bc45 100644
--- a/cmake/Modules/FindMSCG.cmake
+++ b/cmake/Modules/FindMSCG.cmake
@@ -10,13 +10,23 @@ find_path(MSCG_INCLUDE_DIR mscg.h PATH_SUFFIXES mscg)
find_library(MSCG_LIBRARY NAMES mscg)
-set(MSCG_LIBRARIES ${MSCG_LIBRARY})
-set(MSCG_INCLUDE_DIRS ${MSCG_INCLUDE_DIR})
-
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set MSCG_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(MSCG DEFAULT_MSG MSCG_LIBRARY MSCG_INCLUDE_DIR)
+# Copy the results to the output variables and target.
+if(MSCG_FOUND)
+ set(MSCG_LIBRARIES ${MSCG_LIBRARY})
+ set(MSCG_INCLUDE_DIRS ${MSCG_INCLUDE_DIR})
+
+ if(NOT TARGET MSCG::MSCG)
+ add_library(MSCG::MSCG UNKNOWN IMPORTED)
+ set_target_properties(MSCG::MSCG PROPERTIES
+ IMPORTED_LOCATION "${MSCG_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${MSCG_INCLUDE_DIR}")
+ endif()
+endif()
+
mark_as_advanced(MSCG_INCLUDE_DIR MSCG_LIBRARY )
diff --git a/cmake/Modules/FindNetCDF.cmake b/cmake/Modules/FindNetCDF.cmake
index 2a992b6b3b532513d1f2886cd5e76aeaba32df20..5c8caa920820da14855e51ab6032b3d7a4e775b7 100644
--- a/cmake/Modules/FindNetCDF.cmake
+++ b/cmake/Modules/FindNetCDF.cmake
@@ -120,3 +120,14 @@ set (NETCDF_INCLUDE_DIRS ${NetCDF_includes})
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (NetCDF
DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDE_DIRS NETCDF_HAS_INTERFACES)
+
+# Copy the results to the output variables and target.
+if(NetCDF_FOUND)
+ if(NOT TARGET NetCDF::NetCDF)
+ add_library(NetCDF::NetCDF UNKNOWN IMPORTED)
+ set_target_properties(NetCDF::NetCDF PROPERTIES
+ IMPORTED_LOCATION "${NETCDF_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${NETCDF_INCLUDE_DIRS}"
+ INTERFACE_LINK_LIBRARIES "${NETCDF_LIBRARIES}")
+ endif()
+endif()
diff --git a/cmake/Modules/FindPNetCDF.cmake b/cmake/Modules/FindPNetCDF.cmake
index bc3a5f9538b17c82201437f3ee378e9be0bf49fa..e501e9af4920553f638fb12132f84e495dc9e959 100644
--- a/cmake/Modules/FindPNetCDF.cmake
+++ b/cmake/Modules/FindPNetCDF.cmake
@@ -53,3 +53,12 @@ include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (PNetCDF DEFAULT_MSG PNETCDF_LIBRARIES PNETCDF_INCLUDES)
mark_as_advanced (PNETCDF_LIBRARIES PNETCDF_INCLUDES)
+
+if(PNetCDF_FOUND)
+ if(NOT TARGET PNetCDF::PNetCDF)
+ add_library(PNetCDF::PNetCDF UNKNOWN IMPORTED)
+ set_target_properties(PNetCDF::PNetCDF PROPERTIES
+ IMPORTED_LOCATION "${PNETCDF_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${PNETCDF_INCLUDES}")
+ endif()
+endif()
diff --git a/cmake/Modules/FindQE.cmake b/cmake/Modules/FindQE.cmake
deleted file mode 100644
index 4484bd4db2ad11a65e68e9feb8b36077c2a9a074..0000000000000000000000000000000000000000
--- a/cmake/Modules/FindQE.cmake
+++ /dev/null
@@ -1,29 +0,0 @@
-# - Find quantum-espresso
-# Find the native QE headers and libraries.
-#
-# QE_INCLUDE_DIRS - where to find quantum-espresso.h, etc.
-# QE_LIBRARIES - List of libraries when using quantum-espresso.
-# QE_FOUND - True if quantum-espresso found.
-#
-
-find_path(QE_INCLUDE_DIR libqecouple.h PATH_SUFFIXES COUPLE/include)
-
-find_library(QECOUPLE_LIBRARY NAMES qecouple)
-find_library(PW_LIBRARY NAMES pw)
-find_library(QEMOD_LIBRARY NAMES qemod)
-find_library(QEFFT_LIBRARY NAMES qefft)
-find_library(QELA_LIBRARY NAMES qela)
-find_library(CLIB_LIBRARY NAMES clib)
-find_library(IOTK_LIBRARY NAMES iotk)
-
-
-set(QE_LIBRARIES ${QECOUPLE_LIBRARY} ${PW_LIBRARY} ${QEMOD_LIBRARY} ${QEFFT_LIBRARY} ${QELA_LIBRARY} ${CLIB_LIBRARY} ${IOTK_LIBRARY})
-set(QE_INCLUDE_DIRS ${QE_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set QE_FOUND to TRUE
-# if all listed variables are TRUE
-
-find_package_handle_standard_args(QE DEFAULT_MSG QECOUPLE_LIBRARY PW_LIBRARY QEMOD_LIBRARY QEFFT_LIBRARY QELA_LIBRARY CLIB_LIBRARY IOTK_LIBRARY QE_INCLUDE_DIR)
-
-mark_as_advanced(QE_INCLUDE_DIR QECOUPLE_LIBRARY PW_LIBRARY QEMOD_LIBRARY QEFFT_LIBRARY QELA_LIBRARY CLIB_LIBRARY IOTK_LIBRARY)
diff --git a/cmake/Modules/FindQUIP.cmake b/cmake/Modules/FindQUIP.cmake
index b6d87d11fa1cc82fd65452074a48e7469f5d39b4..277cfae49ed2a31b03a094c79a04a6d980e9a19d 100644
--- a/cmake/Modules/FindQUIP.cmake
+++ b/cmake/Modules/FindQUIP.cmake
@@ -7,12 +7,21 @@
find_library(QUIP_LIBRARY NAMES quip)
-set(QUIP_LIBRARIES ${QUIP_LIBRARY})
-
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set QUIP_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(QUIP DEFAULT_MSG QUIP_LIBRARY)
+# Copy the results to the output variables and target.
+if(QUIP_FOUND)
+ set(QUIP_LIBRARIES ${QUIP_LIBRARY})
+
+ if(NOT TARGET QUIP::QUIP)
+ add_library(QUIP::QUIP UNKNOWN IMPORTED)
+ set_target_properties(QUIP::QUIP PROPERTIES
+ IMPORTED_LOCATION "${QUIP_LIBRARY}")
+ endif()
+endif()
+
mark_as_advanced(QUIP_LIBRARY)
diff --git a/cmake/Modules/FindTBB.cmake b/cmake/Modules/FindTBB.cmake
deleted file mode 100644
index 8cc050817e6b919d3d77935afcd26f1fd4d1cce0..0000000000000000000000000000000000000000
--- a/cmake/Modules/FindTBB.cmake
+++ /dev/null
@@ -1,46 +0,0 @@
-# - Find parts of TBB
-# Find the native TBB headers and libraries.
-#
-# TBB_INCLUDE_DIRS - where to find tbb.h, etc.
-# TBB_LIBRARIES - List of libraries when using tbb.
-# TBB_FOUND - True if tbb found.
-#
-
-########################################################
-# TBB
-
-# TODO use more generic FindTBB
-
-find_path(TBB_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
-find_library(TBB_LIBRARY NAMES tbb PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
- $ENV{TBBROOT}/lib/intel64/gcc4.4
- $ENV{TBBROOT}/lib/intel64/gcc4.1)
-set(TBB_LIBRARIES ${TBB_LIBRARY})
-set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set TBB_FOUND to TRUE
-# if all listed variables are TRUE
-
-find_package_handle_standard_args(TBB DEFAULT_MSG TBB_LIBRARY TBB_INCLUDE_DIR)
-
-mark_as_advanced(TBB_INCLUDE_DIR TBB_LIBRARY )
-
-########################################################
-# TBB Malloc
-
-find_path(TBB_MALLOC_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
-find_library(TBB_MALLOC_LIBRARY NAMES tbbmalloc PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
- $ENV{TBBROOT}/lib/intel64/gcc4.4
- $ENV{TBBROOT}/lib/intel64/gcc4.1)
-
-set(TBB_MALLOC_LIBRARIES ${TBB_MALLOC_LIBRARY})
-set(TBB_MALLOC_INCLUDE_DIRS ${TBB_MALLOC_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set TBB_MALLOC_FOUND to TRUE
-# if all listed variables are TRUE
-
-find_package_handle_standard_args(TBB_MALLOC DEFAULT_MSG TBB_MALLOC_LIBRARY TBB_MALLOC_INCLUDE_DIR)
-
-mark_as_advanced(TBB_MALLOC_INCLUDE_DIR TBB_MALLOC_LIBRARY )
diff --git a/cmake/Modules/FindTBB_MALLOC.cmake b/cmake/Modules/FindTBB_MALLOC.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..896db649af75456c0f4bee348b572091b74e66f1
--- /dev/null
+++ b/cmake/Modules/FindTBB_MALLOC.cmake
@@ -0,0 +1,36 @@
+# - Find parts of TBB_MALLOC
+# Find the native TBB_MALLOC headers and libraries.
+#
+# TBB_MALLOC_INCLUDE_DIRS - where to find tbb.h, etc.
+# TBB_MALLOC_LIBRARIES - List of libraries when using tbb.
+# TBB_MALLOC_FOUND - True if tbb found.
+#
+
+
+########################################################
+# TBB Malloc
+
+find_path(TBB_MALLOC_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
+find_library(TBB_MALLOC_LIBRARY NAMES tbbmalloc PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
+ $ENV{TBBROOT}/lib/intel64/gcc4.4
+ $ENV{TBBROOT}/lib/intel64/gcc4.1)
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set TBB_MALLOC_FOUND to TRUE
+# if all listed variables are TRUE
+
+find_package_handle_standard_args(TBB_MALLOC DEFAULT_MSG TBB_MALLOC_LIBRARY TBB_MALLOC_INCLUDE_DIR)
+
+if(TBB_MALLOC_FOUND)
+ set(TBB_MALLOC_LIBRARIES ${TBB_MALLOC_LIBRARY})
+ set(TBB_MALLOC_INCLUDE_DIRS ${TBB_MALLOC_INCLUDE_DIR})
+
+ if(NOT TARGET TBB::TBB_MALLOC)
+ add_library(TBB::TBB_MALLOC UNKNOWN IMPORTED)
+ set_target_properties(TBB::TBB_MALLOC PROPERTIES
+ IMPORTED_LOCATION "${TBB_MALLOC_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${TBB_MALLOC_INCLUDE_DIR}")
+ endif()
+endif()
+
+mark_as_advanced(TBB_MALLOC_INCLUDE_DIR TBB_MALLOC_LIBRARY )
diff --git a/cmake/Modules/FindVORO.cmake b/cmake/Modules/FindVORO.cmake
index b0cccbcd1de79e30c9a18065654d141d9954844a..3f0fe98ff19bf67f684041d832a797d12adaab28 100644
--- a/cmake/Modules/FindVORO.cmake
+++ b/cmake/Modules/FindVORO.cmake
@@ -10,13 +10,23 @@ find_path(VORO_INCLUDE_DIR voro++.hh PATH_SUFFIXES voro++)
find_library(VORO_LIBRARY NAMES voro++)
-set(VORO_LIBRARIES ${VORO_LIBRARY})
-set(VORO_INCLUDE_DIRS ${VORO_INCLUDE_DIR})
-
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set VORO_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(VORO DEFAULT_MSG VORO_LIBRARY VORO_INCLUDE_DIR)
+# Copy the results to the output variables and target.
+if(VORO_FOUND)
+ set(VORO_LIBRARIES ${VORO_LIBRARY})
+ set(VORO_INCLUDE_DIRS ${VORO_INCLUDE_DIR})
+
+ if(NOT TARGET VORO::VORO)
+ add_library(VORO::VORO UNKNOWN IMPORTED)
+ set_target_properties(VORO::VORO PROPERTIES
+ IMPORTED_LOCATION "${VORO_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${VORO_INCLUDE_DIR}")
+ endif()
+endif()
+
mark_as_advanced(VORO_INCLUDE_DIR VORO_LIBRARY )
diff --git a/cmake/Modules/FindZMQ.cmake b/cmake/Modules/FindZMQ.cmake
index 608ccda777336f9d84dfabd40a9c6bdba1bd12be..7d612c2eb38d519c61cc95d0eb123309332e26a9 100644
--- a/cmake/Modules/FindZMQ.cmake
+++ b/cmake/Modules/FindZMQ.cmake
@@ -1,8 +1,19 @@
find_path(ZMQ_INCLUDE_DIR zmq.h)
find_library(ZMQ_LIBRARY NAMES zmq)
-set(ZMQ_LIBRARIES ${ZMQ_LIBRARY})
-set(ZMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR})
-
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZMQ DEFAULT_MSG ZMQ_LIBRARY ZMQ_INCLUDE_DIR)
+
+# Copy the results to the output variables and target.
+if(ZMQ_FOUND)
+ set(ZMQ_LIBRARIES ${ZMQ_LIBRARY})
+ set(ZMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR})
+
+ if(NOT TARGET ZMQ::ZMQ)
+ add_library(ZMQ::ZMQ UNKNOWN IMPORTED)
+ set_target_properties(ZMQ::ZMQ PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${ZMQ_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${ZMQ_INCLUDE_DIR}")
+ endif()
+endif()
diff --git a/cmake/Modules/GenerateBinaryHeader.cmake b/cmake/Modules/GenerateBinaryHeader.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..512f69e09de985b5ae70cb9bd8bfcb1b4bae0ca7
--- /dev/null
+++ b/cmake/Modules/GenerateBinaryHeader.cmake
@@ -0,0 +1,3 @@
+# utility script to call GenerateBinaryHeader function
+include(${SOURCE_DIR}/Modules/LAMMPSUtils.cmake)
+GenerateBinaryHeader(${VARNAME} ${HEADER_FILE} ${SOURCE_FILES})
diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake
index 3ea2b3cb7ec977175d026672c1a03f386fc86e61..02de630c82d320b67d144ea39eb30c1c44ed2c77 100644
--- a/cmake/Modules/LAMMPSUtils.cmake
+++ b/cmake/Modules/LAMMPSUtils.cmake
@@ -69,3 +69,19 @@ macro(pkg_depends PKG1 PKG2)
message(FATAL_ERROR "${PKG1} package needs LAMMPS to be build with ${PKG2}")
endif()
endmacro()
+
+# CMake-only replacement for bin2c and xxd
+function(GenerateBinaryHeader varname outfile files)
+ message("Creating ${outfile}...")
+ file(WRITE ${outfile} "// CMake generated file\n")
+ math(EXPR ARG_END "${ARGC}-1")
+
+ foreach(IDX RANGE 2 ${ARG_END})
+ list(GET ARGV ${IDX} filename)
+ file(READ ${filename} content HEX)
+ string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," content "${content}")
+ string(REGEX REPLACE ",$" "" content "${content}")
+ file(APPEND ${outfile} "const unsigned char ${varname}[] = { ${content} };\n")
+ file(APPEND ${outfile} "const unsigned int ${varname}_size = sizeof(${varname});\n")
+ endforeach()
+endfunction(GenerateBinaryHeader)
diff --git a/cmake/Modules/MPI4WIN.cmake b/cmake/Modules/MPI4WIN.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..035c6a22f3be44a597f674d281b61852964481ff
--- /dev/null
+++ b/cmake/Modules/MPI4WIN.cmake
@@ -0,0 +1,30 @@
+# Download and configure custom MPICH files for Windows
+message(STATUS "Downloading and configuring MPICH-1.4.1 for Windows")
+include(ExternalProject)
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ ExternalProject_Add(mpi4win_build
+ URL https://download.lammps.org/thirdparty/mpich2-win64-devel.tar.gz
+ URL_MD5 4939fdb59d13182fd5dd65211e469f14
+ CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
+ BUILD_BYPRODUCTS /lib/libmpi.a)
+else()
+ ExternalProject_Add(mpi4win_build
+ URL https://download.lammps.org/thirdparty/mpich2-win32-devel.tar.gz
+ URL_MD5 a61d153500dce44e21b755ee7257e031
+ CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
+ BUILD_BYPRODUCTS /lib/libmpi.a)
+endif()
+
+ExternalProject_get_property(mpi4win_build SOURCE_DIR)
+file(MAKE_DIRECTORY "${SOURCE_DIR}/include")
+add_library(MPI::MPI_CXX UNKNOWN IMPORTED)
+set_target_properties(MPI::MPI_CXX PROPERTIES
+ IMPORTED_LOCATION "${SOURCE_DIR}/lib/libmpi.a"
+ INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/include"
+ INTERFACE_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX")
+add_dependencies(MPI::MPI_CXX mpi4win_build)
+
+# set variables for status reporting at the end of CMake run
+set(MPI_CXX_INCLUDE_PATH "${SOURCE_DIR}/include")
+set(MPI_CXX_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX")
+set(MPI_CXX_LIBRARIES "${SOURCE_DIR}/lib/libmpi.a")
diff --git a/cmake/Modules/Packages/COMPRESS.cmake b/cmake/Modules/Packages/COMPRESS.cmake
index 864b868865f531ebcce5374bceed2612fb37d391..801a38a21561bde85fb2c031a96786043bd858b4 100644
--- a/cmake/Modules/Packages/COMPRESS.cmake
+++ b/cmake/Modules/Packages/COMPRESS.cmake
@@ -1,5 +1,2 @@
-if(PKG_COMPRESS)
- find_package(ZLIB REQUIRED)
- include_directories(${ZLIB_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS ${ZLIB_LIBRARIES})
-endif()
+find_package(ZLIB REQUIRED)
+target_link_libraries(lammps PRIVATE ZLIB::ZLIB)
diff --git a/cmake/Modules/Packages/CORESHELL.cmake b/cmake/Modules/Packages/CORESHELL.cmake
index 591477c89948c3d34f975e8cdf65181b96af9171..4e12d2ee363e80377fb7e8eb44a2f073c1317027 100644
--- a/cmake/Modules/Packages/CORESHELL.cmake
+++ b/cmake/Modules/Packages/CORESHELL.cmake
@@ -1,13 +1,11 @@
-if(PKG_CORESHELL)
- set(CORESHELL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/CORESHELL)
- set(CORESHELL_SOURCES)
- set_property(GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}")
+ set(CORESHELL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/CORESHELL)
+ set(CORESHELL_SOURCES)
+ set_property(GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}")
- # detects styles which have a CORESHELL version
- RegisterStylesExt(${CORESHELL_SOURCES_DIR} cs CORESHELL_SOURCES)
+ # detects styles which have a CORESHELL version
+ RegisterStylesExt(${CORESHELL_SOURCES_DIR} cs CORESHELL_SOURCES)
- get_property(CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES)
+ get_property(CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES)
- list(APPEND LIB_SOURCES ${CORESHELL_SOURCES})
- include_directories(${CORESHELL_SOURCES_DIR})
-endif()
+ target_sources(lammps PRIVATE ${CORESHELL_SOURCES})
+ target_include_directories(lammps PRIVATE ${CORESHELL_SOURCES_DIR})
diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake
index dab9d51a3f9eb823f09c05ac438546c64f05e9f1..9299914b9b39109d71966b6a15f931b767cbdaa3 100644
--- a/cmake/Modules/Packages/GPU.cmake
+++ b/cmake/Modules/Packages/GPU.cmake
@@ -1,194 +1,374 @@
-if(PKG_GPU)
- if (CMAKE_VERSION VERSION_LESS "3.1")
- message(FATAL_ERROR "For the GPU package you need at least cmake-3.1")
+set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU)
+set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h
+ ${GPU_SOURCES_DIR}/fix_gpu.h
+ ${GPU_SOURCES_DIR}/fix_gpu.cpp)
+
+set(GPU_API "opencl" CACHE STRING "API used by GPU package")
+set(GPU_API_VALUES opencl cuda hip)
+set_property(CACHE GPU_API PROPERTY STRINGS ${GPU_API_VALUES})
+validate_option(GPU_API GPU_API_VALUES)
+string(TOUPPER ${GPU_API} GPU_API)
+
+set(GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision")
+set(GPU_PREC_VALUES double mixed single)
+set_property(CACHE GPU_PREC PROPERTY STRINGS ${GPU_PREC_VALUES})
+validate_option(GPU_PREC GPU_PREC_VALUES)
+string(TOUPPER ${GPU_PREC} GPU_PREC)
+
+if(GPU_PREC STREQUAL "DOUBLE")
+ set(GPU_PREC_SETTING "DOUBLE_DOUBLE")
+elseif(GPU_PREC STREQUAL "MIXED")
+ set(GPU_PREC_SETTING "SINGLE_DOUBLE")
+elseif(GPU_PREC STREQUAL "SINGLE")
+ set(GPU_PREC_SETTING "SINGLE_SINGLE")
+endif()
+
+file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp)
+file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu)
+
+if(GPU_API STREQUAL "CUDA")
+ find_package(CUDA REQUIRED)
+ find_program(BIN2C bin2c)
+ if(NOT BIN2C)
+ message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.")
+ endif()
+ option(CUDPP_OPT "Enable CUDPP_OPT" ON)
+ option(CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF)
+ if(CUDA_MPS_SUPPORT)
+ set(GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY")
+ endif()
+
+ set(GPU_ARCH "sm_50" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)")
+
+ file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
+ list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
+
+ cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu)
+
+ if(CUDPP_OPT)
+ cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
+ file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp)
+ file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu)
+ endif()
+
+ # build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
+ # --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
+ set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH} ")
+ # Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
+ if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
+ string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
+ endif()
+ # Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
+ if(CUDA_VERSION VERSION_GREATER "4.9")
+ string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
+ endif()
+ # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
+ if(CUDA_VERSION VERSION_GREATER "5.9")
+ string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
+ endif()
+ # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
+ if(CUDA_VERSION VERSION_GREATER "7.9")
+ string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
+ endif()
+ # Volta (GPU Arch 7.0) is supported by CUDA 9 and later
+ if(CUDA_VERSION VERSION_GREATER "8.9")
+ string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
+ endif()
+ # Turing (GPU Arch 7.5) is supported by CUDA 10 and later
+ if(CUDA_VERSION VERSION_GREATER "9.9")
+ string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
+ endif()
+
+ cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS
+ -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
+
+ cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC}
+ -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
+
+ foreach(CU_OBJ ${GPU_GEN_OBJS})
+ get_filename_component(CU_NAME ${CU_OBJ} NAME_WE)
+ string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}")
+ add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
+ COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
+ DEPENDS ${CU_OBJ}
+ COMMENT "Generating ${CU_NAME}_cubin.h")
+ list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h)
+ endforeach()
+ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h")
+
+ add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS})
+ target_link_libraries(gpu PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
+ target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS})
+ target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS})
+ if(CUDPP_OPT)
+ target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
+ target_compile_definitions(gpu PRIVATE -DUSE_CUDPP)
+ endif()
+
+ target_link_libraries(lammps PRIVATE gpu)
+
+ add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
+ target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR)
+ target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
+ target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
+
+elseif(GPU_API STREQUAL "OPENCL")
+ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+ # download and unpack support binaries for compilation of windows binaries.
+ set(LAMMPS_THIRDPARTY_URL "http://download.lammps.org/thirdparty")
+ file(DOWNLOAD "${LAMMPS_THIRDPARTY_URL}/opencl-win-devel.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/opencl-win-devel.tar.gz"
+ EXPECTED_MD5 2c00364888d5671195598b44c2e0d44d)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf opencl-win-devel.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ add_library(OpenCL::OpenCL UNKNOWN IMPORTED)
+ if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
+ set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win32/libOpenCL.dll")
+ elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+ set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win64/libOpenCL.dll")
+ endif()
+ set_target_properties(OpenCL::OpenCL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/include")
+ else()
+ find_package(OpenCL REQUIRED)
+ endif()
+ set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning")
+ set(OCL_TUNE_VALUES intel fermi kepler cypress generic)
+ set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES})
+ validate_option(OCL_TUNE OCL_TUNE_VALUES)
+ string(TOUPPER ${OCL_TUNE} OCL_TUNE)
+
+ include(OpenCLUtils)
+ set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h)
+
+ file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu)
+ list(REMOVE_ITEM GPU_LIB_CU
+ ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu
+ ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu
+ ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu
+ ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu
+ ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu
+ ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu
+ ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu
+ )
+
+ foreach(GPU_KERNEL ${GPU_LIB_CU})
+ get_filename_component(basename ${GPU_KERNEL} NAME_WE)
+ string(SUBSTRING ${basename} 4 -1 KERNEL_NAME)
+ GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL})
+ list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h)
+ endforeach()
+
+ GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu)
+ GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu)
+ GenerateOpenCLHeader(re_squared ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu)
+ GenerateOpenCLHeader(re_squared_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu)
+ GenerateOpenCLHeader(tersoff ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu)
+ GenerateOpenCLHeader(tersoff_zbl ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu)
+ GenerateOpenCLHeader(tersoff_mod ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu)
+
+ list(APPEND GPU_LIB_SOURCES
+ ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h
+ ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h
+ ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h
+ ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h
+ ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h
+ ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h
+ ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h
+ )
+
+ add_library(gpu STATIC ${GPU_LIB_SOURCES})
+ target_link_libraries(gpu PRIVATE OpenCL::OpenCL)
+ target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu)
+ target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT)
+ target_compile_definitions(gpu PRIVATE -DUSE_OPENCL)
+
+ target_link_libraries(lammps PRIVATE gpu)
+
+ add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
+ target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL)
+ target_link_libraries(ocl_get_devices PRIVATE OpenCL::OpenCL)
+elseif(GPU_API STREQUAL "HIP")
+ if(NOT DEFINED HIP_PATH)
+ if(NOT DEFINED ENV{HIP_PATH})
+ set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
+ else()
+ set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
+ endif()
+ endif()
+ set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
+ find_package(HIP REQUIRED)
+ option(HIP_USE_DEVICE_SORT "Use GPU sorting" ON)
+
+ if(NOT DEFINED HIP_PLATFORM)
+ if(NOT DEFINED ENV{HIP_PLATFORM})
+ set(HIP_PLATFORM "hcc" CACHE PATH "HIP Platform to be used during compilation")
+ else()
+ set(HIP_PLATFORM $ENV{HIP_PLATFORM} CACHE PATH "HIP Platform used during compilation")
+ endif()
+ endif()
+
+ set(ENV{HIP_PLATFORM} ${HIP_PLATFORM})
+
+ if(HIP_PLATFORM STREQUAL "hcc")
+ set(HIP_ARCH "gfx906" CACHE STRING "HIP target architecture")
+ elseif(HIP_PLATFORM STREQUAL "nvcc")
+ find_package(CUDA REQUIRED)
+ set(HIP_ARCH "sm_50" CACHE STRING "HIP primary CUDA architecture (e.g. sm_60)")
+
+ # build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
+ # --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
+ set(HIP_CUDA_GENCODE "-arch=${HIP_ARCH} ")
+ # Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
+ if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
+ string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
+ endif()
+ # Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
+ if(CUDA_VERSION VERSION_GREATER "4.9")
+ string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
+ endif()
+ # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
+ if(CUDA_VERSION VERSION_GREATER "5.9")
+ string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
+ endif()
+ # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
+ if(CUDA_VERSION VERSION_GREATER "7.9")
+ string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
+ endif()
+ # Volta (GPU Arch 7.0) is supported by CUDA 9 and later
+ if(CUDA_VERSION VERSION_GREATER "8.9")
+ string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
+ endif()
+ # Turing (GPU Arch 7.5) is supported by CUDA 10 and later
+ if(CUDA_VERSION VERSION_GREATER "9.9")
+ string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
endif()
- set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU)
- set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h
- ${GPU_SOURCES_DIR}/fix_gpu.h
- ${GPU_SOURCES_DIR}/fix_gpu.cpp)
-
- set(GPU_API "opencl" CACHE STRING "API used by GPU package")
- set(GPU_API_VALUES opencl cuda)
- set_property(CACHE GPU_API PROPERTY STRINGS ${GPU_API_VALUES})
- validate_option(GPU_API GPU_API_VALUES)
- string(TOUPPER ${GPU_API} GPU_API)
-
- set(GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision")
- set(GPU_PREC_VALUES double mixed single)
- set_property(CACHE GPU_PREC PROPERTY STRINGS ${GPU_PREC_VALUES})
- validate_option(GPU_PREC GPU_PREC_VALUES)
- string(TOUPPER ${GPU_PREC} GPU_PREC)
-
- if(GPU_PREC STREQUAL "DOUBLE")
- set(GPU_PREC_SETTING "DOUBLE_DOUBLE")
- elseif(GPU_PREC STREQUAL "MIXED")
- set(GPU_PREC_SETTING "SINGLE_DOUBLE")
- elseif(GPU_PREC STREQUAL "SINGLE")
- set(GPU_PREC_SETTING "SINGLE_SINGLE")
+ endif()
+
+ file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
+ list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
+
+ set(GPU_LIB_CU_HIP "")
+ foreach(CU_FILE ${GPU_LIB_CU})
+ get_filename_component(CU_NAME ${CU_FILE} NAME_WE)
+ string(REGEX REPLACE "^.*lal_" "" CU_NAME "${CU_NAME}")
+
+ set(CU_CPP_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}.cu.cpp")
+ set(CUBIN_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}.cubin")
+ set(CUBIN_H_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h")
+
+ if(HIP_PLATFORM STREQUAL "hcc")
+ configure_file(${CU_FILE} ${CU_CPP_FILE} COPYONLY)
+
+ add_custom_command(OUTPUT ${CUBIN_FILE}
+ VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --genco -t="${HIP_ARCH}" -f=\"-O3 -ffast-math -DUSE_HIP -D_${GPU_PREC_SETTING} -I${LAMMPS_LIB_SOURCE_DIR}/gpu\" -o ${CUBIN_FILE} ${CU_CPP_FILE}
+ DEPENDS ${CU_CPP_FILE}
+ COMMENT "Generating ${CU_NAME}.cubin")
+ elseif(HIP_PLATFORM STREQUAL "nvcc")
+ add_custom_command(OUTPUT ${CUBIN_FILE}
+ VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --fatbin --use_fast_math -DUSE_HIP -D_${GPU_PREC_SETTING} ${HIP_CUDA_GENCODE} -I${LAMMPS_LIB_SOURCE_DIR}/gpu -o ${CUBIN_FILE} ${CU_FILE}
+ DEPENDS ${CU_FILE}
+ COMMENT "Generating ${CU_NAME}.cubin")
endif()
- file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp)
- file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu)
+ add_custom_command(OUTPUT ${CUBIN_H_FILE}
+ COMMAND ${CMAKE_COMMAND} -D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -D VARNAME=${CU_NAME} -D HEADER_FILE=${CUBIN_H_FILE} -D SOURCE_FILES=${CUBIN_FILE} -P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/GenerateBinaryHeader.cmake
+ DEPENDS ${CUBIN_FILE}
+ COMMENT "Generating ${CU_NAME}_cubin.h")
- if(GPU_API STREQUAL "CUDA")
- find_package(CUDA REQUIRED)
- find_program(BIN2C bin2c)
- if(NOT BIN2C)
- message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.")
- endif()
- option(CUDPP_OPT "Enable CUDPP_OPT" ON)
- option(CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF)
- if(CUDA_MPS_SUPPORT)
- set(GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY")
- endif()
+ list(APPEND GPU_LIB_SOURCES ${CUBIN_H_FILE})
+ endforeach()
- set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)")
+ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h ${LAMMPS_LIB_BINARY_DIR}/gpu/*.cu.cpp")
- file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
- list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
+ hip_add_library(gpu STATIC ${GPU_LIB_SOURCES})
+ target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu)
+ target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT)
+ target_compile_definitions(gpu PRIVATE -DUSE_HIP)
- cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu)
+ if(HIP_USE_DEVICE_SORT)
+ # add hipCUB
+ target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include)
+ target_compile_definitions(gpu PRIVATE -DUSE_HIP_DEVICE_SORT)
- if(CUDPP_OPT)
- cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
- file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp)
- file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu)
- endif()
+ if(HIP_PLATFORM STREQUAL "nvcc")
+ find_package(CUB)
- # build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
- # --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
- set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH} ")
- # Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
- if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
- string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
- endif()
- # Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
- if(CUDA_VERSION VERSION_GREATER "4.9")
- string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
- endif()
- # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
- if(CUDA_VERSION VERSION_GREATER "5.9")
- string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
- endif()
- # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
- if(CUDA_VERSION VERSION_GREATER "7.9")
- string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
- endif()
- # Volta (GPU Arch 7.0) is supported by CUDA 9 and later
- if(CUDA_VERSION VERSION_GREATER "8.9")
- string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
- endif()
- # Turing (GPU Arch 7.5) is supported by CUDA 10 and later
- if(CUDA_VERSION VERSION_GREATER "9.9")
- string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
+ if(CUB_FOUND)
+ set(DOWNLOAD_CUB_DEFAULT OFF)
+ else()
+ set(DOWNLOAD_CUB_DEFAULT ON)
endif()
- cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS
- -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
-
- cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC}
- -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
-
- foreach(CU_OBJ ${GPU_GEN_OBJS})
- get_filename_component(CU_NAME ${CU_OBJ} NAME_WE)
- string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}")
- add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
- COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
- DEPENDS ${CU_OBJ}
- COMMENT "Generating ${CU_NAME}_cubin.h")
- list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h)
- endforeach()
- set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h")
-
-
- add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS})
- target_link_libraries(gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
- target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS})
- target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS})
- if(CUDPP_OPT)
- target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
- target_compile_definitions(gpu PRIVATE -DUSE_CUDPP)
+ option(DOWNLOAD_CUB "Download and compile the CUB library instead of using an already installed one" ${DOWNLOAD_CUB_DEFAULT})
+
+ if(DOWNLOAD_CUB)
+ message(STATUS "CUB download requested")
+ include(ExternalProject)
+
+ ExternalProject_Add(CUB
+ GIT_REPOSITORY https://github.com/NVlabs/cub
+ TIMEOUT 5
+ PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ UPDATE_COMMAND ""
+ )
+ ExternalProject_get_property(CUB SOURCE_DIR)
+ set(CUB_INCLUDE_DIR ${SOURCE_DIR})
+ else()
+ find_package(CUB)
+ if(NOT CUB_FOUND)
+ message(FATAL_ERROR "CUB library not found. Help CMake to find it by setting CUB_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it")
+ endif()
endif()
- list(APPEND LAMMPS_LINK_LIBS gpu)
-
- add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
- target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR)
- target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
- target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
-
-
- elseif(GPU_API STREQUAL "OPENCL")
- find_package(OpenCL REQUIRED)
- set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning")
- set(OCL_TUNE_VALUES intel fermi kepler cypress generic)
- set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES})
- validate_option(OCL_TUNE OCL_TUNE_VALUES)
- string(TOUPPER ${OCL_TUNE} OCL_TUNE)
-
- include(OpenCLUtils)
- set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h)
-
- file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu)
- list(REMOVE_ITEM GPU_LIB_CU
- ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu
- ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu
- ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu
- ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu
- ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu
- ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu
- ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu
- )
-
- foreach(GPU_KERNEL ${GPU_LIB_CU})
- get_filename_component(basename ${GPU_KERNEL} NAME_WE)
- string(SUBSTRING ${basename} 4 -1 KERNEL_NAME)
- GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL})
- list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h)
- endforeach()
-
- GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu)
- GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu)
- GenerateOpenCLHeader(re_squared ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu)
- GenerateOpenCLHeader(re_squared_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu)
- GenerateOpenCLHeader(tersoff ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu)
- GenerateOpenCLHeader(tersoff_zbl ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu)
- GenerateOpenCLHeader(tersoff_mod ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu)
-
- list(APPEND GPU_LIB_SOURCES
- ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h
- ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h
- ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h
- ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h
- ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h
- ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h
- ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h
- )
-
- add_library(gpu STATIC ${GPU_LIB_SOURCES})
- target_link_libraries(gpu ${OpenCL_LIBRARIES})
- target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu ${OpenCL_INCLUDE_DIRS})
- target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT)
- target_compile_definitions(gpu PRIVATE -DUSE_OPENCL)
-
- list(APPEND LAMMPS_LINK_LIBS gpu)
-
- add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
- target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL)
- target_link_libraries(ocl_get_devices PRIVATE ${OpenCL_LIBRARIES})
- target_include_directories(ocl_get_devices PRIVATE ${OpenCL_INCLUDE_DIRS})
+ target_include_directories(gpu PRIVATE ${CUB_INCLUDE_DIR})
endif()
+ endif()
+
+ hip_add_executable(hip_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
+ target_compile_definitions(hip_get_devices PRIVATE -DUCL_HIP)
+
+ if(HIP_PLATFORM STREQUAL "nvcc")
+ target_compile_definitions(gpu PRIVATE -D__HIP_PLATFORM_NVCC__)
+ target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include)
+ target_include_directories(gpu PRIVATE ${CUDA_INCLUDE_DIRS})
+ target_link_libraries(gpu PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
+
+ target_compile_definitions(hip_get_devices PRIVATE -D__HIP_PLATFORM_NVCC__)
+ target_include_directories(hip_get_devices PRIVATE ${HIP_ROOT_DIR}/include)
+ target_include_directories(hip_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
+ target_link_libraries(hip_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
+ elseif(HIP_PLATFORM STREQUAL "hcc")
+ target_compile_definitions(gpu PRIVATE -D__HIP_PLATFORM_HCC__)
+ target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include)
+
+ target_compile_definitions(hip_get_devices PRIVATE -D__HIP_PLATFORM_HCC__)
+ target_include_directories(hip_get_devices PRIVATE ${HIP_ROOT_DIR}/../include)
+ endif()
+
+ target_link_libraries(lammps PRIVATE gpu)
+endif()
- # GPU package
- FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX)
+# GPU package
+FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX)
- set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}")
+set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}")
- # detects styles which have GPU version
- RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES)
+# detects styles which have GPU version
+RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES)
- get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES)
+get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES)
- list(APPEND LIB_SOURCES ${GPU_SOURCES})
- include_directories(${GPU_SOURCES_DIR})
+if(NOT BUILD_MPI)
+ # mpistubs is aliased to MPI::MPI_CXX, but older versions of cmake won't work forward the include path
+ target_link_libraries(gpu PRIVATE mpi_stubs)
+else()
+ target_link_libraries(gpu PRIVATE MPI::MPI_CXX)
+endif()
+if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS gpu EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
+target_compile_definitions(gpu PRIVATE -DLAMMPS_${LAMMPS_SIZES})
+set_target_properties(gpu PROPERTIES OUTPUT_NAME lammps_gpu${LAMMPS_MACHINE})
+target_sources(lammps PRIVATE ${GPU_SOURCES})
+target_include_directories(lammps PRIVATE ${GPU_SOURCES_DIR})
diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake
index a75e248097c670957bcf91419b7c2db24582002f..278a6b5afc19a6e45e761e9931a15c5e80b74e77 100644
--- a/cmake/Modules/Packages/KIM.cmake
+++ b/cmake/Modules/Packages/KIM.cmake
@@ -1,67 +1,66 @@
-if(PKG_KIM)
- set(KIM-API_MIN_VERSION 2.1)
- find_package(CURL)
- if(CURL_FOUND)
- include_directories(${CURL_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS ${CURL_LIBRARIES})
- add_definitions(-DLMP_KIM_CURL)
- set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.")
- mark_as_advanced(LMP_DEBUG_CURL)
- if(LMP_DEBUG_CURL)
- add_definitions(-DLMP_DEBUG_CURL)
- endif()
- set(LMP_NO_SSL_CHECK OFF CACHE STRING "Tell libcurl to not verify the peer. If on, the connection succeeds regardless of the names in the certificate. Insecure - Use with caution!")
- mark_as_advanced(LMP_NO_SSL_CHECK)
- if(LMP_NO_SSL_CHECK)
- add_definitions(-DLMP_NO_SSL_CHECK)
- endif()
+set(KIM-API_MIN_VERSION 2.1.3)
+find_package(CURL)
+if(CURL_FOUND)
+ if(CMAKE_VERSION VERSION_LESS 3.12)
+ target_include_directories(lammps PRIVATE ${CURL_INCLUDE_DIRS})
+ target_link_libraries(lammps PRIVATE ${CURL_LIBRARIES})
+ else()
+ target_link_libraries(lammps PRIVATE CURL::libcurl)
+ endif()
+ target_compile_definitions(lammps PRIVATE -DLMP_KIM_CURL)
+ set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.")
+ mark_as_advanced(LMP_DEBUG_CURL)
+ if(LMP_DEBUG_CURL)
+ target_compile_definitions(lammps PRIVATE -DLMP_DEBUG_CURL)
endif()
- find_package(KIM-API QUIET)
+ set(LMP_NO_SSL_CHECK OFF CACHE STRING "Tell libcurl to not verify the peer. If on, the connection succeeds regardless of the names in the certificate. Insecure - Use with caution!")
+ mark_as_advanced(LMP_NO_SSL_CHECK)
+ if(LMP_NO_SSL_CHECK)
+ target_compile_definitions(lammps PRIVATE -DLMP_NO_SSL_CHECK)
+ endif()
+endif()
+find_package(PkgConfig QUIET)
+set(DOWNLOAD_KIM_DEFAULT ON)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(KIM-API QUIET libkim-api>=${KIM-API_MIN_VERSION})
if(KIM-API_FOUND)
- if (KIM-API_VERSION VERSION_LESS ${KIM-API_MIN_VERSION})
- if ("${DOWNLOAD_KIM}" STREQUAL "")
- message(WARNING "Unsuitable KIM-API version \"${KIM-API_VERSION}\" found, but required is at least \"${KIM-API_MIN_VERSION}\". Default behavior set to download and build our own.")
- endif()
- set(DOWNLOAD_KIM_DEFAULT ON)
- else()
- set(DOWNLOAD_KIM_DEFAULT OFF)
- endif()
- else()
- if ("${DOWNLOAD_KIM}" STREQUAL "")
- message(WARNING "KIM-API package not found. Default behavior set to download and build our own")
- endif()
- set(DOWNLOAD_KIM_DEFAULT ON)
+ set(DOWNLOAD_KIM_DEFAULT OFF)
endif()
- option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT})
- if(DOWNLOAD_KIM)
- if(CMAKE_GENERATOR STREQUAL "Ninja")
- message(FATAL_ERROR "Cannot build downloaded KIM-API library with Ninja build tool")
- endif()
- message(STATUS "KIM-API download requested - we will build our own")
- include(CheckLanguage)
- include(ExternalProject)
- enable_language(C)
- check_language(Fortran)
- if(NOT CMAKE_Fortran_COMPILER)
- message(FATAL_ERROR "Compiling the KIM-API library requires a Fortran compiler")
- endif()
- ExternalProject_Add(kim_build
- URL https://s3.openkim.org/kim-api/kim-api-2.1.3.txz
- URL_MD5 6ee829a1bbba5f8b9874c88c4c4ebff8
- BINARY_DIR build
- CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
- -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
- -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
- -DCMAKE_INSTALL_PREFIX=
- -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- )
- ExternalProject_get_property(kim_build INSTALL_DIR)
- set(KIM-API_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api)
- set(KIM-API_LDFLAGS ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX})
- list(APPEND LAMMPS_DEPS kim_build)
- else()
- find_package(KIM-API ${KIM-API_MIN_VERSION} REQUIRED)
+endif()
+option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT})
+if(DOWNLOAD_KIM)
+ message(STATUS "KIM-API download requested - we will build our own")
+ include(ExternalProject)
+ enable_language(C)
+ enable_language(Fortran)
+ ExternalProject_Add(kim_build
+ URL https://s3.openkim.org/kim-api/kim-api-2.1.3.txz
+ URL_MD5 6ee829a1bbba5f8b9874c88c4c4ebff8
+ BINARY_DIR build
+ CMAKE_ARGS ${CMAKE_REQUEST_PIC}
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
+ -DCMAKE_INSTALL_LIBDIR=lib
+ -DCMAKE_INSTALL_PREFIX=
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
+ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+ BUILD_BYPRODUCTS /lib/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}
+ )
+ ExternalProject_get_property(kim_build INSTALL_DIR)
+ file(MAKE_DIRECTORY ${INSTALL_DIR}/include/kim-api)
+ add_library(LAMMPS::KIM UNKNOWN IMPORTED)
+ set_target_properties(LAMMPS::KIM PROPERTIES
+ IMPORTED_LOCATION "${INSTALL_DIR}/lib/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}"
+ INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include/kim-api")
+ target_link_libraries(lammps PRIVATE LAMMPS::KIM)
+ add_dependencies(LAMMPS::KIM kim_build)
+ if(NOT BUILD_SHARED_LIBS)
+ install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
- list(APPEND LAMMPS_LINK_LIBS "${KIM-API_LDFLAGS}")
- include_directories(${KIM-API_INCLUDE_DIRS})
+else()
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=${KIM-API_MIN_VERSION})
+ target_link_libraries(lammps PRIVATE PkgConfig::KIM-API)
endif()
diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake
index 428588ec9d06e860f3535cf6b8de619fc896a67d..eb549519d171f89f826b4f14c05d1fa88767a67e 100644
--- a/cmake/Modules/Packages/KOKKOS.cmake
+++ b/cmake/Modules/Packages/KOKKOS.cmake
@@ -1,66 +1,125 @@
-if(PKG_KOKKOS)
- # TODO: this option needs to be documented when this works with a
- # regular release version of KOKKOS, and a version compatibility check
- # of external KOKKOS lib versus what the KOKKOS package needs is required.
- option(EXTERNAL_KOKKOS "Build against external kokkos library")
- if(EXTERNAL_KOKKOS)
- find_package(Kokkos REQUIRED)
- list(APPEND LAMMPS_LINK_LIBS Kokkos::kokkos)
- else()
- set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
- set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
- add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
-
- set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src
- ${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src
- ${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src
- ${LAMMPS_LIB_KOKKOS_BIN_DIR})
- include_directories(${Kokkos_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS kokkos)
+########################################################################
+# consistency checks and Kokkos options/settings required by LAMMPS
+if(Kokkos_ENABLE_CUDA)
+ message(STATUS "KOKKOS: Enabling CUDA LAMBDA function support")
+ set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "" FORCE)
+endif()
+# Adding OpenMP compiler flags without the checks done for
+# BUILD_OMP can result in compile failures. Enforce consistency.
+if(Kokkos_ENABLE_OPENMP AND NOT BUILD_OMP)
+ message(FATAL_ERROR "Must enable BUILD_OMP with Kokkos_ENABLE_OPENMP")
+endif()
+########################################################################
+
+option(EXTERNAL_KOKKOS "Build against external kokkos library" OFF)
+option(DOWNLOAD_KOKKOS "Download the KOKKOS library instead of using the bundled one" OFF)
+if(DOWNLOAD_KOKKOS)
+ # extract Kokkos-related variables and values so we can forward them to the Kokkos library build
+ get_cmake_property(_VARS VARIABLES)
+ list(FILTER _VARS INCLUDE REGEX ^Kokkos_)
+ foreach(_VAR IN LISTS _VARS)
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-D${_VAR}=${${_VAR}}")
+ endforeach()
+ message(STATUS "KOKKOS download requested - we will build our own")
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_INSTALL_PREFIX=")
+ if(CMAKE_REQUEST_PIC)
+ list(APPEND KOKKOS_LIB_BUILD_ARGS ${CMAKE_REQUEST_PIC})
+ endif()
+ # append other CMake variables that need to be forwarded to CMAKE_ARGS
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_INSTALL_LIBDIR=lib")
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}")
+ list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
+ include(ExternalProject)
+ ExternalProject_Add(kokkos_build
+ URL https://github.com/kokkos/kokkos/archive/3.1.00.tar.gz
+ URL_MD5 f638a6c786f748a602b26faa0e96ebab
+ CMAKE_ARGS ${KOKKOS_LIB_BUILD_ARGS}
+ BUILD_BYPRODUCTS /lib/libkokkoscore.a
+ )
+ ExternalProject_get_property(kokkos_build INSTALL_DIR)
+ file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
+ add_library(LAMMPS::KOKKOS UNKNOWN IMPORTED)
+ set_target_properties(LAMMPS::KOKKOS PROPERTIES
+ IMPORTED_LOCATION "${INSTALL_DIR}/lib/libkokkoscore.a"
+ INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include"
+ INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
+ target_link_libraries(lammps PRIVATE LAMMPS::KOKKOS)
+ add_dependencies(LAMMPS::KOKKOS kokkos_build)
+ if(NOT BUILD_SHARED_LIBS)
+ install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
- add_definitions(-DLMP_KOKKOS)
+elseif(EXTERNAL_KOKKOS)
+ find_package(Kokkos 3.1)
+ if(NOT Kokkos_FOUND)
+ message(FATAL_ERROR "KOKKOS library version 3.1 or later not found, help CMake to find it by setting KOKKOS_LIBRARY, or set DOWNLOAD_KOKKOS=ON to download it")
+ endif()
+ target_link_libraries(lammps PRIVATE Kokkos::kokkos)
+else()
+ set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
+ set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
+ add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
- set(KOKKOS_PKG_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/KOKKOS)
- set(KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/atom_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/atom_vec_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/comm_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/comm_tiled_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/min_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/min_linesearch_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/neighbor_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/neigh_list_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/neigh_bond_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/fix_nh_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/domain_kokkos.cpp
- ${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp)
+ set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src
+ ${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src
+ ${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src
+ ${LAMMPS_LIB_KOKKOS_BIN_DIR})
+ target_include_directories(lammps PRIVATE ${Kokkos_INCLUDE_DIRS})
+ target_link_libraries(lammps PRIVATE kokkos)
+endif()
+target_compile_definitions(lammps PRIVATE -DLMP_KOKKOS)
- if(PKG_KSPACE)
- list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp)
- endif()
+set(KOKKOS_PKG_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/KOKKOS)
+set(KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/atom_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/atom_vec_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/comm_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/comm_tiled_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/min_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/min_linesearch_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/neighbor_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/neigh_list_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/neigh_bond_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/fix_nh_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/domain_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp)
- set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
+if(PKG_KSPACE)
+ list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/fft3d_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp
+ ${KOKKOS_PKG_SOURCES_DIR}/remap_kokkos.cpp)
+ if(Kokkos_ENABLE_CUDA)
+ if(NOT ${FFT} STREQUAL "KISS")
+ target_compile_definitions(lammps PRIVATE -DFFT_CUFFT)
+ target_link_libraries(lammps PRIVATE cufft)
+ endif()
+ endif()
+endif()
- # detects styles which have KOKKOS version
- RegisterStylesExt(${KOKKOS_PKG_SOURCES_DIR} kokkos KOKKOS_PKG_SOURCES)
+set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
- # register kokkos-only styles
- RegisterNBinStyle(${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.h)
- RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.h)
- RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.h)
+# detects styles which have KOKKOS version
+RegisterStylesExt(${KOKKOS_PKG_SOURCES_DIR} kokkos KOKKOS_PKG_SOURCES)
- if(PKG_USER-DPD)
- get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
- list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.cpp)
- RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.h)
- set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
- endif()
+# register kokkos-only styles
+RegisterNBinStyle(${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.h)
+RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.h)
+RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.h)
+if(PKG_USER-DPD)
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
-
- list(APPEND LIB_SOURCES ${KOKKOS_PKG_SOURCES})
- include_directories(${KOKKOS_PKG_SOURCES_DIR})
+ list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.cpp)
+ RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.h)
+ set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
endif()
+
+get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
+
+target_sources(lammps PRIVATE ${KOKKOS_PKG_SOURCES})
+target_include_directories(lammps PRIVATE ${KOKKOS_PKG_SOURCES_DIR})
diff --git a/cmake/Modules/Packages/KSPACE.cmake b/cmake/Modules/Packages/KSPACE.cmake
index 63c42baf2d5c0bb17fce96f85dfc99fe84b6eede..dce0c15ef60a0eab19600ee616e87c7ac0a04dac 100644
--- a/cmake/Modules/Packages/KSPACE.cmake
+++ b/cmake/Modules/Packages/KSPACE.cmake
@@ -1,42 +1,56 @@
-if(PKG_KSPACE)
- option(FFT_SINGLE "Use single precision FFTs instead of double precision FFTs" OFF)
- set(FFTW "FFTW3")
- if(FFT_SINGLE)
- set(FFTW "FFTW3F")
- add_definitions(-DFFT_SINGLE)
- endif()
- find_package(${FFTW} QUIET)
- if(${FFTW}_FOUND)
- set(FFT "FFTW3" CACHE STRING "FFT library for KSPACE package")
- else()
- set(FFT "KISS" CACHE STRING "FFT library for KSPACE package")
- endif()
- set(FFT_VALUES KISS FFTW3 MKL)
- set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES})
- validate_option(FFT FFT_VALUES)
- string(TOUPPER ${FFT} FFT)
+option(FFT_SINGLE "Use single precision FFTs instead of double precision FFTs" OFF)
+set(FFTW "FFTW3")
+if(FFT_SINGLE)
+ set(FFTW "FFTW3F")
+ target_compile_definitions(lammps PUBLIC -DFFT_SINGLE)
+endif()
+find_package(${FFTW} QUIET)
+if(${FFTW}_FOUND)
+ set(FFT "FFTW3" CACHE STRING "FFT library for KSPACE package")
+else()
+ set(FFT "KISS" CACHE STRING "FFT library for KSPACE package")
+endif()
+set(FFT_VALUES KISS FFTW3 MKL)
+set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES})
+validate_option(FFT FFT_VALUES)
+string(TOUPPER ${FFT} FFT)
- if(FFT STREQUAL "FFTW3")
- find_package(${FFTW} REQUIRED)
- add_definitions(-DFFT_FFTW3)
- include_directories(${${FFTW}_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS ${${FFTW}_LIBRARIES})
- elseif(FFT STREQUAL "MKL")
- find_package(MKL REQUIRED)
- add_definitions(-DFFT_MKL)
- include_directories(${MKL_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES})
+if(FFT STREQUAL "FFTW3")
+ find_package(${FFTW} REQUIRED)
+ target_compile_definitions(lammps PUBLIC -DFFT_FFTW3)
+ target_link_libraries(lammps PUBLIC ${FFTW}::${FFTW})
+ if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
+ option(FFT_FFTW_THREADS "Use threaded FFTW library" ON)
else()
- # last option is KISSFFT
- add_definitions(-DFFT_KISS)
+ option(FFT_FFTW_THREADS "Use threaded FFT library" OFF)
endif()
- set(FFT_PACK "array" CACHE STRING "Optimization for FFT")
- set(FFT_PACK_VALUES array pointer memcpy)
- set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES})
- validate_option(FFT_PACK FFT_PACK_VALUES)
- if(NOT FFT_PACK STREQUAL "array")
- string(TOUPPER ${FFT_PACK} FFT_PACK)
- add_definitions(-DFFT_PACK_${FFT_PACK})
+ if(FFT_FFTW_THREADS)
+ if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
+ target_compile_definitions(lammps PRIVATE -DFFT_FFTW_THREADS)
+ target_link_libraries(lammps PRIVATE ${FFTW}::${FFTW}_OMP)
+ else()
+ message(FATAL_ERROR "Need OpenMP enabled FFTW3 library for FFT_THREADS")
+ endif()
+ endif()
+elseif(FFT STREQUAL "MKL")
+ find_package(MKL REQUIRED)
+ target_compile_definitions(lammps PRIVATE -DFFT_MKL)
+ option(FFT_MKL_THREADS "Use threaded MKL FFT" ON)
+ if(FFT_MKL_THREADS)
+ target_compile_definitions(lammps PRIVATE -DFFT_MKL_THREADS)
endif()
+ target_link_libraries(lammps PRIVATE MKL::MKL)
+else()
+ # last option is KISSFFT
+ target_compile_definitions(lammps PRIVATE -DFFT_KISS)
+endif()
+
+set(FFT_PACK "array" CACHE STRING "Optimization for FFT")
+set(FFT_PACK_VALUES array pointer memcpy)
+set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES})
+validate_option(FFT_PACK FFT_PACK_VALUES)
+if(NOT FFT_PACK STREQUAL "array")
+ string(TOUPPER ${FFT_PACK} FFT_PACK)
+ target_compile_definitions(lammps PRIVATE -DFFT_PACK_${FFT_PACK})
endif()
diff --git a/cmake/Modules/Packages/LATTE.cmake b/cmake/Modules/Packages/LATTE.cmake
index de7116780bfe262faeebecfebea3a465c9a7f4de..a2a94755ab0eec34f676b00476dfd47eb22cfd4a 100644
--- a/cmake/Modules/Packages/LATTE.cmake
+++ b/cmake/Modules/Packages/LATTE.cmake
@@ -1,38 +1,47 @@
-if(PKG_LATTE)
- enable_language(Fortran)
- find_package(LATTE)
- if(LATTE_FOUND)
- set(DOWNLOAD_LATTE_DEFAULT OFF)
- else()
- set(DOWNLOAD_LATTE_DEFAULT ON)
+enable_language(Fortran)
+
+# using lammps in a super-build setting
+if(TARGET LATTE::latte)
+ target_link_libraries(lammps PRIVATE LATTE::latte)
+ return()
+endif()
+
+find_package(LATTE)
+if(LATTE_FOUND)
+ set(DOWNLOAD_LATTE_DEFAULT OFF)
+else()
+ set(DOWNLOAD_LATTE_DEFAULT ON)
+endif()
+option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
+if(DOWNLOAD_LATTE)
+ message(STATUS "LATTE download requested - we will build our own")
+ include(ExternalProject)
+ ExternalProject_Add(latte_build
+ URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz
+ URL_MD5 85ac414fdada2d04619c8f936344df14
+ SOURCE_SUBDIR cmake
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC} -DCMAKE_INSTALL_LIBDIR=lib
+ -DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
+ -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}
+ -DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+ BUILD_BYPRODUCTS /lib/liblatte.a
+ )
+ ExternalProject_get_property(latte_build INSTALL_DIR)
+ add_library(LAMMPS::LATTE UNKNOWN IMPORTED)
+ set_target_properties(LAMMPS::LATTE PROPERTIES
+ IMPORTED_LOCATION "${INSTALL_DIR}/lib/liblatte.a"
+ INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}")
+ target_link_libraries(lammps PRIVATE LAMMPS::LATTE)
+ add_dependencies(LAMMPS::LATTE latte_build)
+ if(NOT BUILD_SHARED_LIBS)
+ install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
- option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
- if(DOWNLOAD_LATTE)
- if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR
- message(FATAL_ERROR "For downlading LATTE you need at least cmake-3.7")
- endif()
- if(CMAKE_GENERATOR STREQUAL "Ninja")
- message(FATAL_ERROR "Cannot build downloaded LATTE library with Ninja build tool")
- endif()
- message(STATUS "LATTE download requested - we will build our own")
- include(ExternalProject)
- ExternalProject_Add(latte_build
- URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz
- URL_MD5 85ac414fdada2d04619c8f936344df14
- SOURCE_SUBDIR cmake
- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC}
- -DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
- -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}
- -DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- )
- ExternalProject_get_property(latte_build INSTALL_DIR)
- set(LATTE_LIBRARIES ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/liblatte.a)
- list(APPEND LAMMPS_DEPS latte_build)
- else()
- find_package(LATTE)
- if(NOT LATTE_FOUND)
- message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it")
- endif()
+else()
+ find_package(LATTE)
+ if(NOT LATTE_FOUND)
+ message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it")
endif()
- list(APPEND LAMMPS_LINK_LIBS ${LATTE_LIBRARIES} ${LAPACK_LIBRARIES})
+ # latte needs lapack
+ target_link_libraries(lammps PRIVATE LATTE::latte ${LAPACK_LIBRARIES})
endif()
diff --git a/cmake/Modules/Packages/MESSAGE.cmake b/cmake/Modules/Packages/MESSAGE.cmake
index aff9c2964adecf9088dcd1e23463f1fc36bb7bc9..e1dc4c107236e63e5a5e4ab8b77af1bae1e4b679 100644
--- a/cmake/Modules/Packages/MESSAGE.cmake
+++ b/cmake/Modules/Packages/MESSAGE.cmake
@@ -1,32 +1,35 @@
-if(PKG_MESSAGE)
- if(LAMMPS_SIZES STREQUAL BIGBIG)
- message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG")
- endif()
- option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
- file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F
- ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c
- ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp)
-
- add_library(cslib STATIC ${cslib_SOURCES})
- if(BUILD_MPI)
- target_compile_definitions(cslib PRIVATE -DMPI_YES)
- set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi")
- else()
- target_compile_definitions(cslib PRIVATE -DMPI_NO)
- target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI)
- set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi")
- endif()
+if(LAMMPS_SIZES STREQUAL BIGBIG)
+ message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG")
+endif()
+option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
+file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F
+ ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c
+ ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp)
- if(MESSAGE_ZMQ)
- target_compile_definitions(cslib PRIVATE -DZMQ_YES)
- find_package(ZMQ REQUIRED)
- target_include_directories(cslib PRIVATE ${ZMQ_INCLUDE_DIRS})
- target_link_libraries(cslib PUBLIC ${ZMQ_LIBRARIES})
- else()
- target_compile_definitions(cslib PRIVATE -DZMQ_NO)
- target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ)
- endif()
+add_library(cslib STATIC ${cslib_SOURCES})
+if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS cslib EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+endif()
+target_compile_definitions(cslib PRIVATE -DLAMMPS_${LAMMPS_SIZES})
+set_target_properties(cslib PROPERTIES OUTPUT_NAME lammps_cslib${LAMMPS_MACHINE})
+if(BUILD_MPI)
+ target_compile_definitions(cslib PRIVATE -DMPI_YES)
+ set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi")
+ target_link_libraries(cslib PRIVATE MPI::MPI_CXX)
+else()
+ target_compile_definitions(cslib PRIVATE -DMPI_NO)
+ target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI)
+ set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi")
+endif()
- list(APPEND LAMMPS_LINK_LIBS cslib)
- include_directories(${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src)
+if(MESSAGE_ZMQ)
+ target_compile_definitions(cslib PRIVATE -DZMQ_YES)
+ find_package(ZMQ REQUIRED)
+ target_link_libraries(cslib PUBLIC ZMQ::ZMQ)
+else()
+ target_compile_definitions(cslib PRIVATE -DZMQ_NO)
+ target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ)
endif()
+
+target_link_libraries(lammps PRIVATE cslib)
+target_include_directories(lammps PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src)
diff --git a/cmake/Modules/Packages/MSCG.cmake b/cmake/Modules/Packages/MSCG.cmake
index b442580583a650ebf58241a82b226374483e3cc3..668d318d689edb039cf0b3f5df0565b052a7e9e2 100644
--- a/cmake/Modules/Packages/MSCG.cmake
+++ b/cmake/Modules/Packages/MSCG.cmake
@@ -1,45 +1,48 @@
-if(PKG_MSCG)
- find_package(GSL REQUIRED)
- find_package(MSCG QUIET)
- if(MSGC_FOUND)
- set(DOWNLOAD_MSCG_DEFAULT OFF)
- else()
- set(DOWNLOAD_MSCG_DEFAULT ON)
+find_package(GSL REQUIRED)
+find_package(MSCG QUIET)
+if(MSGC_FOUND)
+ set(DOWNLOAD_MSCG_DEFAULT OFF)
+else()
+ set(DOWNLOAD_MSCG_DEFAULT ON)
+endif()
+option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT})
+if(DOWNLOAD_MSCG)
+ include(ExternalProject)
+ ExternalProject_Add(mscg_build
+ URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz
+ URL_MD5 8c45e269ee13f60b303edd7823866a91
+ SOURCE_SUBDIR src/CMake
+ CMAKE_ARGS ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS}
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
+ -DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
+ -DCMAKE_INSTALL_PREFIX=
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
+ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+ BUILD_COMMAND ${CMAKE_COMMAND} --build . --target mscg
+ INSTALL_COMMAND ""
+ BUILD_BYPRODUCTS /libmscg.a
+ )
+ ExternalProject_get_property(mscg_build BINARY_DIR)
+ ExternalProject_get_property(mscg_build SOURCE_DIR)
+ file(MAKE_DIRECTORY ${SOURCE_DIR}/src)
+ add_library(LAMMPS::MSCG UNKNOWN IMPORTED)
+ set_target_properties(LAMMPS::MSCG PROPERTIES
+ IMPORTED_LOCATION "${BINARY_DIR}/libmscg.a"
+ INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/src"
+ INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}")
+ target_link_libraries(lammps PRIVATE LAMMPS::MSCG)
+ add_dependencies(LAMMPS::MSCG mscg_build)
+ if(NOT BUILD_SHARED_LIBS)
+ install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
- option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT})
- if(DOWNLOAD_MSCG)
- if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR
- message(FATAL_ERROR "For downlading MSCG you need at least cmake-3.7")
- endif()
- if(CMAKE_GENERATOR STREQUAL "Ninja")
- message(FATAL_ERROR "Cannot build downloaded MSCG library with Ninja build tool")
- endif()
- include(ExternalProject)
- if(NOT LAPACK_FOUND)
- set(EXTRA_MSCG_OPTS "-DLAPACK_LIBRARIES=${CMAKE_CURRENT_BINARY_DIR}/liblinalg.a")
- endif()
- ExternalProject_Add(mscg_build
- URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz
- URL_MD5 8c45e269ee13f60b303edd7823866a91
- SOURCE_SUBDIR src/CMake
- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS}
- BUILD_COMMAND make mscg INSTALL_COMMAND ""
- )
- ExternalProject_get_property(mscg_build BINARY_DIR)
- set(MSCG_LIBRARIES ${BINARY_DIR}/libmscg.a)
- ExternalProject_get_property(mscg_build SOURCE_DIR)
- set(MSCG_INCLUDE_DIRS ${SOURCE_DIR}/src)
- list(APPEND LAMMPS_DEPS mscg_build)
- if(NOT LAPACK_FOUND)
- file(MAKE_DIRECTORY ${MSCG_INCLUDE_DIRS})
- add_dependencies(mscg_build linalg)
- endif()
- else()
- find_package(MSCG)
- if(NOT MSCG_FOUND)
- message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it")
- endif()
+else()
+ find_package(MSCG)
+ if(NOT MSCG_FOUND)
+ message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it")
endif()
- list(APPEND LAMMPS_LINK_LIBS ${MSCG_LIBRARIES} ${GSL_LIBRARIES} ${LAPACK_LIBRARIES})
- include_directories(${MSCG_INCLUDE_DIRS})
+ target_link_libraries(lammps PRIVATE MSCG::MSCG)
endif()
+target_link_libraries(lammps PRIVATE GSL::gsl ${LAPACK_LIBRARIES})
diff --git a/cmake/Modules/Packages/OPT.cmake b/cmake/Modules/Packages/OPT.cmake
index f2802c757bdb1d3472395270c9ba1f7a4b652c19..bcf572b087d56f66c512b6d906f987d512d8347a 100644
--- a/cmake/Modules/Packages/OPT.cmake
+++ b/cmake/Modules/Packages/OPT.cmake
@@ -1,13 +1,11 @@
-if(PKG_OPT)
- set(OPT_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPT)
- set(OPT_SOURCES)
- set_property(GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}")
+ set(OPT_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPT)
+ set(OPT_SOURCES)
+ set_property(GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}")
- # detects styles which have OPT version
- RegisterStylesExt(${OPT_SOURCES_DIR} opt OPT_SOURCES)
+ # detects styles which have OPT version
+ RegisterStylesExt(${OPT_SOURCES_DIR} opt OPT_SOURCES)
- get_property(OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES)
+ get_property(OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES)
- list(APPEND LIB_SOURCES ${OPT_SOURCES})
- include_directories(${OPT_SOURCES_DIR})
-endif()
+ target_sources(lammps PRIVATE ${OPT_SOURCES})
+ target_include_directories(lammps PRIVATE ${OPT_SOURCES_DIR})
diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake
index 4f8959ae389ca97ef8774641f08949cf1bff600c..a577f824fe418cefb7d728acea61668151ed0364 100644
--- a/cmake/Modules/Packages/PYTHON.cmake
+++ b/cmake/Modules/Packages/PYTHON.cmake
@@ -1,6 +1,9 @@
-if(PKG_PYTHON)
- find_package(PythonLibs REQUIRED)
- add_definitions(-DLMP_PYTHON)
- include_directories(${PYTHON_INCLUDE_DIR})
- list(APPEND LAMMPS_LINK_LIBS ${PYTHON_LIBRARY})
+if(CMAKE_VERSION VERSION_LESS 3.12)
+ find_package(PythonLibs REQUIRED) # Deprecated since version 3.12
+ target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIR})
+ target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARY})
+else()
+ find_package(Python REQUIRED COMPONENTS Development)
+ target_link_libraries(lammps PRIVATE Python::Python)
endif()
+target_compile_definitions(lammps PRIVATE -DLMP_PYTHON)
diff --git a/cmake/Modules/Packages/QEQ.cmake b/cmake/Modules/Packages/QEQ.cmake
index 94cca30540dab41dd831254881ed86f788d00653..1bdaa02f431568038af65f7fe0bb49f558ae582b 100644
--- a/cmake/Modules/Packages/QEQ.cmake
+++ b/cmake/Modules/Packages/QEQ.cmake
@@ -1,20 +1,18 @@
# Fix qeq/fire requires MANYBODY (i.e. COMB and COMB3) to be installed
-if(PKG_QEQ)
- set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ)
- file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h)
- file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp)
+set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ)
+file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h)
+file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp)
- if(NOT PKG_MANYBODY)
- list(REMOVE_ITEM QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix_qeq_fire.h)
- list(REMOVE_ITEM QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp)
- endif()
- set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}")
+if(NOT PKG_MANYBODY)
+ list(REMOVE_ITEM QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix_qeq_fire.h)
+ list(REMOVE_ITEM QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp)
+endif()
+set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}")
- foreach(MY_HEADER ${QEQ_HEADERS})
- AddStyleHeader(${MY_HEADER} FIX)
- endforeach()
+foreach(MY_HEADER ${QEQ_HEADERS})
+ AddStyleHeader(${MY_HEADER} FIX)
+endforeach()
- get_property(QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES)
- list(APPEND LIB_SOURCES ${QEQ_SOURCES})
- include_directories(${QEQ_SOURCES_DIR})
-endif()
+get_property(QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES)
+target_sources(lammps PRIVATE ${QEQ_SOURCES})
+target_include_directories(lammps PRIVATE ${QEQ_SOURCES_DIR})
diff --git a/cmake/Modules/Packages/USER-COLVARS.cmake b/cmake/Modules/Packages/USER-COLVARS.cmake
index b7fb91917cc32595dfd589adf779c26ac3af28bf..31e64e37909ca3557f8c9186e3643513b75b5f70 100644
--- a/cmake/Modules/Packages/USER-COLVARS.cmake
+++ b/cmake/Modules/Packages/USER-COLVARS.cmake
@@ -1,42 +1,36 @@
-if(PKG_USER-COLVARS)
+set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars)
- set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars)
+file(GLOB COLVARS_SOURCES ${COLVARS_SOURCE_DIR}/[^.]*.cpp)
- file(GLOB COLVARS_SOURCES ${COLVARS_SOURCE_DIR}/[^.]*.cpp)
+# Build Lepton by default
+option(COLVARS_LEPTON "Build and link the Lepton library" ON)
- # Build Lepton by default
- set(COLVARS_LEPTON_DEFAULT ON)
- # but not if C++11 is disabled per user request
- if(DEFINED DISABLE_CXX11_REQUIREMENT)
- if(DISABLE_CXX11_REQUIREMENT)
- set(COLVARS_LEPTON_DEFAULT OFF)
- endif()
- endif()
-
- option(COLVARS_LEPTON "Build and link the Lepton library" ${COLVARS_LEPTON_DEFAULT})
-
- # Verify that the user's choice is consistent
- if(DEFINED DISABLE_CXX11_REQUIREMENT)
- if((DISABLE_CXX11_REQUIREMENT) AND (COLVARS_LEPTON))
- message(FATAL_ERROR "Building the Lepton library requires C++11 or later.")
- endif()
- endif()
-
- if(COLVARS_LEPTON)
- set(LEPTON_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars/lepton)
- file(GLOB LEPTON_SOURCES ${LEPTON_DIR}/src/[^.]*.cpp)
- add_library(lepton STATIC ${LEPTON_SOURCES})
- target_include_directories(lepton PRIVATE ${LEPTON_DIR}/include)
- endif()
-
- add_library(colvars STATIC ${COLVARS_SOURCES})
- target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars)
- list(APPEND LAMMPS_LINK_LIBS colvars)
-
- if(COLVARS_LEPTON)
- list(APPEND LAMMPS_LINK_LIBS lepton)
- target_compile_options(colvars PRIVATE -DLEPTON)
- target_include_directories(colvars PUBLIC ${LEPTON_DIR}/include)
+if(COLVARS_LEPTON)
+ set(LEPTON_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars/lepton)
+ file(GLOB LEPTON_SOURCES ${LEPTON_DIR}/src/[^.]*.cpp)
+ add_library(lepton STATIC ${LEPTON_SOURCES})
+ if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS lepton EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
+ # Change the define below to LEPTON_BUILDING_SHARED_LIBRARY when linking Lepton as a DLL with MSVC
+ target_compile_definitions(lepton PRIVATE -DLEPTON_BUILDING_STATIC_LIBRARY)
+ set_target_properties(lepton PROPERTIES OUTPUT_NAME lammps_lepton${LAMMPS_MACHINE})
+ target_include_directories(lepton PRIVATE ${LEPTON_DIR}/include)
+endif()
+add_library(colvars STATIC ${COLVARS_SOURCES})
+if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS colvars EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+endif()
+target_compile_definitions(colvars PRIVATE -DLAMMPS_${LAMMPS_SIZES})
+set_target_properties(colvars PROPERTIES OUTPUT_NAME lammps_colvars${LAMMPS_MACHINE})
+target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars)
+target_link_libraries(lammps PRIVATE colvars)
+
+if(COLVARS_LEPTON)
+ target_link_libraries(lammps PRIVATE lepton)
+ target_compile_definitions(colvars PRIVATE -DLEPTON)
+ # Disable the line below when linking Lepton as a DLL with MSVC
+ target_compile_definitions(colvars PRIVATE -DLEPTON_USE_STATIC_LIBRARIES)
+ target_include_directories(colvars PUBLIC ${LEPTON_DIR}/include)
endif()
diff --git a/cmake/Modules/Packages/USER-H5MD.cmake b/cmake/Modules/Packages/USER-H5MD.cmake
index 40ea7b7444cd024c762e9708ebc8dd965a95c153..4fcae93027c36204799b5388de90e2f6b9b4795f 100644
--- a/cmake/Modules/Packages/USER-H5MD.cmake
+++ b/cmake/Modules/Packages/USER-H5MD.cmake
@@ -1,8 +1,5 @@
-if(PKG_USER-H5MD)
- enable_language(C)
+enable_language(C)
- find_package(HDF5 REQUIRED)
- target_link_libraries(h5md ${HDF5_LIBRARIES})
- target_include_directories(h5md PRIVATE ${HDF5_INCLUDE_DIRS})
- include_directories(${HDF5_INCLUDE_DIRS})
-endif()
+find_package(HDF5 REQUIRED)
+target_link_libraries(h5md PRIVATE ${HDF5_LIBRARIES})
+target_include_directories(h5md PUBLIC ${HDF5_INCLUDE_DIRS})
diff --git a/cmake/Modules/Packages/USER-INTEL.cmake b/cmake/Modules/Packages/USER-INTEL.cmake
index 3c0cc7ba2498df01d0a3450faf7049808d6379a8..0ae1ec018a309be7f2ac4293e04d12019ddd9a8b 100644
--- a/cmake/Modules/Packages/USER-INTEL.cmake
+++ b/cmake/Modules/Packages/USER-INTEL.cmake
@@ -1,118 +1,109 @@
-if(PKG_USER-INTEL)
- check_include_file_cxx(immintrin.h FOUND_IMMINTRIN)
- if(NOT FOUND_IMMINTRIN)
- message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it")
- endif()
+check_include_file_cxx(immintrin.h FOUND_IMMINTRIN)
+if(NOT FOUND_IMMINTRIN)
+ message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it")
+endif()
- add_definitions(-DLMP_USER_INTEL)
+target_compile_definitions(lammps PRIVATE -DLMP_USER_INTEL)
- set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)")
- set(INTEL_ARCH_VALUES cpu knl)
- set_property(CACHE INTEL_ARCH PROPERTY STRINGS ${INTEL_ARCH_VALUES})
- validate_option(INTEL_ARCH INTEL_ARCH_VALUES)
- string(TOUPPER ${INTEL_ARCH} INTEL_ARCH)
+set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)")
+set(INTEL_ARCH_VALUES cpu knl)
+set_property(CACHE INTEL_ARCH PROPERTY STRINGS ${INTEL_ARCH_VALUES})
+validate_option(INTEL_ARCH INTEL_ARCH_VALUES)
+string(TOUPPER ${INTEL_ARCH} INTEL_ARCH)
- find_package(Threads QUIET)
+find_package(Threads QUIET)
+if(Threads_FOUND)
+ set(INTEL_LRT_MODE "threads" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
+else()
+ set(INTEL_LRT_MODE "none" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
+endif()
+set(INTEL_LRT_VALUES none threads c++11)
+set_property(CACHE INTEL_LRT_MODE PROPERTY STRINGS ${INTEL_LRT_VALUES})
+validate_option(INTEL_LRT_MODE INTEL_LRT_VALUES)
+string(TOUPPER ${INTEL_LRT_MODE} INTEL_LRT_MODE)
+if(INTEL_LRT_MODE STREQUAL "THREADS")
if(Threads_FOUND)
- set(INTEL_LRT_MODE "threads" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
+ target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT)
+ target_link_libraries(lammps PRIVATE Threads::Threads)
else()
- set(INTEL_LRT_MODE "none" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
+ message(FATAL_ERROR "Must have working threads library for Long-range thread support")
endif()
- set(INTEL_LRT_VALUES none threads c++11)
- set_property(CACHE INTEL_LRT_MODE PROPERTY STRINGS ${INTEL_LRT_VALUES})
- validate_option(INTEL_LRT_MODE INTEL_LRT_VALUES)
- string(TOUPPER ${INTEL_LRT_MODE} INTEL_LRT_MODE)
- if(INTEL_LRT_MODE STREQUAL "THREADS")
- if(Threads_FOUND)
- add_definitions(-DLMP_INTEL_USELRT)
- list(APPEND LAMMPS_LINK_LIBS ${CMAKE_THREAD_LIBS_INIT})
- else()
- message(FATAL_ERROR "Must have working threads library for Long-range thread support")
- endif()
- endif()
- if(INTEL_LRT_MODE STREQUAL "C++11")
- add_definitions(-DLMP_INTEL_USERLRT -DLMP_INTEL_LRT11)
+endif()
+if(INTEL_LRT_MODE STREQUAL "C++11")
+ target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT -DLMP_INTEL_LRT11)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
+ message(FATAL_ERROR "USER-INTEL needs at least a 2016 Intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}")
endif()
+else()
+ message(WARNING "USER-INTEL gives best performance with Intel compilers")
+endif()
+find_package(TBB_MALLOC QUIET)
+if(TBB_MALLOC_FOUND)
+ target_link_libraries(lammps PRIVATE TBB::TBB_MALLOC)
+else()
+ target_compile_definitions(lammps PRIVATE -DLMP_INTEL_NO_TBB)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
- if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
- message(FATAL_ERROR "USER-INTEL needs at least a 2016 Intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}")
- endif()
- else()
- message(WARNING "USER-INTEL gives best performance with Intel compilers")
+ message(WARNING "USER-INTEL with Intel compilers should use TBB malloc libraries")
endif()
+endif()
- find_package(TBB QUIET)
- if(TBB_FOUND)
- list(APPEND LAMMPS_LINK_LIBS ${TBB_MALLOC_LIBRARIES})
- else()
- add_definitions(-DLMP_INTEL_NO_TBB)
- if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
- message(WARNING "USER-INTEL with Intel compilers should use TBB malloc libraries")
- endif()
- endif()
+find_package(MKL QUIET)
+if(MKL_FOUND)
+ target_compile_definitions(lammps PRIVATE -DLMP_USE_MKL_RNG)
+ target_link_libraries(lammps PRIVATE MKL::MKL)
+else()
+ message(STATUS "Pair style dpd/intel will be faster with MKL libraries")
+endif()
- find_package(MKL QUIET)
- if(MKL_FOUND)
- add_definitions(-DLMP_USE_MKL_RNG)
- list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES})
- else()
- message(STATUS "Pair style dpd/intel will be faster with MKL libraries")
- endif()
+if((NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "64") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "128") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "256"))
+ message(FATAL_ERROR "USER-INTEL only supports memory alignment of 64, 128 or 256 on this platform")
+endif()
- if((NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "64") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "128") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "256"))
- message(FATAL_ERROR "USER-INTEL only supports memory alignment of 64, 128 or 256 on this platform")
+if(INTEL_ARCH STREQUAL "KNL")
+ if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+ message(FATAL_ERROR "Must use Intel compiler with USER-INTEL for KNL architecture")
endif()
-
- if(INTEL_ARCH STREQUAL "KNL")
- if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
- message(FATAL_ERROR "Must use Intel compiler with USER-INTEL for KNL architecture")
- endif()
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload")
- set(MIC_OPTIONS "-qoffload-option,mic,compiler,\"-fp-model fast=2 -mGLOB_default_function_attrs=\\\"gather_scatter_loop_unroll=4\\\"\"")
- add_compile_options(-xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${MIC_OPTIONS})
- add_definitions(-DLMP_INTEL_OFFLOAD)
- else()
- if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
- if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xCOMMON-AVX512")
- else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload")
+ set(MIC_OPTIONS "-qoffload-option,mic,compiler,\"-fp-model fast=2 -mGLOB_default_function_attrs=\\\"gather_scatter_loop_unroll=4\\\"\"")
+ target_compile_options(lammps PRIVATE -xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${MIC_OPTIONS})
+ target_compile_definitions(lammps PRIVATE -DLMP_INTEL_OFFLOAD)
+else()
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+ include(CheckCXXCompilerFlag)
+ foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict)
+ check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAG})
+ if(COMPILER_SUPPORTS${_FLAG})
+ target_compile_options(lammps PRIVATE ${_FLAG})
endif()
- include(CheckCXXCompilerFlag)
- foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict)
- check_cxx_compiler_flag("${__FLAG}" COMPILER_SUPPORTS${_FLAG})
- if(COMPILER_SUPPORTS${_FLAG})
- add_compile_options(${_FLAG})
- endif()
- endforeach()
- else()
- add_compile_options(-O3 -ffast-math)
- endif()
+ endforeach()
endif()
+endif()
- # collect sources
- set(USER-INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-INTEL)
- set(USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/fix_intel.cpp
- ${USER-INTEL_SOURCES_DIR}/fix_nh_intel.cpp
- ${USER-INTEL_SOURCES_DIR}/intel_buffers.cpp
- ${USER-INTEL_SOURCES_DIR}/nbin_intel.cpp
- ${USER-INTEL_SOURCES_DIR}/npair_intel.cpp)
+# collect sources
+set(USER-INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-INTEL)
+set(USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/fix_intel.cpp
+ ${USER-INTEL_SOURCES_DIR}/fix_nh_intel.cpp
+ ${USER-INTEL_SOURCES_DIR}/intel_buffers.cpp
+ ${USER-INTEL_SOURCES_DIR}/nbin_intel.cpp
+ ${USER-INTEL_SOURCES_DIR}/npair_intel.cpp)
- set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}")
+set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}")
- # detect styles which have a USER-INTEL version
- RegisterStylesExt(${USER-INTEL_SOURCES_DIR} intel USER-INTEL_SOURCES)
- RegisterNBinStyle(${USER-INTEL_SOURCES_DIR}/nbin_intel.h)
- RegisterNPairStyle(${USER-INTEL_SOURCES_DIR}/npair_intel.h)
- RegisterFixStyle(${USER-INTEL_SOURCES_DIR}/fix_intel.h)
+# detect styles which have a USER-INTEL version
+RegisterStylesExt(${USER-INTEL_SOURCES_DIR} intel USER-INTEL_SOURCES)
+RegisterNBinStyle(${USER-INTEL_SOURCES_DIR}/nbin_intel.h)
+RegisterNPairStyle(${USER-INTEL_SOURCES_DIR}/npair_intel.h)
+RegisterFixStyle(${USER-INTEL_SOURCES_DIR}/fix_intel.h)
- get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES)
- if(PKG_KSPACE)
- list(APPEND USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp)
- RegisterIntegrateStyle(${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.h)
- endif()
-
- list(APPEND LIB_SOURCES ${USER-INTEL_SOURCES})
- include_directories(${USER-INTEL_SOURCES_DIR})
+get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES)
+if(PKG_KSPACE)
+ list(APPEND USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp)
+ RegisterIntegrateStyle(${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.h)
endif()
+
+target_sources(lammps PRIVATE ${USER-INTEL_SOURCES})
+target_include_directories(lammps PRIVATE ${USER-INTEL_SOURCES_DIR})
diff --git a/cmake/Modules/Packages/USER-MOLFILE.cmake b/cmake/Modules/Packages/USER-MOLFILE.cmake
index b8c4234d265dbc2381ae4bfcc57aec00a2ee7407..dd6435e56b2b41d6f8802aabf79878039c787134 100644
--- a/cmake/Modules/Packages/USER-MOLFILE.cmake
+++ b/cmake/Modules/Packages/USER-MOLFILE.cmake
@@ -1,14 +1,11 @@
-if(PKG_USER-MOLFILE)
- if (CMAKE_VERSION VERSION_LESS "3.10") # due to INTERFACE without a library
- message(FATAL_ERROR "For configuring USER-MOLFILE you need CMake 3.10 or later")
- endif()
-
- set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers")
- add_library(molfile INTERFACE)
- target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS})
- # no need to link with -ldl on windows
- if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS})
- endif()
- list(APPEND LAMMPS_LINK_LIBS molfile)
+set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers")
+add_library(molfile INTERFACE)
+if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS molfile EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
+target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS})
+# no need to link with -ldl on windows
+if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+ target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS})
+endif()
+target_link_libraries(lammps PRIVATE molfile)
diff --git a/cmake/Modules/Packages/USER-NETCDF.cmake b/cmake/Modules/Packages/USER-NETCDF.cmake
index f60c046ab99aa36fc26577e4225bed9b5edd46fc..91186c84db736137e02fa155362f595231e4ee95 100644
--- a/cmake/Modules/Packages/USER-NETCDF.cmake
+++ b/cmake/Modules/Packages/USER-NETCDF.cmake
@@ -1,24 +1,20 @@
-if(PKG_USER-NETCDF)
- # USER-NETCDF can use NetCDF, Parallel NetCDF (PNetCDF), or both. At least one necessary.
- # NetCDF library enables dump sytle "netcdf", while PNetCDF enables dump style "netcdf/mpiio"
- find_package(NetCDF)
- if(NETCDF_FOUND)
- find_package(PNetCDF)
- else(NETCDF_FOUND)
- find_package(PNetCDF REQUIRED)
- endif(NETCDF_FOUND)
+# USER-NETCDF can use NetCDF, Parallel NetCDF (PNetCDF), or both. At least one necessary.
+# NetCDF library enables dump style "netcdf", while PNetCDF enables dump style "netcdf/mpiio"
+find_package(NetCDF)
+if(NETCDF_FOUND)
+ find_package(PNetCDF)
+else(NETCDF_FOUND)
+ find_package(PNetCDF REQUIRED)
+endif(NETCDF_FOUND)
- if(NETCDF_FOUND)
- include_directories(${NETCDF_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS ${NETCDF_LIBRARIES})
- add_definitions(-DLMP_HAS_NETCDF)
- endif(NETCDF_FOUND)
+if(NETCDF_FOUND)
+ target_link_libraries(lammps PRIVATE NetCDF::NetCDF)
+ target_compile_definitions(lammps PRIVATE -DLMP_HAS_NETCDF)
+endif(NETCDF_FOUND)
- if(PNETCDF_FOUND)
- include_directories(${PNETCDF_INCLUDES})
- list(APPEND LAMMPS_LINK_LIBS ${PNETCDF_LIBRARIES})
- add_definitions(-DLMP_HAS_PNETCDF)
- endif(PNETCDF_FOUND)
+if(PNETCDF_FOUND)
+ target_link_libraries(lammps PRIVATE PNetCDF::PNetCDF)
+ target_compile_definitions(lammps PRIVATE -DLMP_HAS_PNETCDF)
+endif(PNETCDF_FOUND)
- add_definitions(-DNC_64BIT_DATA=0x0020)
-endif()
+target_compile_definitions(lammps PRIVATE -DNC_64BIT_DATA=0x0020)
diff --git a/cmake/Modules/Packages/USER-OMP.cmake b/cmake/Modules/Packages/USER-OMP.cmake
index 668f42f10a56f382d5a1146193a6b7c69da0a00a..a1053ad355d3667245fadc45f126a8f60fd6ba70 100644
--- a/cmake/Modules/Packages/USER-OMP.cmake
+++ b/cmake/Modules/Packages/USER-OMP.cmake
@@ -1,42 +1,40 @@
-if(PKG_USER-OMP)
- set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP)
- set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp
- ${USER-OMP_SOURCES_DIR}/thr_omp.cpp
- ${USER-OMP_SOURCES_DIR}/fix_omp.cpp
- ${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp
- ${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp
- ${USER-OMP_SOURCES_DIR}/domain_omp.cpp)
- add_definitions(-DLMP_USER_OMP)
- set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}")
+ set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP)
+ set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp
+ ${USER-OMP_SOURCES_DIR}/thr_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/fix_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/domain_omp.cpp)
+ target_compile_definitions(lammps PRIVATE -DLMP_USER_OMP)
+ set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}")
- # detects styles which have USER-OMP version
- RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES)
- RegisterFixStyle(${USER-OMP_SOURCES_DIR}/fix_omp.h)
+ # detects styles which have USER-OMP version
+ RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES)
+ RegisterFixStyle(${USER-OMP_SOURCES_DIR}/fix_omp.h)
- get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES)
+ get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES)
- # manually add package dependent source files from USER-OMP that do not provide styles
+ # manually add package dependent source files from USER-OMP that do not provide styles
- if(PKG_ASPHERE)
- list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp)
- endif()
+ if(PKG_ASPHERE)
+ list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp)
+ endif()
- if(PKG_RIGID)
- list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp)
- endif()
+ if(PKG_RIGID)
+ list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp)
+ endif()
- if(PKG_USER-REAXC)
- list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp
- ${USER-OMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp
- ${USER-OMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp
- ${USER-OMP_SOURCES_DIR}/reaxc_bonds_omp.cpp
- ${USER-OMP_SOURCES_DIR}/reaxc_init_md_omp.cpp
- ${USER-OMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp
- ${USER-OMP_SOURCES_DIR}/reaxc_forces_omp.cpp
- ${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp
- ${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp)
- endif()
+ if(PKG_USER-REAXC)
+ list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/reaxc_bonds_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/reaxc_init_md_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/reaxc_forces_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp
+ ${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp)
+ endif()
- list(APPEND LIB_SOURCES ${USER-OMP_SOURCES})
- include_directories(${USER-OMP_SOURCES_DIR})
-endif()
+ target_sources(lammps PRIVATE ${USER-OMP_SOURCES})
+ target_include_directories(lammps PRIVATE ${USER-OMP_SOURCES_DIR})
diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/USER-PLUMED.cmake
index bf5c502d84bbe9421c6e37518ea519fcb3f97dbb..102ce7a7ad4431eae7b0ff2880fe71ebc92474b7 100644
--- a/cmake/Modules/Packages/USER-PLUMED.cmake
+++ b/cmake/Modules/Packages/USER-PLUMED.cmake
@@ -1,91 +1,101 @@
-if(PKG_USER-PLUMED)
- set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library")
- set(PLUMED_MODE_VALUES static shared runtime)
- set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES})
- validate_option(PLUMED_MODE PLUMED_MODE_VALUES)
- string(TOUPPER ${PLUMED_MODE} PLUMED_MODE)
+set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library")
+set(PLUMED_MODE_VALUES static shared runtime)
+set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES})
+validate_option(PLUMED_MODE PLUMED_MODE_VALUES)
+string(TOUPPER ${PLUMED_MODE} PLUMED_MODE)
- set(PLUMED_LINK_LIBS "")
- if(PLUMED_MODE STREQUAL "STATIC")
- find_package(LAPACK REQUIRED)
- find_package(BLAS REQUIRED)
- find_package(GSL REQUIRED)
- list(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES})
- list(APPEND PLUMED_LINK_LIBS ${LAPACK_LIBRARIES} ${GSL_LIBRARIES})
- find_package(ZLIB QUIET)
- if(ZLIB_FOUND)
- list(APPEND PLUMED_LINK_LIBS ${ZLIB_LIBRARIES})
- endif()
+set(PLUMED_LINK_LIBS)
+if(PLUMED_MODE STREQUAL "STATIC")
+ find_package(LAPACK REQUIRED)
+ find_package(BLAS REQUIRED)
+ find_package(GSL REQUIRED)
+ list(APPEND PLUMED_LINK_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} GSL::gsl)
+ find_package(ZLIB QUIET)
+ if(ZLIB_FOUND)
+ list(APPEND PLUMED_LINK_LIBS ZLIB::ZLIB)
+ endif()
+ find_package(FFTW3 QUIET)
+ if(FFTW3_FOUND)
+ list(APPEND PLUMED_LINK_LIBS FFTW3::FFTW3)
endif()
+endif()
- find_package(PkgConfig QUIET)
- set(DOWNLOAD_PLUMED_DEFAULT ON)
- if(PKG_CONFIG_FOUND)
- pkg_check_modules(PLUMED QUIET plumed)
- if(PLUMED_FOUND)
- set(DOWNLOAD_PLUMED_DEFAULT OFF)
- endif()
+find_package(PkgConfig QUIET)
+set(DOWNLOAD_PLUMED_DEFAULT ON)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PLUMED QUIET plumed)
+ if(PLUMED_FOUND)
+ set(DOWNLOAD_PLUMED_DEFAULT OFF)
endif()
+endif()
- option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT})
- if(DOWNLOAD_PLUMED)
- if(CMAKE_GENERATOR STREQUAL "Ninja")
- message(FATAL_ERROR "Cannot build downloaded Plumed library with Ninja build tool")
- endif()
- if(BUILD_MPI)
- set(PLUMED_CONFIG_MPI "--enable-mpi")
- set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
- set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER})
- else()
- set(PLUMED_CONFIG_MPI "--disable-mpi")
- set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER})
- set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER})
- endif()
- if(BUILD_OMP)
- set(PLUMED_CONFIG_OMP "--enable-openmp")
- else()
- set(PLUMED_CONFIG_OMP "--disable-openmp")
- endif()
- message(STATUS "PLUMED download requested - we will build our own")
- include(ExternalProject)
- ExternalProject_Add(plumed_build
- URL https://github.com/plumed/plumed2/releases/download/v2.5.3/plumed-src-2.5.3.tgz
- URL_MD5 de30d6e7c2dcc0973298e24a6da24286
- BUILD_IN_SOURCE 1
- CONFIGURE_COMMAND /configure --prefix=
- ${CONFIGURE_REQUEST_PIC}
- --enable-modules=all
- ${PLUMED_CONFIG_MPI}
- ${PLUMED_CONFIG_OMP}
- CXX=${PLUMED_CONFIG_CXX}
- CC=${PLUMED_CONFIG_CC}
- )
- ExternalProject_get_property(plumed_build INSTALL_DIR)
- set(PLUMED_INSTALL_DIR ${INSTALL_DIR})
- list(APPEND LAMMPS_DEPS plumed_build)
- if(PLUMED_MODE STREQUAL "STATIC")
- add_definitions(-D__PLUMED_WRAPPER_CXX=1)
- list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed.a ${PLUMED_LINK_LIBS} ${CMAKE_DL_LIBS})
- elseif(PLUMED_MODE STREQUAL "SHARED")
- list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX} ${PLUMED_INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_DL_LIBS})
- elseif(PLUMED_MODE STREQUAL "RUNTIME")
- add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX})
- list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumedWrapper.a -rdynamic ${CMAKE_DL_LIBS})
- endif()
- set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include")
+option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT})
+if(DOWNLOAD_PLUMED)
+ if(BUILD_MPI)
+ set(PLUMED_CONFIG_MPI "--enable-mpi")
+ set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
+ set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER})
else()
- find_package(PkgConfig REQUIRED)
- pkg_check_modules(PLUMED REQUIRED plumed)
- if(PLUMED_MODE STREQUAL "STATIC")
- add_definitions(-D__PLUMED_WRAPPER_CXX=1)
- include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
- elseif(PLUMED_MODE STREQUAL "SHARED")
- include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared)
- elseif(PLUMED_MODE STREQUAL "RUNTIME")
- add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX})
- include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime)
- endif()
- list(APPEND LAMMPS_LINK_LIBS ${PLUMED_LOAD})
+ set(PLUMED_CONFIG_MPI "--disable-mpi")
+ set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER})
+ set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER})
+ endif()
+ if(BUILD_OMP)
+ set(PLUMED_CONFIG_OMP "--enable-openmp")
+ else()
+ set(PLUMED_CONFIG_OMP "--disable-openmp")
+ endif()
+ message(STATUS "PLUMED download requested - we will build our own")
+ if(PLUMED_MODE STREQUAL "STATIC")
+ set(PLUMED_BUILD_BYPRODUCTS "/lib/libplumed.a")
+ elseif(PLUMED_MODE STREQUAL "SHARED")
+ set(PLUMED_BUILD_BYPRODUCTS "/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX};/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ elseif(PLUMED_MODE STREQUAL "RUNTIME")
+ set(PLUMED_BUILD_BYPRODUCTS "/lib/libplumedWrapper.a")
+ endif()
+ include(ExternalProject)
+ ExternalProject_Add(plumed_build
+ URL https://github.com/plumed/plumed2/releases/download/v2.6.0/plumed-src-2.6.0.tgz
+ URL_MD5 204d2edae58d9b10ba3ad460cad64191
+ BUILD_IN_SOURCE 1
+ CONFIGURE_COMMAND /configure --prefix=
+ ${CONFIGURE_REQUEST_PIC}
+ --enable-modules=all
+ ${PLUMED_CONFIG_MPI}
+ ${PLUMED_CONFIG_OMP}
+ CXX=${PLUMED_CONFIG_CXX}
+ CC=${PLUMED_CONFIG_CC}
+ BUILD_BYPRODUCTS ${PLUMED_BUILD_BYPRODUCTS}
+ )
+ ExternalProject_get_property(plumed_build INSTALL_DIR)
+ add_library(LAMMPS::PLUMED UNKNOWN IMPORTED)
+ add_dependencies(LAMMPS::PLUMED plumed_build)
+ if(NOT BUILD_SHARED_LIBS)
+ install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
+ endif()
+ if(PLUMED_MODE STREQUAL "STATIC")
+ set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed.a INTERFACE_LINK_LIBRARIES "${PLUMED_LINK_LIBS};${CMAKE_DL_LIBS}")
+ elseif(PLUMED_MODE STREQUAL "SHARED")
+ set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX} INTERFACE_LINK_LIBRARIES "${INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX};${CMAKE_DL_LIBS}")
+ elseif(PLUMED_MODE STREQUAL "RUNTIME")
+ set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_DEFAULT_KERNEL=${INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumedWrapper.a INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}")
+ endif()
+ set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
+ file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
+else()
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(PLUMED REQUIRED plumed)
+ add_library(LAMMPS::PLUMED INTERFACE IMPORTED)
+ if(PLUMED_MODE STREQUAL "STATIC")
+ include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
+ elseif(PLUMED_MODE STREQUAL "SHARED")
+ include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared)
+ elseif(PLUMED_MODE STREQUAL "RUNTIME")
+ set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime)
endif()
- include_directories(${PLUMED_INCLUDE_DIRS})
+ set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_LINK_LIBRARIES "${PLUMED_LOAD}")
+ set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PLUMED_INCLUDE_DIRS}")
endif()
+target_link_libraries(lammps PRIVATE LAMMPS::PLUMED)
diff --git a/cmake/Modules/Packages/USER-QMMM.cmake b/cmake/Modules/Packages/USER-QMMM.cmake
index e0ae1a46dc19128f03c6004e232b284ea3692dbd..76bb76fa5afe6160dc797566592fed7d145b2160 100644
--- a/cmake/Modules/Packages/USER-QMMM.cmake
+++ b/cmake/Modules/Packages/USER-QMMM.cmake
@@ -1,9 +1,12 @@
-if(PKG_USER-QMMM)
- enable_language(Fortran)
- enable_language(C)
+enable_language(C)
- message(WARNING "Building QMMM with CMake is still experimental")
- find_package(QE REQUIRED)
- include_directories(${QE_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS ${QE_LIBRARIES})
+if(NOT BUILD_SHARED_LIBS)
+ message(WARNING "It is recommended to use BUILD_SHARED_LIBS=yes with USER-QMMM")
endif()
+add_library(qmmm STATIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm/libqmmm.c)
+if(NOT BUILD_SHARED_LIBS)
+ install(TARGETS qmmm EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+endif()
+set_target_properties(qmmm PROPERTIES OUTPUT_NAME lammps_qmmm${LAMMPS_MACHINE})
+target_link_libraries(lammps PRIVATE qmmm)
+target_include_directories(qmmm PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm)
diff --git a/cmake/Modules/Packages/USER-QUIP.cmake b/cmake/Modules/Packages/USER-QUIP.cmake
index 93096a2f54bec679eda388df567f5b35662641cf..790f27def7bfffa7341e1fea45aab8292cda9464 100644
--- a/cmake/Modules/Packages/USER-QUIP.cmake
+++ b/cmake/Modules/Packages/USER-QUIP.cmake
@@ -1,5 +1,3 @@
-if(PKG_USER-QUIP)
- enable_language(Fortran)
- find_package(QUIP REQUIRED)
- list(APPEND LAMMPS_LINK_LIBS ${QUIP_LIBRARIES} ${LAPACK_LIBRARIES})
-endif()
+enable_language(Fortran)
+find_package(QUIP REQUIRED)
+target_link_libraries(lammps PRIVATE QUIP::QUIP ${LAPACK_LIBRARIES})
diff --git a/cmake/Modules/Packages/USER-SCAFACOS.cmake b/cmake/Modules/Packages/USER-SCAFACOS.cmake
index 475f2585c80fcfb19c4f8d6cf731791d122a9f90..ee12e754e648b497577cb172d03271f134b6dae4 100644
--- a/cmake/Modules/Packages/USER-SCAFACOS.cmake
+++ b/cmake/Modules/Packages/USER-SCAFACOS.cmake
@@ -1,62 +1,62 @@
-if(PKG_USER-SCAFACOS)
- enable_language(Fortran)
- enable_language(C)
+enable_language(Fortran)
+enable_language(C)
- find_package(GSL REQUIRED)
- find_package(PkgConfig QUIET)
- set(DOWNLOAD_SCAFACOS_DEFAULT ON)
- if(PKG_CONFIG_FOUND)
- pkg_check_modules(SCAFACOS QUIET scafacos)
- if(SCAFACOS_FOUND)
- set(DOWNLOAD_SCAFACOS_DEFAULT OFF)
- endif()
+find_package(GSL REQUIRED)
+find_package(PkgConfig QUIET)
+find_package(MPI REQUIRED)
+set(DOWNLOAD_SCAFACOS_DEFAULT ON)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(SCAFACOS QUIET scafacos)
+ if(SCAFACOS_FOUND)
+ set(DOWNLOAD_SCAFACOS_DEFAULT OFF)
endif()
- option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT})
- if(DOWNLOAD_SCAFACOS)
- if(CMAKE_GENERATOR STREQUAL "Ninja")
- message(FATAL_ERROR "Cannot build downloaded ScaFaCoS library with Ninja build tool")
- endif()
- message(STATUS "ScaFaCoS download requested - we will build our own")
- include(ExternalProject)
- ExternalProject_Add(scafacos_build
- URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz
- URL_MD5 bd46d74e3296bd8a444d731bb10c1738
- CONFIGURE_COMMAND /configure --prefix= --disable-doc
- --enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m
- --with-internal-fftw --with-internal-pfft
- --with-internal-pnfft ${CONFIGURE_REQUEST_PIC}
- FC=${CMAKE_MPI_Fortran_COMPILER}
- CXX=${CMAKE_MPI_CXX_COMPILER}
- CC=${CMAKE_MPI_C_COMPILER}
- F77=
- )
- ExternalProject_get_property(scafacos_build INSTALL_DIR)
- set(SCAFACOS_BUILD_DIR ${INSTALL_DIR})
- set(SCAFACOS_INCLUDE_DIRS ${SCAFACOS_BUILD_DIR}/include)
- list(APPEND LAMMPS_DEPS scafacos_build)
- # list and order from pkg_config file of ScaFaCoS build
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_direct.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_ewald.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fmm.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p2nfft.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p3m.a)
- list(APPEND LAMMPS_LINK_LIBS ${GSL_LIBRARIES})
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_near.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_gridsort.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_resort.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_redist.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_common.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pnfft.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pfft.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3_mpi.a)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3.a)
- list(APPEND LAMMPS_LINK_LIBS ${MPI_Fortran_LIBRARIES})
- list(APPEND LAMMPS_LINK_LIBS ${MPI_C_LIBRARIES})
- else()
- find_package(PkgConfig REQUIRED)
- pkg_check_modules(SCAFACOS REQUIRED scafacos)
- list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_LDFLAGS})
+endif()
+option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT})
+if(DOWNLOAD_SCAFACOS)
+ message(STATUS "ScaFaCoS download requested - we will build our own")
+ include(ExternalProject)
+ ExternalProject_Add(scafacos_build
+ URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz
+ URL_MD5 bd46d74e3296bd8a444d731bb10c1738
+ CONFIGURE_COMMAND /configure --prefix= --disable-doc
+ --enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m
+ --with-internal-fftw --with-internal-pfft
+ --with-internal-pnfft ${CONFIGURE_REQUEST_PIC}
+ FC=${CMAKE_MPI_Fortran_COMPILER}
+ CXX=${CMAKE_MPI_CXX_COMPILER}
+ CC=${CMAKE_MPI_C_COMPILER}
+ F77=
+ BUILD_BYPRODUCTS
+ /lib/libfcs.a
+ /lib/libfcs_direct.a
+ /lib/libfcs_ewald.a
+ /lib/libfcs_fmm.a
+ /lib/libfcs_p2nfft.a
+ /lib/libfcs_p3m.a
+ /lib/libfcs_near.a
+ /lib/libfcs_gridsort.a
+ /lib/libfcs_resort.a
+ /lib/libfcs_redist.a
+ /lib/libfcs_common.a
+ /lib/libfcs_pnfft.a
+ /lib/libfcs_pfft.a
+ /lib/libfcs_fftw3_mpi.a
+ /lib/libfcs_fftw3.a
+ )
+ ExternalProject_get_property(scafacos_build INSTALL_DIR)
+ file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
+ add_library(LAMMPS::SCAFACOS UNKNOWN IMPORTED)
+ set_target_properties(LAMMPS::SCAFACOS PROPERTIES
+ IMPORTED_LOCATION "${INSTALL_DIR}/lib/libfcs.a"
+ INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include"
+ INTERFACE_LINK_LIBRARIES "${INSTALL_DIR}/lib/libfcs.a;${INSTALL_DIR}/lib/libfcs_direct.a;${INSTALL_DIR}/lib/libfcs_ewald.a;${INSTALL_DIR}/lib/libfcs_fmm.a;${INSTALL_DIR}/lib/libfcs_p2nfft.a;${INSTALL_DIR}/lib/libfcs_p3m.a;GSL::gsl;${INSTALL_DIR}/lib/libfcs_near.a;${INSTALL_DIR}/lib/libfcs_gridsort.a;${INSTALL_DIR}/lib/libfcs_resort.a;${INSTALL_DIR}/lib/libfcs_redist.a;${INSTALL_DIR}/lib/libfcs_common.a;${INSTALL_DIR}/lib/libfcs_pnfft.a;${INSTALL_DIR}/lib/libfcs_pfft.a;${INSTALL_DIR}/lib/libfcs_fftw3_mpi.a;${INSTALL_DIR}/lib/libfcs_fftw3.a;MPI::MPI_Fortran;MPI::MPI_C")
+ target_link_libraries(lammps PRIVATE LAMMPS::SCAFACOS)
+ add_dependencies(LAMMPS::SCAFACOS scafacos_build)
+ if(NOT BUILD_SHARED_LIBS)
+ install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
- include_directories(${SCAFACOS_INCLUDE_DIRS})
+else()
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(SCAFACOS REQUIRED IMPORTED_TARGET scafacos)
+ target_link_libraries(lammps PRIVATE PkgConfig::SCAFACOS)
endif()
diff --git a/cmake/Modules/Packages/USER-SDPD.cmake b/cmake/Modules/Packages/USER-SDPD.cmake
index 530dcf2bd915446b24e5521e97f59b24504df340..c9f419d91849f1ebebc7aeaab91eea167255fcb8 100644
--- a/cmake/Modules/Packages/USER-SDPD.cmake
+++ b/cmake/Modules/Packages/USER-SDPD.cmake
@@ -1,13 +1,13 @@
# Fix rigid/meso requires RIGID to be installed
-if(PKG_USER-SDPD)
- set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD)
+set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD)
- get_property(hlist GLOBAL PROPERTY FIX)
- if(NOT PKG_RIGID)
- list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h)
- list(REMOVE_ITEM LIB_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp)
- endif()
- set_property(GLOBAL PROPERTY FIX "${hlist}")
-
- include_directories(${USER-SDPD_SOURCES_DIR})
+get_property(hlist GLOBAL PROPERTY FIX)
+if(NOT PKG_RIGID)
+ list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h)
+ get_target_property(LAMMPS_SOURCES lammps SOURCES)
+ list(REMOVE_ITEM LAMMPS_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp)
+ set_property(TARGET lammps PROPERTY SOURCES ${LAMMPS_SOURCES})
endif()
+set_property(GLOBAL PROPERTY FIX "${hlist}")
+
+target_include_directories(lammps PRIVATE ${USER-SDPD_SOURCES_DIR})
diff --git a/cmake/Modules/Packages/USER-SMD.cmake b/cmake/Modules/Packages/USER-SMD.cmake
index a868918e378649a501b4a616ba1bf0aafd49b2db..0a5165471c6b22949c1fe737d67fdb5f2c6b045a 100644
--- a/cmake/Modules/Packages/USER-SMD.cmake
+++ b/cmake/Modules/Packages/USER-SMD.cmake
@@ -1,28 +1,31 @@
-if(PKG_USER-SMD)
- find_package(Eigen3 NO_MODULE)
- if(EIGEN3_FOUND)
- set(DOWNLOAD_EIGEN3_DEFAULT OFF)
- else()
- set(DOWNLOAD_EIGEN3_DEFAULT ON)
+find_package(Eigen3 NO_MODULE)
+if(EIGEN3_FOUND)
+ set(DOWNLOAD_EIGEN3_DEFAULT OFF)
+else()
+ set(DOWNLOAD_EIGEN3_DEFAULT ON)
+endif()
+option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT})
+if(DOWNLOAD_EIGEN3)
+ message(STATUS "Eigen3 download requested - we will build our own")
+ include(ExternalProject)
+ ExternalProject_Add(Eigen3_build
+ URL http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz
+ URL_MD5 f2a417d083fe8ca4b8ed2bc613d20f07
+ CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
+ )
+ ExternalProject_get_property(Eigen3_build SOURCE_DIR)
+ add_library(LAMMPS::EIGEN3 INTERFACE IMPORTED)
+ set_target_properties(LAMMPS::EIGEN3 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}")
+ target_link_libraries(lammps PRIVATE LAMMPS::EIGEN3)
+ add_dependencies(LAMMPS::EIGEN3 Eigen3_build)
+ if(NOT BUILD_SHARED_LIBS)
+ install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
endif()
- option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT})
- if(DOWNLOAD_EIGEN3)
- message(STATUS "Eigen3 download requested - we will build our own")
- include(ExternalProject)
- ExternalProject_Add(Eigen3_build
- URL http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz
- URL_MD5 f2a417d083fe8ca4b8ed2bc613d20f07
- CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
- )
- ExternalProject_get_property(Eigen3_build SOURCE_DIR)
- set(EIGEN3_INCLUDE_DIR ${SOURCE_DIR})
- list(APPEND LAMMPS_DEPS Eigen3_build)
- else()
- find_package(Eigen3 NO_MODULE)
- mark_as_advanced(Eigen3_DIR)
- if(NOT EIGEN3_FOUND)
- message(FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it")
- endif()
+else()
+ find_package(Eigen3 NO_MODULE)
+ mark_as_advanced(Eigen3_DIR)
+ if(NOT EIGEN3_FOUND)
+ message(FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it")
endif()
- include_directories(${EIGEN3_INCLUDE_DIR})
+ target_link_libraries(lammps PRIVATE Eigen3::Eigen)
endif()
diff --git a/cmake/Modules/Packages/USER-VTK.cmake b/cmake/Modules/Packages/USER-VTK.cmake
index d264577ca2f77f5af3b2cbac590f4d9fc07500d9..8c4445167a10cf1e66c2e0444c7eb15afde85b12 100644
--- a/cmake/Modules/Packages/USER-VTK.cmake
+++ b/cmake/Modules/Packages/USER-VTK.cmake
@@ -1,6 +1,4 @@
-if(PKG_USER-VTK)
- find_package(VTK REQUIRED NO_MODULE)
- include(${VTK_USE_FILE})
- add_definitions(-DLAMMPS_VTK)
- list(APPEND LAMMPS_LINK_LIBS ${VTK_LIBRARIES})
-endif()
+find_package(VTK REQUIRED NO_MODULE)
+include(${VTK_USE_FILE})
+target_compile_definitions(lammps PRIVATE -DLAMMPS_VTK)
+target_link_libraries(lammps PRIVATE ${VTK_LIBRARIES})
diff --git a/cmake/Modules/Packages/VORONOI.cmake b/cmake/Modules/Packages/VORONOI.cmake
index 89fa70bf9801de4750fa84b2af6e64943e631815..4635466a50096808744d697def16a87c4fcf0255 100644
--- a/cmake/Modules/Packages/VORONOI.cmake
+++ b/cmake/Modules/Packages/VORONOI.cmake
@@ -1,45 +1,47 @@
-if(PKG_VORONOI)
- find_package(VORO)
- if(VORO_FOUND)
- set(DOWNLOAD_VORO_DEFAULT OFF)
+find_package(VORO)
+if(VORO_FOUND)
+ set(DOWNLOAD_VORO_DEFAULT OFF)
+else()
+ set(DOWNLOAD_VORO_DEFAULT ON)
+endif()
+option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" ${DOWNLOAD_VORO_DEFAULT})
+if(DOWNLOAD_VORO)
+ message(STATUS "Voro++ download requested - we will build our own")
+ include(ExternalProject)
+
+ if(BUILD_SHARED_LIBS)
+ set(VORO_BUILD_CFLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
else()
- set(DOWNLOAD_VORO_DEFAULT ON)
+ set(VORO_BUILD_CFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
endif()
- option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" ${DOWNLOAD_VORO_DEFAULT})
- if(DOWNLOAD_VORO)
- if(CMAKE_GENERATOR STREQUAL "Ninja")
- message(FATAL_ERROR "Cannot build downloaded Voro++ library with Ninja build tool")
- endif()
- message(STATUS "Voro++ download requested - we will build our own")
- include(ExternalProject)
-
- if(BUILD_SHARED_LIBS)
- set(VORO_BUILD_CFLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
- else()
- set(VORO_BUILD_CFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
- endif()
- if(APPLE)
- get_filename_component(VORO_CXX ${CMAKE_CXX_COMPILER} NAME_WE)
- set(VORO_BUILD_OPTIONS CXX=${VORO_CXX} CFLAGS=${VORO_BUILD_CFLAGS})
- else()
- set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS})
- endif()
-
- ExternalProject_Add(voro_build
- URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz
- URL_MD5 2338b824c3b7b25590e18e8df5d68af9
- CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} BUILD_IN_SOURCE 1 INSTALL_COMMAND ""
- )
- ExternalProject_get_property(voro_build SOURCE_DIR)
- set(VORO_LIBRARIES ${SOURCE_DIR}/src/libvoro++.a)
- set(VORO_INCLUDE_DIRS ${SOURCE_DIR}/src)
- list(APPEND LAMMPS_DEPS voro_build)
+ if(APPLE)
+ get_filename_component(VORO_CXX ${CMAKE_CXX_COMPILER} NAME_WE)
+ set(VORO_BUILD_OPTIONS CXX=${VORO_CXX} CFLAGS=${VORO_BUILD_CFLAGS})
else()
- find_package(VORO)
- if(NOT VORO_FOUND)
- message(FATAL_ERROR "Voro++ library not found. Help CMake to find it by setting VORO_LIBRARY and VORO_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it")
- endif()
+ set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS})
+ endif()
+
+ ExternalProject_Add(voro_build
+ URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz
+ URL_MD5 2338b824c3b7b25590e18e8df5d68af9
+ CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} BUILD_IN_SOURCE 1 INSTALL_COMMAND ""
+ BUILD_BYPRODUCTS /src/libvoro++.a
+ )
+ ExternalProject_get_property(voro_build SOURCE_DIR)
+ file(MAKE_DIRECTORY ${SOURCE_DIR}/src)
+ add_library(LAMMPS::VORO UNKNOWN IMPORTED)
+ set_target_properties(LAMMPS::VORO PROPERTIES
+ IMPORTED_LOCATION "${SOURCE_DIR}/src/libvoro++.a"
+ INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/src")
+ target_link_libraries(lammps PRIVATE LAMMPS::VORO)
+ add_dependencies(LAMMPS::VORO voro_build)
+ if(NOT BUILD_SHARED_LIBS)
+ install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
+ endif()
+else()
+ find_package(VORO)
+ if(NOT VORO_FOUND)
+ message(FATAL_ERROR "Voro++ library not found. Help CMake to find it by setting VORO_LIBRARY and VORO_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it")
endif()
- include_directories(${VORO_INCLUDE_DIRS})
- list(APPEND LAMMPS_LINK_LIBS ${VORO_LIBRARIES})
+ target_link_libraries(lammps PRIVATE VORO::VORO)
endif()
diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake
index 0eeef00fe9ab4b603fe319825662a6b827f46ac7..f0a5f4519d4c3367f38f0f81b784647407df9457 100644
--- a/cmake/Modules/Testing.cmake
+++ b/cmake/Modules/Testing.cmake
@@ -2,7 +2,7 @@
# Testing
###############################################################################
option(ENABLE_TESTING "Enable testing" OFF)
-if(ENABLE_TESTING AND BUILD_EXE)
+if(ENABLE_TESTING)
enable_testing()
option(LAMMPS_TESTING_SOURCE_DIR "Location of lammps-testing source directory" "")
option(LAMMPS_TESTING_GIT_TAG "Git tag of lammps-testing" "master")
@@ -28,7 +28,7 @@ if(ENABLE_TESTING AND BUILD_EXE)
"https://github.com/lammps/lammps-testing in LAMMPS_TESTING_SOURCE_DIR")
endif()
- add_test(ShowHelp ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -help)
+ add_test(NAME ShowHelp COMMAND $ -help)
if(EXISTS ${LAMMPS_TESTING_SOURCE_DIR})
message(STATUS "Running test discovery...")
@@ -42,8 +42,7 @@ if(ENABLE_TESTING AND BUILD_EXE)
string(REPLACE "-" "_" TEST_NAME ${TEST_NAME})
string(REPLACE "+" "_" TEST_NAME ${TEST_NAME})
set(TEST_NAME "test_core_${TEST_NAME}_serial")
- add_test(${TEST_NAME} ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -in ${SCRIPT_NAME})
- set_tests_properties(${TEST_NAME} PROPERTIES WORKING_DIRECTORY ${PARENT_DIR})
+ add_test(NAME ${TEST_NAME} COMMAND $ -in ${SCRIPT_NAME} WORKING_DIRECTORY ${PARENT_DIR})
endforeach()
list(LENGTH TEST_SCRIPTS NUM_TESTS)
diff --git a/cmake/README.md b/cmake/README.md
deleted file mode 100644
index 6255307ef32f36120eaefe6c1fea097cdab50824..0000000000000000000000000000000000000000
--- a/cmake/README.md
+++ /dev/null
@@ -1,2320 +0,0 @@
-# Building LAMMPS using CMake
-
-LAMMPS recently acquired support for building with CMake thanks to the efforts
-of Christoph Junghans (LANL) and Richard Berger (Temple U). One of the key
-strengths of CMake is that it can generate the necessary build system files of
-your own personal preference. It also enables using common development IDEs such
-as Eclipse, Visual Studio, QtCreator, Xcode and many more for LAMMPS
-development.
-
-CMake can both be used as a command-line (CLI) utility `cmake` or through one of
-its GUIs. `ccmake` is a text-based ui to configure and build CMake projects.
-`cmake-gui` is a graphical frontend for running CMake operations that works on
-Linux desktop environments, Windows and MacOS X.
-
-The following is a tutorial-style introduction in using the CMake system. It
-should give you the necessary foundation to understand how to do the most common
-tasks, act as a reference and provide examples of typical use cases.
-
-## Table of Contents
-
- * [Quick Start for the Impatient](#quick-start-for-the-impatient)
- * [Building LAMMPS using cmake](#building-lammps-using-cmake-1)
- * [Prerequisites](#prerequisites)
- * [Build directory vs. Source Directory](#build-directory-vs-source-directory)
- * [Defining and using presets](#defining-and-using-presets)
- * [Reference](#reference)
- * [Common CMake Configuration Options](#common-cmake-configuration-options)
- * [LAMMPS Configuration Options](#lammps-configuration-options)
- * [Parallelization and Accelerator Packages](#parallelization-and-accelerator-packages)
- * [Default Packages](#default-packages)
- * [Other Packages](#other-packages)
- * [User Packages](#user-packages)
- * [Package-Specific Configuration Options](#package-specific-configuration-options)
- * [KSPACE Package](#kspace-package)
- * [MKL](#mkl)
- * [FFTW3](#fftw3)
- * [BLAS](#blas)
- * [LAPACK](#lapack)
- * [PYTHON Package](#python-package)
- * [GPU Package](#gpu-package)
- * [MESSAGE Package](#message-package)
- * [MSCG Package](#mscg-package)
- * [VORONOI Package](#voronoi-package)
- * [USER-LATTE Package](#user-latte-package)
- * [USER-PLUMED Package](#user-plumed-package)
- * [USER-SCAFACOS Package](#user-scafacos-package)
- * [USER-SMD Package](#user-smd-package)
- * [Optional Features](#optional-features)
- * [zlib support](#zlib-support)
- * [JPEG support](#jpeg-support)
- * [PNG support](#png-support)
- * [GZIP support](#gzip-support)
- * [FFMPEG support](#ffmpeg-support)
- * [Compilers](#compilers)
- * [Building with GNU Compilers](#building-with-gnu-compilers)
- * [Building with Intel Compilers](#building-with-intel-compilers)
- * [Building with LLVM/Clang Compilers](#building-with-llvmclang-compilers)
-
-## Quick Start for the Impatient
-If you want to skip ahead and just run the compilation using `cmake`, please
-find a minimal example below. Together with the options reference below, this
-should get you started.
-
-```bash
-git clone https://github.com/lammps/lammps.git
-mkdir lammps/build
-cd lammps/build
-cmake [-D OPTION_A=VALUE_A -D OPTION_B=VALUE_B ...] ../cmake
-make
-```
-
-# Building LAMMPS using `cmake`
-
-## Prerequisites
-This tutorial assumes you are running in a command-line environment using a
-shell like Bash.
-
-* Linux: any terminal window will work
-* MacOS X: launch the Terminal app
-* Windows 10: install and run "Bash on Windows" (aka Ubuntu on Windows)
-
-Before we start, please download the latest and greatest version of LAMMPS from
-GitHub. You can either download it as a tarball or ZIP file, or via git. When
-you start with a fresh lammps directory, the contents should look like this:
-
-```bash
-$ ls
-bench doc lib potentials README tools
-cmake examples LICENSE python src
-```
-
-## Build directory vs. Source Directory
-
-By using CMake we separate building LAMMPS into multiple phases:
-
-1. **Configuration**: define which features we want to enable/disable and how it should be compiled
-2. **Compilation**: compile each source file and generate binaries and libraries based on the configuration
-3. **Installation** (Optional): finally we can install the generated binaries on our system
-
-In the GNU Make based build system of LAMMPS, configuration occurs by running
-special make targets like `make yes-MOLECULAR`. These targets modify the
-**source directory** (`src/`) directory by copying package files and patching
-Makefile. In some cases you are force to manually edit Makefiles to add compiler
-options and/or correct include directory and library paths.
-
-These edits and copy operations are no longer necessary when compiling with
-CMake. The source directory stays untouched, so you compile LAMMPS in many
-different variants using the same source code checkout. It enables true
-**out-of-source** builds.
-
-When using Cmake, you can compile in **any** folder outside of the source
-directory. Any working directory you choose becomes a so-called **build
-directory**. All configuration files and compilation results are stored in this
-folder. We recommend calling it something like `build/`.
-
-Let's have a look a quick example, where we get the greatest and latest version
-of LAMMPS from GitHub via git:
-```bash
-git clone https://github.com/lammps/lammps.git
-```
-
-We then create a new `build` folder and make it our current working directory:
-```
-mkdir lammps/build
-cd lammps/build
-```
-
-To configure LAMMPS we run `cmake` inside of this folder. However it requires at
-least one argument. `cmake` needs to read the LAMMPS `CMakeLists.txt` file to
-know what to do. This file is located in the `cmake/` subdirectory of the
-lammps checkout. To run `cmake` add the relative or absolute path to the `cmake/`
-directory as first argument.
-
-E.g., if the current working directory is `lammps/build` you can specify the
-relative path to `lammps/cmake` as follows:
-```
-cmake ../cmake
-```
-
-You could also specify the absolute path:
-```
-cmake /path/to/my/lammps/folder/cmake
-```
-
-Please note: **This does NOT compile the code!** Running cmake only configures
-the next build. It generates the necessary files to compile the code. On
-Unix/Linux it defaults to generating Makefiles. You can also choose other output
-formats to generate files for Eclipse, Xcode or Visual Studio which are
-supported on other platorms.
-
-To compile LAMMPS once the Makefiles are generated, simply type `make` in the
-build directory.
-
-```
-make
-```
-# Defining and using presets
-
-The CMake build exposes a lot of different options. In the old build system
-some of the package selections were possible by using special make target like
-`make yes-std` or `make no-lib`. Achieving a similar result with cmake requires
-specifying all options manually. This can quickly become a very long command
-line that is hard to handle. While these could be stored in a simple script
-file, there is another way of defining "presets" to compile LAMMPS in a certain
-way. Since the cmake build process - contrary to the conventional build system -
-includes the compilation of the bundled libraries into the standard build process,
-the grouping of those presets is somewhat different.
-
-A preset is a regular CMake script file that can use constructs such as
-variables, lists and for-loops to manipulate configuration options and create
-an [*initial cache*](https://cmake.org/cmake/help/v3.12/manual/cmake.1.html).
-Options must be set with the `CACHE` and `FORCE` flag to ensure they are
-considered even during a second cmake run.
-
-Such a file can then be passed to cmake via the `-C` flag. Several examples of
-presets can be found in the `cmake/presets` folder.
-
-```bash
-# build LAMMPS with all packages enabled which don't use external libraries and enable GPU package
-mkdir build
-cd build
-cmake -C ../cmake/presets/all_on.cmake -C ../cmake/presets/nolib.cmake -D PKG_GPU=on ../cmake
-```
-
-# Reference
-
-## Common CMake Configuration Options
-
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
CMAKE_INSTALL_PREFIX
-
Install location where LAMMPS files will be copied to. In the Unix/Linux case with Makefiles this controls what `make install` will do.
-
- Default setting is $HOME/.local.
-
-
-
-
CMAKE_BUILD_TYPE
-
Controls if debugging symbols are added to the generated binaries
-
-
-
RelWithDebInfo (default)
-
Release
-
Debug
-
MinSizeRel
-
-
-
-
-
CMAKE_VERBOSE_MAKEFILE
-
Enable verbose output from Makefile builds (useful for debugging), the same can be achived by adding `VERBOSE=1` to the `make` call.
-
-
-
off (default)
-
on
-
-
-
-
-
-
-
-## LAMMPS Configuration Options
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
LAMMPS_SIZE_LIMIT
-
Controls the integer sizes used by LAMMPS internally
-
-
-
LAMMPS_SMALLBIG (default)
-
32bit , 64bit
-
LAMMPS_SMALLSMALL
-
32bit , 32bit
-
LAMMPS_BIGBIG
-
64bit , 64bit
-
-
-
-
-
LAMMPS_LONGLONG_TO_LONG
-
Workaround if your system or MPI version does not recognize long long data types
-
-
-
off (default)
-
on
-
-
-
-
-
LAMMPS_MEMALIGN
-
controls the alignment of blocks of memory allocated by LAMMPS
-
-
-
64 (default)
-
-
-
-
-
LAMMPS_EXCEPTIONS
-
controls whether LAMMPS dies after an error or throws a C++ exception. This is particularly useful when running through the C library interface, since an error
- in LAMMPS then doesn't kill the parent process
-
-
-
off (default)
-
on
-
-
-
-
-
LAMMPS_MACHINE
-
allows appending a machine suffix to the generated LAMMPS binary
-
-
-
*none* (default)
-
-
-
-
-
LAMMPS_LIB_SUFFIX
-
allows appending a suffix to the generated LAMMPS library
-
-
-
*none* (default)
-
-
-
-
-
BUILD_LIB
-
control whether to build LAMMPS as a library
-
-
-
off (default)
-
on
-
-
-
-
-
BUILD_EXE
-
control whether to build LAMMPS executable
-
-
-
on (default)
-
off
-
-
-
-
-
BUILD_SHARED_LIBS
-
control whether to build LAMMPS as a shared-library
-
-
-
off (default)
-
on
-
-
-
-
-
BUILD_DOC
-
control whether to build LAMMPS documentation
-
-
-
off (default)
-
on
-
-
-
-
-
BUILD_TOOLS
-
control whether to build LAMMPS tools
-
-
-
off (default)
-
on
-
-
-
-
-
-
-## Parallelization and Accelerator Packages
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
BUILD_MPI
-
control whether to build LAMMPS with MPI support. This will look for
- `mpicxx` in your path and use this MPI implementation.
-
-
-
on (default, if found)
-
off
-
-
-
-
-
BUILD_OMP
-
control whether to build LAMMPS with OpenMP support.
-
-
-
on (default, if found)
-
off
-
-
-
-
-
PKG_OPT
-
- A handful of pair styles which are optimized for improved CPU performance on
- single or multiple cores. These include EAM, LJ, CHARMM, and Morse potentials.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-OMP
-
- Hundreds of pair, fix, compute, bond, angle, dihedral, improper, and kspace
- styles which are altered to enable threading on many-core CPUs via OpenMP
- directives.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-INTEL
-
- Dozens of pair, fix, bond, angle, dihedral, improper, and kspace styles which
- are optimized for Intel CPUs and KNLs (Knights Landing).
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_GPU
-
- Dozens of pair styles and a version of the PPPM long-range Coulombic solver
- optimized for GPUs. All such styles have a “gpu†as a suffix in their style
- name. The GPU code can be compiled with either CUDA or OpenCL, however the
- OpenCL variants are no longer actively maintained and only the CUDA versions
- are regularly tested.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_KOKKOS
-
Dozens of atom, pair, bond, angle, dihedral, improper, fix, compute styles adapted to compile using the Kokkos library which can convert them to OpenMP or CUDA code so that they run efficiently on multicore CPUs, KNLs, or GPUs.
-
-
-
off (default)
-
on
-
-
-
-
-
-
-## Default Packages
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
PKG_ASPHERE
-
Computes, time-integration fixes, and pair styles for aspherical particle models including ellipsoids, 2d lines, and 3d triangles.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_BODY
-
Body-style particles with internal structure. Computes, time-integration fixes, pair styles, as well as the body styles themselves.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_CLASS2
-
Bond, angle, dihedral, improper, and pair styles for the COMPASS CLASS2 molecular force field.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_COLLOID
-
Coarse-grained finite-size colloidal particles. Pair styles and fix wall styles for colloidal interactions. Includes the Fast Lubrication Dynamics (FLD) method for hydrodynamic interactions, which is a simplified approximation to Stokesian dynamics.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_COMPRESS
-
Compressed output of dump files via the zlib compression library, using dump styles with a “gz†in their style name.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_CORESHELL
-
Compute and pair styles that implement the adiabatic core/shell model for polarizability. The pair styles augment Born, Buckingham, and Lennard-Jones styles with core/shell capabilities. The compute temp/cs command calculates the temperature of a system with core/shell particles.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_DIPOLE
-
An atom style and several pair styles for point dipole models with short-range or long-range interactions.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_GRANULAR
-
Pair styles and fixes for finite-size granular particles, which interact with each other and boundaries via frictional and dissipative potentials.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_KSPACE
-
A variety of long-range Coulombic solvers, as well as pair styles which compute the corresponding short-range pairwise Coulombic interactions. These include Ewald, particle-particle particle-mesh (PPPM), and multilevel summation method (MSM) solvers.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_MANYBODY
-
- A variety of manybody and bond-order potentials. These include (AI)REBO, BOP,
- EAM, EIM, Stillinger-Weber, and Tersoff potentials.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_MC
-
- Several fixes and a pair style that have Monte Carlo (MC) or MC-like
- attributes. These include fixes for creating, breaking, and swapping bonds,
- for performing atomic swaps, and performing grand-canonical MC (GCMC) in
- conjuction with dynamics.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_MISC
-
- A variety of compute, fix, pair, dump styles with specialized capabilities that
- don’t align with other packages.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_MOLECULE
-
- A large number of atom, pair, bond, angle, dihedral, improper styles that are
- used to model molecular systems with fixed covalent bonds. The pair styles
- include the Dreiding (hydrogen-bonding) and CHARMM force fields, and a TIP4P
- water model.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_PERI
-
- An atom style, several pair styles which implement different Peridynamics
- materials models, and several computes which calculate diagnostics.
- Peridynamics is a a particle-based meshless continuum model.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_QEQ
-
- Several fixes for performing charge equilibration (QEq) via different
- algorithms. These can be used with pair styles that perform QEq as part of
- their formulation.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_REPLICA
-
- A collection of multi-replica methods which can be used when running multiple
- LAMMPS simulations (replicas). See Section 6.5 for an overview of how to run
- multi-replica simulations in LAMMPS. Methods in the package include nudged
- elastic band (NEB), parallel replica dynamics (PRD), temperature accelerated
- dynamics (TAD), parallel tempering, and a verlet/split algorithm for
- performing long-range Coulombics on one set of processors, and the remainder
- of the force field calcalation on another set.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_RIGID
-
- Fixes which enforce rigid constraints on collections of atoms or particles.
- This includes SHAKE and RATTLE, as well as varous rigid-body integrators for a
- few large bodies or many small bodies. Also several computes which calculate
- properties of rigid bodies.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_SHOCK
-
- Fixes for running impact simulations where a shock-wave passes through a
- material.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_SPIN
-
Model atomic magnetic spins classically, coupled to atoms moving in the usual manner via MD. Various pair, fix, and compute styles.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_SNAP
-
- A pair style for the spectral neighbor analysis potential (SNAP). SNAP is
- methodology for deriving a highly accurate classical potential fit to a large
- archive of quantum mechanical (DFT) data. Also several computes which analyze
- attributes of the potential.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_SRD
-
- A pair of fixes which implement the Stochastic Rotation Dynamics (SRD) method
- for coarse-graining of a solvent, typically around large colloidal particles.
-
-
-
-
off (default)
-
on
-
-
-
-
-
-
-## Other Packages
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
PKG_KIM
-
A pair_style kim command which is a wrapper on the Knowledge Base for Interatomic Models (KIM) repository of interatomic potentials, enabling any of them to be used in LAMMPS simulations.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_PYTHON
-
Enable support for Python scripting inside of LAMMPS.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_MESSAGE
-
Commands to use LAMMPS as either a client or server and couple it to another application.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_MSCG
-
- A fix mscg command which can parameterize a Multi-Scale Coarse-Graining (MSCG)
- model using the open-source MS-CG library.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_MPIIO
-
- Support for parallel output/input of dump and restart files via the MPIIO library.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_POEMS
-
- A fix that wraps the Parallelizable Open source Efficient Multibody Software
- (POEMS) library, which is able to simulate the dynamics of articulated body
- systems. These are systems with multiple rigid bodies (collections of
- particles) whose motion is coupled by connections at hinge points.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_LATTE
-
- A fix command which wraps the LATTE DFTB code, so that molecular dynamics can
- be run with LAMMPS using density-functional tight-binding quantum forces
- calculated by LATTE.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_VORONOI
-
- A compute command which calculates the Voronoi tesselation of a collection of atoms by wrapping the Voro++ library. This can be used to calculate the local volume or each atoms or its near neighbors.
-
-
-
-
off (default)
-
on
-
-
-
-
-
-
-## User Packages
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
PKG_USER-ADIOS
-
ADIOS is a high-performance I/O library. This package implements the dump “atom/adios†and dump “custom/adios†commands to write data using the ADIOS library.
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-ATC
-
- ATC stands for atoms-to-continuum. This package implements a fix atc command
- to either couple molecular dynamics with continuum finite element equations or
- perform on-the-fly conversion of atomic information to continuum fields.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-AWPMD
-
- AWPMD stands for Antisymmetrized Wave Packet Molecular Dynamics. This package
- implements an atom, pair, and fix style which allows electrons to be treated
- as explicit particles in a classical molecular dynamics model.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-BOCS
-
- This package provides fix bocs, a modified version of fix npt which includes the pressure correction to the barostat as outlined in: N. J. H. Dunn and W. G. Noid, “Bottom-up coarse-grained models that accurately describe the structure, pressure, and compressibility of molecular liquids,†J. Chem. Phys. 143, 243148 (2015).
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-CGDNA
-
- Several pair styles, a bond style, and integration fixes for coarse-grained
- models of single- and double-stranded DNA based on the oxDNA model of Doye,
- Louis and Ouldridge at the University of Oxford. This includes Langevin-type
- rigid-body integrators with improved stability.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-CGSDK
-
- Several pair styles and an angle style which implement the coarse-grained SDK
- model of Shinoda, DeVane, and Klein which enables simulation of ionic liquids,
- electrolytes, lipids and charged amino acids.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-COLVARS
-
- COLVARS stands for collective variables, which can be used to implement
- various enhanced sampling methods, including Adaptive Biasing Force,
- Metadynamics, Steered MD, Umbrella Sampling and Restraints. A fix colvars
- command is implemented which wraps a COLVARS library, which implements these
- methods. simulations.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-DIFFRACTION
-
- Two computes and a fix for calculating x-ray and electron diffraction
- intensities based on kinematic diffraction theory.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-DPD
-
- DPD stands for dissipative particle dynamics. This package implements
- coarse-grained DPD-based models for energetic, reactive molecular crystalline
- materials. It includes many pair styles specific to these systems, including
- for reactive DPD, where each particle has internal state for multiple species
- and a coupled set of chemical reaction ODEs are integrated each timestep.
- Highly accurate time integrators for isothermal, isoenergetic, isobaric and
- isenthalpic conditions are included. These enable long timesteps via the
- Shardlow splitting algorithm.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-DRUDE
-
- Fixes, pair styles, and a compute to simulate thermalized Drude oscillators as
- a model of polarization.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-EFF
-
- EFF stands for electron force field which allows a classical MD code to model
- electrons as particles of variable radius. This package contains atom, pair,
- fix and compute styles which implement the eFF as described in A.
- Jaramillo-Botero, J. Su, Q. An, and W.A. Goddard III, JCC, 2010. The eFF
- potential was first introduced by Su and Goddard, in 2007.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-FEP
-
- FEP stands for free energy perturbation. This package provides methods for
- performing FEP simulations by using a fix adapt/fep command with soft-core
- pair potentials, which have a “soft†in their style name.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-H5MD
-
- H5MD stands for HDF5 for MD. HDF5 is a portable, binary, self-describing file
- format, used by many scientific simulations. H5MD is a format for molecular
- simulations, built on top of HDF5. This package implements a dump h5md command
- to output LAMMPS snapshots in this format.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-LB
-
- Fixes which implement a background Lattice-Boltzmann (LB) fluid, which can be
- used to model MD particles influenced by hydrodynamic forces.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-MANIFOLD
-
- Several fixes and a “manifold†class which enable simulations of particles
- constrained to a manifold (a 2D surface within the 3D simulation box). This is
- done by applying the RATTLE constraint algorithm to formulate single-particle
- constraint functions g(xi,yi,zi) = 0 and their derivative (i.e. the normal of
- the manifold) n = grad(g).
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-MEAMC
-
- A pair style for the modified embedded atom (MEAM) potential translated from
- the Fortran version in the MEAM package to plain C++. In contrast to the MEAM
- package, no library needs to be compiled and the pair style can be
- instantiated multiple times.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-MESO
-
- Several extensions of the the dissipative particle dynamics (DPD) method.
- Specifically, energy-conserving DPD (eDPD) that can model non-isothermal
- processes, many-body DPD (mDPD) for simulating vapor-liquid coexistence, and
- transport DPD (tDPD) for modeling advection-diffusion-reaction systems. The
- equations of motion of these DPD extensions are integrated through a modified
- velocity-Verlet (MVV) algorithm.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-MGPT
-
- A pair style which provides a fast implementation of the quantum-based MGPT
- multi-ion potentials. The MGPT or model GPT method derives from
- first-principles DFT-based generalized pseudopotential theory (GPT) through a
- series of systematic approximations valid for mid-period transition metals
- with nearly half-filled d bands. The MGPT method was originally developed by
- John Moriarty at LLNL. The pair style in this package calculates forces and
- energies using an optimized matrix-MGPT algorithm due to Tomas Oppelstrup at
- LLNL.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-MISC
-
- A potpourri of (mostly) unrelated features contributed to LAMMPS by users.
- Each feature is a single fix, compute, pair, bond, angle, dihedral, improper,
- or command style.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-MOFFF
-
- Pair, angle and improper styles needed to employ the MOF-FF force field by
- Schmid and coworkers with LAMMPS. MOF-FF is a first principles derived force
- field with the primary aim to simulate MOFs and related porous framework
- materials, using spherical Gaussian charges. It is described in S. Bureekaew
- et al., Phys. Stat. Sol. B 2013, 250, 1128-1141. For the usage of MOF-FF see
- the example in the example directory as well as the MOF+ website.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-MOLFILE
-
- A dump molfile command which uses molfile plugins that are bundled with the
- VMD molecular visualization and analysis program, to enable LAMMPS to dump
- snapshots in formats compatible with various molecular simulation tools.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-NETCDF
-
- Dump styles for writing NetCDF formatted dump files. NetCDF is a portable,
- binary, self-describing file format developed on top of HDF5. The file
- contents follow the AMBER NetCDF trajectory conventions
- (http://ambermd.org/netcdf/nctraj.xhtml), but include extensions.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-PHONON
-
- A fix phonon command that calculates dynamical matrices, which can then be
- used to compute phonon dispersion relations, directly from molecular dynamics
- simulations.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-PLUMED
-
- The fix plumed command allows you to use the PLUMED free energy plugin for molecular dynamics to analyze and bias your LAMMPS trajectory on the fly. The PLUMED library is called from within the LAMMPS input script by using the fix plumed command.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-PTM
-
- A compute ptm/atom command that calculates local structure characterization using the Polyhedral Template Matching methodology.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-QTB
-
- Two fixes which provide a self-consistent quantum treatment of vibrational modes in a classical molecular dynamics simulation. By coupling the MD simulation to a colored thermostat, it introduces zero point energy into the system, altering the energy power spectrum and the heat capacity to account for their quantum nature. This is useful when modeling systems at temperatures lower than their classical limits or when temperatures ramp across the classical limits in a simulation.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-QUIP
-
- A pair_style quip command which wraps the QUIP libAtoms library, which
- includes a variety of interatomic potentials, including Gaussian Approximation
- Potential (GAP) models developed by the Cambridge University group.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-QMMM
-
- A fix qmmm command which allows LAMMPS to be used in a QM/MM simulation,
- currently only in combination with the Quantum ESPRESSO package.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-REAXC
-
- A pair style which implements the ReaxFF potential in C/C++ (in contrast to
- the REAX package and its Fortran library). ReaxFF is universal reactive force
- field. See the src/USER-REAXC/README file for more info on differences between
- the two packages. Also two fixes for monitoring molecules as bonds are created
- and destroyed.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-SCAFACOS
-
- A KSpace style which wraps the ScaFaCoS Coulomb solver library to compute long-range Coulombic interactions.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-SDPD
-
- A pair style for smoothed dissipative particle dynamics (SDPD), which is an
- extension of smoothed particle hydrodynamics (SPH) to mesoscale where thermal
- fluctuations are important (see the USER-SPH package). Also two fixes for
- moving and rigid body integration of SPH/SDPD particles (particles of
- atom_style meso).
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-SMD
-
- An atom style, fixes, computes, and several pair styles which implements
- smoothed Mach dynamics (SMD) for solids, which is a model related to smoothed
- particle hydrodynamics (SPH) for liquids (see the USER-SPH package).
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-SMTBQ
-
- A pair style which implements a Second Moment Tight Binding model with QEq
- charge equilibration (SMTBQ) potential for the description of ionocovalent
- bonds in oxides.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-SPH
-
- An atom style, fixes, computes, and several pair styles which implements
- smoothed particle hydrodynamics (SPH) for liquids. See the related USER-SMD
- package package for smooth Mach dynamics (SMD) for solids.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-TALLY
-
- Several compute styles that can be called when pairwise interactions are
- calculated to tally information (forces, heat flux, energy, stress, etc) about
- individual interactions.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-UEF
-
- A fix style for the integration of the equations of motion under extensional
- flow with proper boundary conditions, as well as several supporting compute
- styles and an output option.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-VTK
-
- A dump vtk command which outputs snapshot info in the VTK format, enabling
- visualization by Paraview or other visualization packages.
-
-
-
-
off (default)
-
on
-
-
-
-
-
PKG_USER-YAFF
-
- Some potentials that are also implemented in the Yet Another Force Field (YAFF) code.
- The expressions and their use are discussed in the following papers:
-
If either MKL or FFTW is selected cmake will try to locate
- these libraries automatically. To control which one should be used please see
- the options below for each FFT library. Otherwise it will default to KISS
- FFT.
How to support Long-range thread mode in Verlet integration
-
-
-
threads (default, if pthreads available)
-
none (default, if pthreads not available)
-
c++11
-
-
-
-
-
-
-### GPU Package
-The GPU package builds a support library which can either use OpenCL or CUDA as
-target API.
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
GPU_API
-
API used by GPU package
-
-
-
opencl (default)
-
cuda
-
-
-
-
-
GPU_PREC
-
Precision size used by GPU package kernels
-
-
-
mixed (default)
-
single
-
double
-
-
-
-
-
OCL_TUNE (OpenCL only)
-
Tuning target for OpenCL driver code
-
-
-
generic (default)
-
intel (Intel CPU)
-
phi (Intel Xeon Phi)
-
fermi (NVIDIA)
-
kepler (NVIDIA)
-
cypress (AMD)
-
-
-
-
-
GPU_ARCH (CUDA only)
-
CUDA SM architecture targeted by GPU package
-
-
-
sm_20 (Fermi)
-
sm_30 (Kepler) (default)
-
sm_50 (Maxwell)
-
sm_60 (Pascal)
-
sm_70 (Volta)
-
sm_75 (Turing)
-
-
-
-
-
CUDPP_OPT (CUDA only)
-
Enable CUDA Performance Primitives Optimizations
-
-
-
on (default)
-
off
-
-
-
-
-
CUDA_MPS_SUPPORT (CUDA only)
-
Enable tweaks for running with Nvidia CUDA Multi-process services daemon
-
-
-
on
-
off (default)
-
-
-
-
-
BIN2C (CUDA only)
-
Path to bin2c executable, will automatically pick up the first one in your $PATH.
-
(automatic)
-
-
-
-
-### KIM Package
-
-Requires installation of the KIM library with API v2
-
-If `DOWNLOAD_KIM` is set, the KIM library will be downloaded and built inside
-the CMake build directory. If the KIM library is already on your system (in a
-location CMake cannot find it), set the `PKG_CONFIG_PATH` environment variable
-so that `libkim-api` can be found.
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
DOWNLOAD_KIM
-
Download KIM API v2 and compile it as part of the build.
-
-
-
off (default)
-
on
-
-
-
-
-
-
-### MESSAGE Package
-
-This package can optionally include support for messaging via sockets, using the open-source [ZeroMQ library](http://zeromq.org/), which must be installed on your system.
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
MESSAGE_ZMQ
-
Build with ZeroMQ support
-
-
-
off (default)
-
on
-
-
-
-
-
ZMQ_LIBRARY
-
- ZMQ library file (only needed if at custom location)
-
-
-
-
-
-
ZMG_INCLUDE_DIR
-
- Provide include directory of existing ZMQ installation (only needed if at custom location)
-
-
-
-
-
-
-
-### MSCG Package
-
-Requires installation of the MSCG library
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
DOWNLOAD_MSCG
-
Download MSCG and compile it as part of the build
-
-
-
off (default)
-
on
-
-
-
-
-
MSCG_LIBRARY
-
- MSCG library file (only needed if at custom location)
-
-
-
-
-
-
MSCG_INCLUDE_DIR
-
- Provide include directory of existing MSCG installation (only needed if at custom location)
-
-
-
-
-
-
-
-### VORONOI Package
-
-Requires installation of the Voro++ library
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
DOWNLOAD_VORO
-
Download Voro++ and compile it as part of the build
-
-
-
off (default)
-
on
-
-
-
-
-
VORO_LIBRARY
-
- Voro++ library file (only needed if at custom location)
-
-
-
-
-
-
VORO_INCLUDE_DIR
-
- Provide include directory of existing Voro++ installation (only needed if at custom location)
-
-
-
-
-
-
-
-### USER-COLVARS Package
-
-Requires a C++11 compiler to compile with the Lepton library included.
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
COLVARS_LEPTON
-
Enable the use of the Lepton library inside the Colvars library.
-
-
-
on (default)
-
off
-
-
-
-
-
-
-### USER-LATTE Package
-
-Requires installation of the LATTE library
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
DOWNLOAD_LATTE
-
Download LATTE and compile it as part of the build
-
-
-
off (default)
-
on
-
-
-
-
-
LATTE_LIBRARY
-
- LATTE library file (only needed if at custom location)
-
-
-
-
-
-
-
-### USER-PLUMED Package
-
-Requires installation of the PLUMED library
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
DOWNLOAD_PLUMED
-
Download PLUMED and compile it as part of the build
-
-
-
off (default)
-
on
-
-
-
-
-
PLUMED_MODE
-
- Determines the linkage mode for the PLUMED library.
-
-
-
-
static (default)
-
shared
-
runtime
-
-
-
-
-
-
-### USER-LATTE Package
-
-Requires installation of the LATTE library
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
DOWNLOAD_LATTE
-
Download LATTE and compile it as part of the build
-
-
-
off (default)
-
on
-
-
-
-
-
LATTE_LIBRARY
-
- LATTE library file (only needed if at custom location)
-
-
-
-
-
-
-
-### USER-SMD Package
-
-Requires installation of the Eigen3 library
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
DOWNLOAD_EIGEN3
-
Download Eigen3 and compile it as part of the build
-
-
-
off (default)
-
on
-
-
-
-
-
EIGEN3_INCLUDE_DIR
-
- Provide include directory of existing Eigen3 installation (only needed if at custom location)
-
-
-
-
-
-
-
-
-### USER-SCAFACOS Package
-
-To build with this package, you must download and build the [ScaFaCoS Coulomb solver library](http://www.scafacos.de/)
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
DOWNLOAD_SCAFACOS
-
Download SCAFACOS and compile it as part of the build
-
-
-
off (default)
-
on
-
-
-
-
-
SCAFACOS_LIBRARY
-
- SCAFACOS library file (only needed if at custom location)
-
-
-
-
-
-
SCAFACOS_INCLUDE_DIR
-
- SCAFACOS include directory (only needed if at custom location)
-
-
-
-
-
-
-
-## Optional Features
-
-### zlib support
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
ZLIB_INCLUDE_DIR
-
-
-
-
-
-
ZLIB_LIBRARIES
-
-
-
-
-
-
-
-### JPEG support
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
WITH_JPEG
-
Enables/Disable JPEG support in LAMMPS
-
-
-
yes (default, if found)
-
no
-
-
-
-
-
JPEG_INCLUDE_DIR
-
-
-
-
-
-
JPEG_LIBRARIES
-
-
-
-
-
-
-
-### PNG support
-(requires zlib support)
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
WITH_PNG
-
Enables/Disable PNG support in LAMMPS
-
-
-
yes (default, if found)
-
no
-
-
-
-
-
PNG_INCLUDE_DIR
-
-
-
-
-
-
PNG_LIBRARIES
-
-
-
-
-
-
-
-### GZIP support
-
-requires `gzip` to be in your `PATH`
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
WITH_GZIP
-
Enables/Disable GZIP support in LAMMPS
-
-
-
yes (default, if found)
-
no
-
-
-
-
-
GZIP_EXECUTABLE
-
Path to gzip executable, will automatically pick up the first one in your $PATH.
-
(automatic)
-
-
-
-
-### FFMPEG support
-
-requires `ffmpeg` to be in your `PATH`
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
WITH_FFMPEG
-
Enables/Disable FFMPEG support in LAMMPS
-
-
-
yes (default, if found)
-
no
-
-
-
-
-
FFMPEG_EXECUTABLE
-
Path to ffmpeg executable, will automatically pick up the first one in your $PATH.
-
(automatic)
-
-
-
-
-
-## Compilers
-
-By default, `cmake` will use your environment C/C++/Fortran compilers for a
-build. It uses the `CC`, `CXX` and `FC` environment variables to detect which
-compilers should be used. However, these values will be cached after the first
-run of `cmake`. Subsequent runs of `cmake` will ignore changes in these
-environment variables. To ensure the correct values are used you avoid the
-cache by setting the `CMAKE_C_COMPILER`, `CMAKE_CXX_COMPILER`,
-`CMAKE_Fortran_COMPILER` options directly.
-
-
-
-
-
Option
-
Description
-
Default
-
-
-
-
-
CMAKE_C_COMPILER
-
C Compiler which should be used by CMake
-
value of `CC` environment variable at first `cmake` run
-
-
-
CMAKE_CXX_COMPILER
-
C++ compiler which should be used by CMake
-
- value of `CXX` environment variable at first `cmake` run
-
-
-
-
CMAKE_Fortran_COMPILER
-
C++ compiler which should be used by CMake
-
- value of `FC` environment variable at first `cmake` run
-
-
-
-
CXX_COMPILER_LAUNCHER
-
CMake will run this tool and pass the compiler and its arguments to the tool. Some example tools are distcc and ccache.
-
- (empty)
-
-
-
-
-
-### Building with GNU Compilers
-
-```bash
-cmake -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D CMAKE_Fortran_COMPILER=gfortran ../cmake
-```
-
-### Building with Intel Compilers
-
-```bash
-cmake -D CMAKE_C_COMPILER=icc -D CMAKE_CXX_COMPILER=icpc -D CMAKE_Fortran_COMPILER=ifort ../cmake
-```
-
-
-### Building with LLVM/Clang Compilers
-
-```bash
-cmake -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_Fortran_COMPILER=flang ../cmake
-```
-
-## LAMMPS Developer Options
-
-
-
-
-
-
Option
-
Description
-
Values
-
-
-
-
-
ENABLE_TESTING
-
Control wheather to add tests via CTest
-
-
-
off (default)
-
on
-
-
-
-
-
LAMMPS_TESTING_SOURCE_DIR
-
Custom location of lammps-testing repository (optional). If not specified it will download it via Git
-
-
-
-
-
LAMMPS_TESTING_GIT_TAG
-
If lammps-testing repository is cloned, this is the tag/commit that will be checked out
-
-
-
master (default)
-
-
-
-
-
ENABLE_COVERAGE
-
Enables code coverage support via gcov and adds a gcovr build target to generate a coverage report.
-
-
-
off (default)
-
on
-
-
-
-
-
ENABLE_SANITIZE_ADDRESS
-
Enables Address Sanitizer support when compiling using GCC or Clang for detecting memory leaks in binaries while running them. See https://clang.llvm.org/docs/AddressSanitizer.html
-
-
-
off (default)
-
on
-
-
-
-
-
ENABLE_SANITIZE_UNDEFINED
-
Enables Undefined Behavior Sanitizer support when compiling using GCC or Clang for detecting code that is running into undefined behavior of the language. See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
-
-
-
off (default)
-
on
-
-
-
-
-
ENABLE_SANITIZE_THREAD
-
Enables Thread Sanitizer support when compiling using GCC or Clang for detecting data races in binaries while running them. See https://clang.llvm.org/docs/ThreadSanitizer.html
This is the documentation for the LAMMPS 2001 version, written in F90,
-which has been superceded by more current versions. See the LAMMPS WWW
Site for more information.
The src directory contains the F90 and C source files for LAMMPS as
well as several sample Makefiles for different machines. To make LAMMPS
-for a specfic machine, you simply type
+for a specific machine, you simply type
make machine
diff --git a/doc/src/2001/input_commands.html b/doc/src/2001/input_commands.html
index 797d6bec4e92b81c71ee6d76f6107dcdf1105be7..62ef5a5120fab1a2ce421b76ca92604fa486a14b 100644
--- a/doc/src/2001/input_commands.html
+++ b/doc/src/2001/input_commands.html
@@ -1079,7 +1079,7 @@ for style aveforce, average force on the group of fixed atoms is computed,
to new total value -> has effect of applying same force to entire group
of atoms
thermostatting constraints (rescale, hoover/drag, langevin) cannot be used in
- conjuction with global "temp control", since they conflict and will
+ conjunction with global "temp control", since they conflict and will
cause atom velocities to be reset twice
thermostatting constraints (rescale, hoover/drag, langevin) cannot be used
when performing a minimization
@@ -1089,7 +1089,7 @@ meaning of rescale and Langevin thermostatting coefficients is same as in
"temp control" command
for rescale style, it can be used as a coarse temperature rescaler,
for example "rescale 200.0 300.0 100 10.0 1.0" will ramp the temperature
- up during the simulation, resetting it to the target temperatue as needed
+ up during the simulation, resetting it to the target temperature as needed
for rescale style, it can be used to create an instantaneous
drag force that slowly rescales the temperature without oscillation,
for example "rescale 300.0 300.0 1 0.0 0.0001" will force (or keep)
@@ -1952,7 +1952,7 @@ for rescale style, the amount of rescaling is contfolled by the fractional
to halfway between the current and target temperature
for rescale style, it can be used as a coarse temperature rescaler,
for example "rescale 200.0 300.0 100 10.0 1.0" will ramp the temperature
- up during the simulation, resetting it to the target temperatue as needed
+ up during the simulation, resetting it to the target temperature as needed
for rescale style, it can be used to create an instantaneous
drag force that slowly rescales the temperature without oscillation,
for example "rescale 300.0 300.0 1 0.0 0.0001" will force (or keep)
diff --git a/doc/src/99/README.html b/doc/src/99/README.html
index 528c1e161debec02bf6c11115be0b1520350b270..d85f23970fc7b560a5a844630f26f4a8d6846048 100644
--- a/doc/src/99/README.html
+++ b/doc/src/99/README.html
@@ -10,7 +10,7 @@ LAMMPS
LAMMPS = Large-scale Atomic/Molecular Massively Parallel Simulator
This is the documentation for the LAMMPS 99 version, written in F77,
-which has been superceded by more current versions. See the LAMMPS WWW
Site for more information.
The src directory contains the F77 and C source files for LAMMPS as
well as several sample Makefiles for different machines. To make LAMMPS
-for a specfic machine, you simply type
+for a specific machine, you simply type
make machine
diff --git a/doc/src/99/input_commands.html b/doc/src/99/input_commands.html
index baea02b5c2cebe620f9ec2083ae5540e214a2ef0..5ece32d52b6fcac3918034ab772dd9dcf9c2d7fd 100644
--- a/doc/src/99/input_commands.html
+++ b/doc/src/99/input_commands.html
@@ -430,7 +430,7 @@ accuracy criterion effectively determines how many k-space vectors are used
for PPPM, accuracy criterion determines mesh spacing (see "particle mesh"
command)
for PPPM, must be running on power-of-2 number of processors for FFTs
-must use periodic boundary conditions in conjuction with Ewald and PPPM
+must use periodic boundary conditions in conjunction with Ewald and PPPM
cannot use any styles other than none with nonbond style = lj/shift or
nonbond style = soft
Coulomb style = smooth should be used with nonbond style = lj/switch,
@@ -772,7 +772,7 @@ for style aveforce, average force on the group of fixed atoms is computed,
to new total value -> has effect of applying same force to entire group
of atoms
thermostatting constraints (rescale, langevin, nose/hoover) cannot be used in
- conjuction with global "temp control", since they conflict and will
+ conjunction with global "temp control", since they conflict and will
cause atom velocities to be reset twice
if multiple Langevin constraints are specified the Marsaglia RNG will
only use the last RNG seed specified for initialization
diff --git a/doc/src/Build.rst b/doc/src/Build.rst
index 2eba3ddd48cd580447c1f0e46ff843e7ebbc6796..441af79009ad86069ee866aec82e001056fab0e2 100644
--- a/doc/src/Build.rst
+++ b/doc/src/Build.rst
@@ -1,13 +1,14 @@
Build LAMMPS
************
-LAMMPS can be built as an executable or library from source code via
-either traditional makefiles (which may require manual editing)
-for use with GNU make or gmake, or a build environment generated by CMake
-(Unix Makefiles, Xcode, Visual Studio, KDevelop or more). As an
-alternative you can download a package with pre-built executables
-as described on the :doc:`Install ` doc page.
+LAMMPS is built as a library and an executable from source code using
+either traditional makefiles for use with GNU make (which may require
+manual editing), or using a build environment generated by CMake (Unix
+Makefiles, Ninja, Xcode, Visual Studio, KDevelop, CodeBlocks and more).
+As an alternative you can download a package with pre-built executables
+or automated build trees as described on the :doc:`Install `
+doc page.
.. toctree::
:maxdepth: 1
@@ -21,8 +22,3 @@ as described on the :doc:`Install ` doc page.
Build_extras
Build_windows
Build_development
-
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst
index cf77c81e692b0d4dd9440d94f6d54c0fbae42fdd..335c1a51899836d3f818aebdb2f89c696111bfde 100644
--- a/doc/src/Build_basics.rst
+++ b/doc/src/Build_basics.rst
@@ -6,159 +6,203 @@ CMake and make:
* :ref:`Serial vs parallel build `
* :ref:`Choice of compiler and compile/link options `
-* :ref:`Build LAMMPS as an executable or a library `
+* :ref:`Build the LAMMPS executable and library `
+* :ref:`Including and removing debug support `
* :ref:`Build the LAMMPS documentation `
* :ref:`Install LAMMPS after a build `
-
----------
-
.. _serial:
Serial vs parallel build
--------------------------------------
+------------------------
-LAMMPS can be built to run in parallel using the ubiquitous `MPI (message-passing interface) `_
-library. Or it can built to run on a single processor (serial)
-without MPI. It can also be built with support for OpenMP threading
-(see more discussion below).
+LAMMPS is written to use the ubiquitous `MPI (Message Passing Interface)
+`_ library API
+for distributed memory parallel computation. You need to have such a
+library installed for building and running LAMMPS in parallel using a
+domain decomposition parallelization. It is compatible with the MPI
+standard version 2.x and later. LAMMPS can also be built into a
+"serial" executable for use with a single processor using the bundled
+MPI STUBS library.
-**CMake variables**\ :
+Independent of the distributed memory MPI parallelization, parts of
+LAMMPS are also written with support for shared memory parallelization
+using the `OpenMP `_ threading
+standard. A more detailed discussion of that is below.
+**CMake build**\ :
-.. parsed-literal::
+.. code-block:: bash
-D BUILD_MPI=value # yes or no, default is yes if CMake finds MPI, else no
- -D BUILD_OMP=value # yes or no (default)
+ -D BUILD_OMP=value # yes or no, default is yes if a compatible compiler is detected
-D LAMMPS_MACHINE=name # name = mpi, serial, mybox, titan, laptop, etc
# no default value
-The executable created by CMake (after running make) is lmp\_name. If
-the LAMMPS\_MACHINE variable is not specified, the executable is just
-lmp. Using BUILD\_MPI=no will produce a serial executable.
+The executable created by CMake (after running make) is named ``lmp`` unless
+the ``LAMMPS_MACHINE`` option is set. When setting ``LAMMPS_MACHINE=name``
+the executable will be called ``lmp_name``. Using ``BUILD_MPI=no`` will
+enforce building a serial executable using the MPI STUBS library.
**Traditional make**\ :
+The build with traditional makefiles has to be done inside the source folder ``src``.
-.. parsed-literal::
+.. code-block:: bash
- cd lammps/src
make mpi # parallel build, produces lmp_mpi using Makefile.mpi
make serial # serial build, produces lmp_serial using Makefile/serial
- make mybox # uses Makefile.mybox to produce lmp_mybox
-
-Serial build (see src/MAKE/Makefile.serial):
-
-
-.. parsed-literal::
+ make mybox # uses Makefile.mybox to produce lmp_mybox
+
+Any ``make machine`` command will look up the make settings from a file
+``Makefile.machine`` in the folder ``src/MAKE`` or one of its
+sub-directories ``MINE``, ``MACHINES``, or ``OPTIONS``, create a folder
+``Obj_machine`` with all objects and generated files and an executable
+called ``lmp_machine``\ . The standard parallel build with ``make mpi``
+assumes a standard MPI installation with MPI compiler wrappers where all
+necessary compiler and linker flags to get access and link with the
+suitable MPI headers and libraries are set by the wrapper programs. For
+other cases or the serial build, you have to adjust the make file
+variables ``MPI_INC``, ``MPI_PATH``, ``MPI_LIB`` as well as ``CC`` and
+``LINK``\ . To enable OpenMP threading usually a compiler specific flag
+needs to be added to the compile and link commands. For the GNU
+compilers, this is ``-fopenmp``\ , which can be added to the ``CC`` and
+``LINK`` makefile variables.
+
+For the serial build the following make variables are set (see src/MAKE/Makefile.serial):
+
+.. code-block:: make
+ CC = g++
+ LINK = g++
MPI_INC = -I../STUBS
MPI_PATH = -L../STUBS
MPI_LIB = -lmpi_stubs
-For a parallel build, if MPI is installed on your system in the usual
-place (e.g. under /usr/local), you do not need to specify the 3
-variables MPI\_INC, MPI\_PATH, MPI\_LIB. The MPI wrapper on the compiler
-(e.g. mpicxx, mpiCC) knows where to find the needed include and
-library files. Failing this, these 3 variables can be used to specify
-where the mpi.h file (MPI\_INC), and the MPI library files (MPI\_PATH)
-are found, and the name of the library files (MPI\_LIB).
-
-For a serial build, you need to specify the 3 variables, as shown
-above.
-
-For a serial LAMMPS build, use the dummy MPI library provided in
-src/STUBS. You also need to build the STUBS library for your platform
-before making LAMMPS itself. A "make serial" build does this for.
-Otherwise, type "make mpi-stubs" from the src directory, or "make"
-from the src/STUBS dir. If the build fails, you will need to edit the
-STUBS/Makefile for your platform.
-
-The file STUBS/mpi.c provides a CPU timer function called MPI\_Wtime()
-that calls gettimeofday() . If your system doesn't support
-gettimeofday() , you'll need to insert code to call another timer.
-Note that the ANSI-standard function clock() rolls over after an hour
-or so, and is therefore insufficient for timing long LAMMPS
-simulations.
+You also need to build the STUBS library for your platform before making
+LAMMPS itself. A ``make serial`` build does this for you automatically,
+otherwise, type ``make mpi-stubs`` from the src directory, or ``make``
+from the ``src/STUBS`` dir. If the build fails, you may need to edit
+the ``STUBS/Makefile`` for your platform. The stubs library does not
+provide MPI/IO functions required by some LAMMPS packages,
+e.g. ``MPIIO`` or ``USER-LB``, and thus is not compatible with those
+packages.
-**CMake and make info**\ :
+.. note::
-If you are installing MPI yourself, we recommend MPICH2 from Argonne
-National Laboratory or OpenMPI. MPICH can be downloaded from the
-`Argonne MPI site `_.
-OpenMPI can be downloaded from the `OpenMPI site `_. Other MPI packages should also work.
-If you are running on a large parallel machine, your system admins or
-the vendor should have already installed a version of MPI, which is
-likely to be faster than a self-installed MPICH or OpenMPI, so find
-out how to build and link with it.
-
-The majority of OpenMP (threading) support in LAMMPS is provided by
-the USER-OMP package; see the :doc:`Speed omp ` doc page for
-details. The USER-INTEL package also provides OpenMP support (it is
-compatible with USER-OMP) and adds vectorization support when compiled
-with the Intel compilers on top of that. Also, the KOKKOS package can
-be compiled for using OpenMP threading.
-
-However, there are a few commands in LAMMPS that have native OpenMP
-support. These are commands in the MPIIO, SNAP, USER-DIFFRACTION, and
-USER-DPD packages. In addition some packages support OpenMP threading
-indirectly through the libraries they interface to: e.g. LATTE and
-USER-COLVARS. See the :doc:`Packages details ` doc
-page for more info on these packages and the doc pages for their
-respective commands for OpenMP threading info.
-
-For CMake, if you use BUILD\_OMP=yes, you can use these packages and
-turn on their native OpenMP support and turn on their native OpenMP
-support at run time, by setting the OMP\_NUM\_THREADS environment
+ The file ``src/STUBS/mpi.c`` provides a CPU timer function called
+ ``MPI_Wtime()`` that calls ``gettimeofday()``. If your operating system
+ does not support ``gettimeofday()``, you will need to insert code to
+ call another timer. Note that the ANSI-standard function ``clock()``
+ rolls over after an hour or so, and is therefore insufficient for
+ timing long LAMMPS simulations.
+
+**MPI and OpenMP support info**\ :
+
+If you are installing MPI yourself to build a parallel LAMMPS
+executable, we recommend either MPICH or OpenMPI which are regularly
+used and tested with LAMMPS by the LAMMPS developers. MPICH can be
+downloaded from the `MPICH home page `_ and
+OpenMPI can be downloaded correspondingly from the `OpenMPI home page
+`_. Other MPI packages should also work. No
+specific vendor provided and standard compliant MPI library is currently
+known to be incompatible with LAMMPS. If you are running on a large
+parallel machine, your system admins or the vendor should have already
+installed a version of MPI, which is likely to be faster than a
+self-installed MPICH or OpenMPI, so you should study the provided
+documentation to find out how to build and link with it.
+
+The majority of OpenMP (threading) support in LAMMPS is provided by the
+``USER-OMP`` package; see the :doc:`Speed omp ` doc page for
+details. The ``USER-INTEL`` package also includes OpenMP threading (it
+is compatible with ``USER-OMP`` and will usually fall back on styles
+from that package, if a ``USER-INTEL`` does not exist) and adds
+vectorization support when compiled with compatible compilers, in
+particular the Intel compilers on top of OpenMP. Also, the ``KOKKOS``
+package can be compiled to include OpenMP threading.
+
+In addition, there are a few commands in LAMMPS that have native OpenMP
+support included as well. These are commands in the ``MPIIO``,
+``SNAP``, ``USER-DIFFRACTION``, and ``USER-DPD`` packages. In addition
+some packages support OpenMP threading indirectly through the libraries
+they interface to: e.g. ``LATTE``, ``KSPACE``, and ``USER-COLVARS``.
+See the :doc:`Packages details ` doc page for more
+info on these packages and the doc pages for their respective commands
+for OpenMP threading info.
+
+For CMake, if you use ``BUILD_OMP=yes``, you can use these packages
+and turn on their native OpenMP support and turn on their native OpenMP
+support at run time, by setting the ``OMP_NUM_THREADS`` environment
variable before you launch LAMMPS.
-For building via conventional make, the CCFLAGS and LINKFLAGS
+For building via conventional make, the ``CCFLAGS`` and ``LINKFLAGS``
variables in Makefile.machine need to include the compiler flag that
-enables OpenMP. For GNU compilers it is -fopenmp. For (recent) Intel
-compilers it is -qopenmp. If you are using a different compiler,
+enables OpenMP. For GNU compilers it is ``-fopenmp``\ . For (recent) Intel
+compilers it is ``-qopenmp``\ . If you are using a different compiler,
please refer to its documentation.
.. _default-none-issues:
-**OpenMP Compiler compatibility info**\ :
-
-Some compilers do not fully support the 'default(none)' directive
-and others (e.g. GCC version 9 and beyond) may implement OpenMP 4.0
-semantics, which are incompatible with the OpenMP 3.1 directives used
-in LAMMPS (for maximal compatibility with compiler versions in use).
-In those case, all 'default(none)' directives (which aid in detecting
-incorrect and unwanted sharing) can be replaced with 'default(shared)'
-while dropping all 'shared()' directives. The script
-'src/USER-OMP/hack\_openmp\_for\_pgi\_gcc9.sh' can be used to automate
-this conversion.
+**OpenMP Compiler compatibility info**\ :
+Some compilers do not fully support the ``default(none)`` directive
+and others (e.g. GCC version 9 and beyond, Clang version 10 and later)
+may implement strict OpenMP 4.0 and later semantics, which are incompatible
+with the OpenMP 3.1 semantics used in LAMMPS for maximal compatibility
+with compiler versions in use. If compilation with OpenMP enabled fails
+because of your compiler requiring strict OpenMP 4.0 semantic, you can
+change the behavior by adding ``-D LAMMPS_OMP_COMPAT=4`` to the ``LMP_INC``
+variable in your makefile, or add it to the command line while configuring
+with CMake. CMake will detect the suitable setting for the GNU, Clang,
+and Intel compilers.
----------
-
.. _compile:
Choice of compiler and compile/link options
---------------------------------------------------------
-The choice of compiler and compiler flags can be important for
-performance. Vendor compilers can produce faster code than
-open-source compilers like GNU. On boxes with Intel CPUs, we suggest
-trying the `Intel C++ compiler `_.
+The choice of compiler and compiler flags can be important for maximum
+performance. Vendor provided compilers for a specific hardware can
+produce faster code than open-source compilers like the GNU compilers.
+On the most common x86 hardware most popular C++ compilers are quite
+similar in performance of C/C++ code at high optimization levels. When
+using the ``USER-INTEL`` package, there is a distinct advantage in using
+the `Intel C++ compiler `_ due to much improved vectorization
+through SSE and AVX instructions on compatible hardware as the source
+code includes changes and Intel compiler specific directives to enable
+high degrees of vectorization. This may change over time as equivalent
+vectorization directives are included into OpenMP standard revisions and
+other compilers adopt them.
.. _intel: https://software.intel.com/en-us/intel-compilers
+On parallel clusters or supercomputers which use "environment modules"
+for their compile/link environments, you can often access different
+compilers by simply loading the appropriate module before building
+LAMMPS.
+**CMake build**\ :
-On parallel clusters or supercomputers which use "modules" for their
-compile/link environments, you can often access different compilers by
-simply loading the appropriate module before building LAMMPS.
-
-**CMake variables**\ :
+By default CMake will use a compiler it finds according to internal
+preferences and it will add optimization flags appropriate to that
+compiler and any :doc:`accelerator packages ` you have
+included in the build.
+You can tell CMake to look for a specific compiler with setting CMake
+variable during configuration. For a few common choices, there are also
+presets in the ``cmake/presets`` folder. For convenience, there is a
+``CMAKE_TUNE_FLAGS`` variable that can be set to apply global compiler
+options. More on that below, but you can also specify the corresponding
+``CMAKE_*_FLAGS`` variables individually if you want to experiment with
+alternate optimization flags. You should specify all 3 compilers, so
+that the (few) LAMMPS source files written in C or Fortran are built
+with a compiler consistent with the one used for the C++ files:
-.. parsed-literal::
+.. code-block:: bash
-D CMAKE_CXX_COMPILER=name # name of C++ compiler
-D CMAKE_C_COMPILER=name # name of C compiler
@@ -168,77 +212,96 @@ simply loading the appropriate module before building LAMMPS.
-D CMAKE_C_FLAGS=string # flags to use with C compiler
-D CMAKE_Fortran_FLAGS=string # flags to use with Fortran compiler
-By default CMake will use a compiler it finds and it will add
-optimization flags appropriate to that compiler and any :doc:`accelerator packages ` you have included in the build.
-
-You can tell CMake to look for a specific compiler with these variable
-settings. Likewise you can specify the FLAGS variables if you want to
-experiment with alternate optimization flags. You should specify all
-3 compilers, so that the small number of LAMMPS source files written
-in C or Fortran are built with a compiler consistent with the one used
-for all the C++ files:
+A few example command lines are:
+.. code-block:: bash
-.. parsed-literal::
-
- Building with GNU Compilers:
+ # Building with GNU Compilers:
cmake ../cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_Fortran_COMPILER=gfortran
- Building with Intel Compilers:
+ # Building with Intel Compilers:
cmake ../cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort
- Building with LLVM/Clang Compilers:
+ # Building with LLVM/Clang Compilers:
cmake ../cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_Fortran_COMPILER=flang
+For compiling with the Clang/LLVM compilers a CMake preset is provided that
+can be loaded with `-C ../cmake/presets/clang.cmake`. Similarly,
+`-C ../cmake/presets/intel.cmake` should switch the
+
+In addition you can set ``CMAKE_TUNE_FLAGS`` to specifically add
+compiler flags to tune for optimal performance on given hosts. By
+default these are initialized to some compiler specific flags, to
+optimize the LAMMPS executable with optimizations and instructions
+available on the host where LAMMPS is compiled. For example, for Intel
+compilers this would be ``-xHost`` and for GNU compilers this would be
+``-march=native``. To turn these flags off, do ``-D CMAKE_TUNE_FLAGS=``.
+
.. note::
- When the cmake command completes, it prints info to the screen
- as to which compilers it is using, and what flags will be used in the
- compilation. Note that if the top-level compiler is mpicxx, it is
- simply a wrapper on a real compiler. The underlying compiler info is
- what will be listed in the CMake output. You should check to insure
- you are using the compiler and optimization flags are the ones you
- want.
+ When the cmake command completes, it prints a summary to the screen
+ which compilers it is using and what flags and settings will be used
+ for the compilation. Note that if the top-level compiler is mpicxx,
+ it is simply a wrapper on a real compiler. The underlying compiler
+ info is what CMake will try to determine and report. You should check
+ to confirm you are using the compiler and optimization flags you want.
-**Makefile.machine settings**\ :
+**Makefile.machine settings for traditional make**\ :
-Parallel build (see src/MAKE/Makefile.mpi):
+The "compiler/linker settings" section of a Makefile.machine lists
+compiler and linker settings for your C++ compiler, including
+optimization flags. For a parallel build it is recommended to use
+``mpicxx`` or ``mpiCC``, since these compiler wrappers will include a
+variety of settings appropriate for your MPI installation and thus
+avoiding the guesswork of finding the right flags.
+Parallel build (see ``src/MAKE/Makefile.mpi``):
-.. parsed-literal::
+.. code-block:: bash
CC = mpicxx
CCFLAGS = -g -O3
LINK = mpicxx
LINKFLAGS = -g -O
-Serial build (see src/MAKE/Makefile.serial):
-
+Serial build with GNU gcc (see ``src/MAKE/Makefile.serial``):
-.. parsed-literal::
+.. code-block:: make
CC = g++
CCFLAGS = -g -O3
LINK = g++
LINKFLAGS = -g -O
-The "compiler/linker settings" section of a Makefile.machine lists
-compiler and linker settings for your C++ compiler, including
-optimization flags. You should always use mpicxx or mpiCC for
-a parallel build, since these compiler wrappers will include
-a variety of settings appropriate for your MPI installation.
.. note::
- If you build LAMMPS with any :doc:`accelerator packages ` included, they have specific
- optimization flags that are either required or recommended for optimal
- performance. You need to include these in the CCFLAGS and LINKFLAGS
- settings above. For details, see the individual package doc pages
- listed on the :doc:`Speed packages ` doc page. Or
- examine these files in the src/MAKE/OPTIONS directory. They
- correspond to each of the 5 accelerator packages and their hardware
- variants:
+ If compilation stops with a message like the following:
+
+ .. code-block::
+ g++ -g -O3 -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 -I../STUBS -c ../main.cpp
+ In file included from ../pointers.h:24:0,
+ from ../input.h:17,
+ from ../main.cpp:16:
+ ../lmptype.h:34:2: error: #error LAMMPS requires a C++11 (or later) compliant compiler. Enable C++11 compatibility or upgrade the compiler.
-.. parsed-literal::
+ then you have either an unsupported (old) compiler or you have to
+ turn on C++11 mode. The latter applies to GCC 4.8.x shipped with
+ RHEL 7.x and CentOS 7.x. For those compilers, you need to add the
+ ``-std=c++11`` flag. Otherwise, you would have to install a newer
+ compiler that supports C++11; either as a binary package or through
+ compiling from source.
+
+If you build LAMMPS with any :doc:`accelerator packages
+` included, there may be specific optimization flags
+that are either required or recommended to enable required features and
+to achieve optimal performance. You need to include these in the
+CCFLAGS and LINKFLAGS settings above. For details, see the individual
+package doc pages listed on the :doc:`Speed packages `
+doc page. Or examine these files in the src/MAKE/OPTIONS directory.
+They correspond to each of the 5 accelerator packages and their hardware
+variants:
+
+.. code-block:: bash
Makefile.opt # OPT package
Makefile.omp # USER-OMP package
@@ -249,128 +312,197 @@ a variety of settings appropriate for your MPI installation.
Makefile.kokkos_omp # KOKKOS package for CPUs (OpenMP)
Makefile.kokkos_phi # KOKKOS package for KNLs (OpenMP)
-
----------
-
.. _exe:
-Build LAMMPS as an executable or a library
-----------------------------------------------------
+Build the LAMMPS executable and library
+---------------------------------------
-LAMMPS can be built as either an executable or as a static or shared
-library. The LAMMPS library can be called from another application or
-a scripting language. See the :doc:`Howto couple ` doc
+LAMMPS is always built as a library of C++ classes plus an executable.
+The executable is a simple ``main()`` function that sets up MPI and then
+creates a LAMMPS class instance from the LAMMPS library, which
+will then process commands provided via a file or from the console
+input. The LAMMPS library can also be called from another application
+or a scripting language. See the :doc:`Howto couple ` doc
page for more info on coupling LAMMPS to other codes. See the
:doc:`Python ` doc page for more info on wrapping and
running LAMMPS from Python via its library interface.
-**CMake variables**\ :
+**CMake build**\ :
+For CMake builds, you can select through setting CMake variables between
+building a shared or a static LAMMPS library and what kind of suffix is
+added to them (in case you want to concurrently install multiple variants
+of binaries with different settings). If none are set, defaults are applied.
-.. parsed-literal::
+.. code-block:: bash
- -D BUILD_EXE=value # yes (default) or no
- -D BUILD_LIB=value # yes or no (default)
-D BUILD_SHARED_LIBS=value # yes or no (default)
- -D LAMMPS_LIB_SUFFIX=name # name = mpi, serial, mybox, titan, laptop, etc
+ -D LAMMPS_MACHINE=name # name = mpi, serial, mybox, titan, laptop, etc
# no default value
-Setting BUILD\_EXE=no will not produce an executable. Setting
-BUILD\_LIB=yes will produce a static library named liblammps.a.
-Setting both BUILD\_LIB=yes and BUILD\_SHARED\_LIBS=yes will produce a
-shared library named liblammps.so. If LAMMPS\_LIB\_SUFFIX is set the generated
-libraries will be named liblammps\_name.a or liblammps\_name.so instead.
+The compilation will always produce a LAMMPS library and an executable
+linked to it. By default this will be a static library named
+``liblammps.a`` and an executable named ``lmp`` Setting
+``BUILD_SHARED_LIBS=yes`` will instead produce a shared library called
+``liblammps.so`` (or ``liblammps.dylib`` or ``liblammps.dll`` depending
+on the platform) If ``LAMMPS_MACHINE=name`` is set in addition, the name
+of the generated libraries will be changed to either
+``liblammps_name.a`` or ``liblammps_name.so``\ , respectively and the
+executable will be called ``lmp_name``.
**Traditional make**\ :
+With the traditional makefile based build process, the choice of
+the generated executable or library depends on the "mode" setting.
+Several options are available and ``mode=static`` is the default.
-.. parsed-literal::
+.. code-block:: bash
- cd lammps/src
make machine # build LAMMPS executable lmp_machine
- make mode=lib machine # build LAMMPS static lib liblammps_machine.a
- make mode=shlib machine # build LAMMPS shared lib liblammps_machine.so
+ make mode=static machine # same as "make machine"
+ make mode=shared machine # build LAMMPS shared lib liblammps_machine.so instead
-The two library builds also create generic soft links, named
-liblammps.a and liblammps.so, which point to the liblammps\_machine
-files.
+The "static" build will generate a static library called
+``liblammps_machine.a`` and an executable named ``lmp_machine``\ , while
+the "shared" build will generate a shared library
+``liblammps_machine.so`` instead and ``lmp_machine`` will be linked to
+it. The build step will also create generic soft links, named
+``liblammps.a`` and ``liblammps.so``\ , which point to the specific
+``liblammps_machine.a/so`` files.
**CMake and make info**\ :
-Note that for a shared library to be usable by a calling program, all
-the auxiliary libraries it depends on must also exist as shared
-libraries. This will be the case for libraries included with LAMMPS,
-such as the dummy MPI library in src/STUBS or any package libraries in
-the lib/packages directory, since they are always built as shared
-libraries using the -fPIC switch. However, if a library like MPI or
-FFTW does not exist as a shared library, the shared library build will
-generate an error. This means you will need to install a shared
-library version of the auxiliary library. The build instructions for
-the library should tell you how to do this.
-
-As an example, here is how to build and install the `MPICH library `_, a popular open-source version of MPI, distributed by
-Argonne National Lab, as a shared library in the default
-/usr/local/lib location:
-
-.. _mpich: http://www-unix.mcs.anl.gov/mpi
-
+Note that for creating a shared library, all the libraries it depends on
+must be compiled to be compatible with shared libraries. This should be
+the case for libraries included with LAMMPS, such as the dummy MPI
+library in ``src/STUBS`` or any package libraries in the ``lib``
+directory, since they are always built in a shared library compatible
+way using the ``-fPIC`` compiler switch. However, if an auxiliary
+library (like MPI or FFTW) does not exist as a compatible format, the
+shared library linking step may generate an error. This means you will
+need to install a compatible version of the auxiliary library. The
+build instructions for that library should tell you how to do this.
+As an example, here is how to build and install the `MPICH library
+`_, a popular open-source version of MPI, as a shared library
+in the default /usr/local/lib location:
+.. _mpich: https://www.mpich.org
-.. parsed-literal::
+.. code-block:: bash
./configure --enable-shared
make
make install
-You may need to use "sudo make install" in place of the last line if
-you do not have write privileges for /usr/local/lib. The end result
-should be the file /usr/local/lib/libmpich.so.
+You may need to use ``sudo make install`` in place of the last line if
+you do not have write privileges for ``/usr/local/lib`` or use the
+``--prefix`` configuration option to select an installation folder,
+where you do have write access. The end result should be the file
+``/usr/local/lib/libmpich.so``. On many Linux installations the folder
+``${HOME}/.local`` is an alternative to using ``/usr/local`` and does
+not require superuser or sudo access. In that case the configuration
+step becomes:
+.. code-block:: bash
+
+ ./configure --enable-shared --prefix=${HOME}/.local
+
+Avoiding to use "sudo" for custom software installation (i.e. from source
+and not through a package manager tool provided by the OS) is generally
+recommended to ensure the integrity of the system software installation.
----------
+.. _debug:
+
+Excluding or removing debug support
+-----------------------------------
+
+By default the compilation settings will include the *-g* flag which
+instructs the compiler to include debug information (e.g. which line of
+source code a particular instruction correspond to). This can be
+extremely useful in case LAMMPS crashes and can help to provide crucial
+information in :doc:`tracking down the origin of a crash `
+and help the LAMMPS developers fix bugs in the source code. However,
+this increases the storage requirements for object files, libraries, and
+the executable 3-5 fold.
+
+If this is a concern, you can change the compilation settings or remove
+the debug information from the LAMMPS executable:
+
+- **Traditional make**: edit your ``Makefile.`` to remove the
+ *-g* flag from the ``CCFLAGS`` and ``LINKFLAGS`` definitions
+- **CMake**: use ``-D CMAKE_BUILD_TYPE=Release`` or explicitly reset
+ the applicable compiler flags (best done using the text mode or
+ graphical user interface).
+- **Remove debug info**: If you are only concerned about the executable
+ being too large, you can use the ``strip`` tool (e.g. ``strip
+ lmp_serial``) to remove the debug information from the executable file.
+ Do not strip libraries or object files, as that will render them unusable.
+
+----------
.. _doc:
Build the LAMMPS documentation
----------------------------------------
-**CMake variable**\ :
-
-
-.. parsed-literal::
+The LAMMPS manual is written in `reStructuredText `_ format which
+can be translated to different output format using the `Sphinx `_
+document generator tool. Currently the translation to HTML and PDF (via
+LaTeX) are supported. For that to work a Python 3 interpreter and
+internet access is required. For the documentation build a python
+based virtual environment is set up in the folder doc/docenv and various
+python packages are installed into that virtual environment via the pip
+tool. The actual translation is then done via make commands.
- -D BUILD_DOC=value # yes or no (default)
-
-This will create the HTML doc pages within the CMake build directory.
-The reason to do this is if you want to "install" LAMMPS on a system
-after the CMake build via "make install", and include the doc pages in
-the install.
+.. _rst: https://docutils.readthedocs.io/en/sphinx-docs/user/rst/quickstart.html
+.. _sphinx: https://sphinx-doc.org
-**Traditional make**\ :
+**Documentation make option**\ :
+The following make commands can be issued in the doc folder of the
+LAMMPS source distribution.
-.. parsed-literal::
+.. code-block:: bash
- cd lammps/doc
- make html # html doc pages
- make pdf # single Manual.pdf file
+ make html # create HTML doc pages in html directory
+ make pdf # create Developer.pdf and Manual.pdf in this directory
+ make fetch # fetch HTML and PDF files from LAMMPS web site
+ make clean # remove all intermediate files
+ make clean-all # reset the entire doc build environment
+ make anchor_check # scan for duplicate anchor labels
+ make style_check # check for complete and consistent style lists
+ make package_check # check for complete and consistent package lists
+ make spelling # spell-check the manual
-This will create a lammps/doc/html dir with the HTML doc pages so that
-you can browse them locally on your system. Type "make" from the
-lammps/doc dir to see other options.
+Thus "make html" will create a "doc/html" directory with the HTML format
+manual pages so that you can browse them with a web browser locally on
+your system.
.. note::
You can also download a tarball of the documentation for the
current LAMMPS version (HTML and PDF files), from the website
- `download page `_.
+ `download page `_.
+**CMake build option**\ :
-----------
+It is also possible to create the HTML version of the manual within
+the :doc:`CMake build directory `. The reason for this
+option is to include the installation of the HTML manual pages into
+the "install" step when installing LAMMPS after the CMake build via
+``make install``. The documentation build is included in the default
+build target, but can also be requested independently with ``make doc``.
+
+.. code-block:: bash
+
+ -D BUILD_DOC=value # yes or no (default)
+----------
.. _tools:
@@ -380,19 +512,18 @@ Build LAMMPS tools
Some tools described in :doc:`Auxiliary tools ` can be built directly
using CMake or Make.
-**CMake variable**\ :
-
+**CMake build3**\ :
-.. parsed-literal::
+.. code-block:: bash
-D BUILD_TOOLS=value # yes or no (default)
-The generated binaries will also become part of the LAMMPS installation (see below)
+The generated binaries will also become part of the LAMMPS installation
+(see below).
**Traditional make**\ :
-
-.. parsed-literal::
+.. code-block:: bash
cd lammps/tools
make all # build all binaries of tools
@@ -401,10 +532,8 @@ The generated binaries will also become part of the LAMMPS installation (see bel
make micelle2d # build only micelle2d tool
make thermo_extract # build only thermo_extract tool
-
----------
-
.. _install:
Install LAMMPS after a build
@@ -416,10 +545,9 @@ a globally visible place on your system, for others to access. Note
that you may need super-user privileges (e.g. sudo) if the directory
you want to copy files to is protected.
-**CMake variable**\ :
+**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
cmake -D CMAKE_INSTALL_PREFIX=path [options ...] ../cmake
make # perform make after CMake command
@@ -427,11 +555,6 @@ you want to copy files to is protected.
**Traditional make**\ :
-There is no "install" option in the src/Makefile for LAMMPS. If you
-wish to do this you will need to first build LAMMPS, then manually
+There is no "install" option in the ``src/Makefile`` for LAMMPS. If
+you wish to do this you will need to first build LAMMPS, then manually
copy the desired LAMMPS files to the appropriate system directories.
-
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
diff --git a/doc/src/Build_cmake.rst b/doc/src/Build_cmake.rst
index 78459bb9906e07bdddc48b330fe48c7b12d1ec91..3473d8314353140566345ad1de107d0a67e9c288 100644
--- a/doc/src/Build_cmake.rst
+++ b/doc/src/Build_cmake.rst
@@ -1,222 +1,162 @@
Build LAMMPS with CMake
=======================
-This page is a short summary of how to use CMake to build LAMMPS.
-Details on CMake variables that enable specific LAMMPS build options
-are given on the pages linked to from the :doc:`Build ` doc page.
+This page describes how to use `CMake `_ in general
+to build LAMMPS. Details for specific compile time settings and options
+to enable and configure add-on packages are discussed with those
+packages. Links to those pages on the :doc:`Build overview `
+page.
+
+The following text assumes some familiarity with CMake and focuses on
+using the command line tool ``cmake`` and what settings are supported
+for building LAMMPS. A more detailed tutorial on how to use ``cmake``
+itself, the text mode or graphical user interface, change the generated
+output files for different build tools and development environments is
+on a :doc:`separate page `.
-Richard Berger (Temple U) has also written a `more comprehensive guide `_
-for how to use CMake to build LAMMPS. If you are new to CMake it is a
-good place to start.
-
-
-----------
+.. note::
+ LAMMPS currently requires that CMake version 3.10 or later is available;
+ version 3.12 or later is preferred.
+
+.. warning::
+
+ You must not mix the :doc:`traditional make based `
+ LAMMPS build procedure with using CMake. Thus no packages may be
+ installed or a build been previously attempted in the LAMMPS source
+ directory by using ``make ``. CMake will detect if this is
+ the case and generate an error. To remove conflicting files from the
+ ``src`` you can use the command ``make no-all purge`` which will
+ un-install all packages and delete all auto-generated files.
+
+
+Advantages of using CMake
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+CMake is an alternative to compiling LAMMPS in the traditional way
+through :doc:`(manually customized) makefiles ` and a recent
+addition to LAMMPS thanks to the efforts of Christoph Junghans (LANL)
+and Richard Berger (Temple U). Using CMake has multiple advantages that
+are specifically helpful for people with limited experience in compiling
+software or for people that want to modify or extend LAMMPS.
+
+- CMake can detect available hardware, tools, features, and libraries
+ and adapt the LAMMPS default build configuration accordingly.
+- CMake can generate files for different build tools and integrated
+ development environments (IDE).
+- CMake supports customization of settings with a text mode or graphical
+ user interface. No knowledge of file formats or and complex command
+ line syntax required.
+- All enabled components are compiled in a single build operation.
+- Automated dependency tracking for all files and configuration options.
+- Support for true out-of-source compilation. Multiple configurations
+ and settings with different choices of LAMMPS packages, settings, or
+ compilers can be configured and built concurrently from the same
+ source tree.
+- Simplified packaging of LAMMPS for Linux distributions, environment
+ modules, or automated build tools like `Homebrew `_.
+- Integration of automated regression testing (the LAMMPS side for that
+ is still under development).
+
+.. _cmake_build:
+
+Getting started
+^^^^^^^^^^^^^^^
Building LAMMPS with CMake is a two-step process. First you use CMake
-to create a build environment in a new directory. On Linux systems,
-this will be based on makefiles for use with make. Then you use the
-make command to build LAMMPS, which uses the created
-Makefile(s). Example:
-
-
-.. parsed-literal::
-
- cd lammps # change to the LAMMPS distribution directory
- mkdir build; cd build # create a new directory (folder) for build
- cmake [options ...] ../cmake # configuration with (command-line) cmake
- make # compilation
-
-The cmake command will detect available features, enable selected
-packages and options, and will generate the build environment. By default
-this build environment will be created for "Unix Makefiles" on most
-platforms and particularly on Linux. However, alternate build tools
-(e.g. Ninja) and support files for Integrated Development Environments
-(IDE) like Eclipse, CodeBlocks, or Kate can be generated, too. This is
-selected via the "-G" command line flag. For the rest of the documentation
-we will assume that the build environment is generated for makefiles
-and thus the make command will be used to compile and link LAMMPS as
-indicated above, producing (by default) an executable called "lmp" and
-a library called "liblammps.a" in the "build" folder. When generating
-a build environment for the "Ninja" build tool, the build command would
-be "ninja" instead of "make".
-
-If your machine has multiple CPU cores (most do these days), using a
-command like "make -jN" (with N being the number of available local
-CPU cores) can be much faster. If you plan to do development on
-LAMMPS or need to re-compile LAMMPS repeatedly, installation of the
-ccache (= Compiler Cache) software may speed up repeated compilation
-even more.
+to generate a build environment in a new directory. For that purpose
+you can use either the command-line utility ``cmake`` (or ``cmake3``),
+the text-mode UI utility ``ccmake`` (or ``ccmake3``) or the graphical
+utility ``cmake-gui``, or use them interchangeably. The second step is
+then the compilation and linking of all objects, libraries, and
+executables. Here is a minimal example using the command line version of
+CMake to build LAMMPS with no add-on packages enabled and no
+customization:
+
+.. code-block:: bash
+
+ cd lammps # change to the LAMMPS distribution directory
+ mkdir build; cd build # create and use a build directory
+ cmake ../cmake # configuration reading CMake scripts from ../cmake
+ cmake --build . # compilation (or type "make")
+
+This will create and change into a folder called ``build``, then run the
+configuration step to generate build files for the default build command
+and then launch that build command to compile LAMMPS. During the
+configuration step CMake will try to detect whether support for MPI,
+OpenMP, FFTW, gzip, JPEG, PNG, and ffmpeg are available and enable the
+corresponding configuration settings. The progress of this
+configuration can be followed on the screen and a summary of selected
+options and settings will be printed at the end. The ``cmake --build
+.`` command will launch the compilation, which, if successful, will
+ultimately produce a library ``liblammps.a`` and the LAMMPS executable
+``lmp`` inside the ``build`` folder.
+
+Compilation can take a long time, since LAMMPS is a large project with
+many features. If your machine has multiple CPU cores (most do these
+days), you can speed this up by compiling sources in parallel with
+``make -j N`` (with N being the maximum number of concurrently executed
+tasks). Also installation of the `ccache `_ (=
+Compiler Cache) software may speed up repeated compilation even more,
+e.g. during code development.
+
+After the initial build, whenever you edit LAMMPS source files, enable
+or disable packages, change compiler flags or build options, you must
+re-compile and relink the LAMMPS executable with ``cmake --build .`` (or
+``make``). If the compilation fails for some reason, try running
+``cmake .`` and then compile again. The included dependency tracking
+should make certain that only the necessary subset of files are
+re-compiled. You can also delete compiled objects, libraries and
+executables with ``cmake --build . clean`` (or ``make clean``).
After compilation, you may optionally install the LAMMPS executable into
your system with:
+.. code-block:: bash
-.. parsed-literal::
-
- make install # optional, copy LAMMPS executable & library elsewhere
-
-This will install the lammps executable and library (if requested), some
-tools (if configured) and additional files like library API headers,
-manpages, potential and force field files. The location of the installation
-tree is set by the CMake variable "CMAKE\_INSTALL\_PREFIX" which defaults
-to ${HOME}/.local
-
-
-----------
-
-
-There are 3 variants of CMake: a command-line version (cmake), a text mode
-UI version (ccmake), and a graphical GUI version (cmake-GUI). You can use
-any of them interchangeably to configure and create the LAMMPS build
-environment. On Linux all the versions produce a Makefile as their
-output. See more details on each below.
-
-You can specify a variety of options with any of the 3 versions, which
-affect how the build is performed and what is included in the LAMMPS
-executable. Links to pages explaining all the options are listed on
-the :doc:`Build ` doc page.
-
-You must perform the CMake build system generation and compilation in
-a new directory you create. It can be anywhere on your local machine.
-In these Build pages we assume that you are building in a directory
-called "lammps/build". You can perform separate builds independently
-with different options, so long as you perform each of them in a
-separate directory you create. All the auxiliary files created by one
-build process (executable, object files, log files, etc) are stored in
-this directory or sub-directories within it that CMake creates.
-
-.. note::
-
- To perform a CMake build, no packages can be installed or a
- build been previously attempted in the LAMMPS src directory by using
- "make" commands to :doc:`perform a conventional LAMMPS build `. CMake detects if this is the case and
- generates an error, telling you to type "make no-all purge" in the src
- directory to un-install all packages. The purge removes all the \*.h
- files auto-generated by make.
-
-You must have CMake version 2.8 or later on your system to build
-LAMMPS. A handful of LAMMPS packages (KOKKOS, LATTE, MSCG) require a
-later version. CMake will print a message telling you if a later
-version is required. Installation instructions for CMake are below.
-
-After the initial build, if you edit LAMMPS source files, or add your
-own new files to the source directory, you can just re-type make from
-your build directory and it will re-compile only the files that have
-changed. If you want to change CMake options you can run cmake (or
-ccmake or cmake-gui) again from the same build directory and alter
-various options; see details below. Or you can remove the entire build
-folder, recreate the directory and start over.
-
-
-----------
-
-
-**Command-line version of CMake**\ :
-
-
-.. parsed-literal::
-
- cmake [options ...] /path/to/lammps/cmake # build from any dir
- cmake [options ...] ../cmake # build from lammps/build
-
-The cmake command takes one required argument, which is the LAMMPS
-cmake directory which contains the CMakeLists.txt file.
-
-The argument can be preceeded or followed by various CMake
-command-line options. Several useful ones are:
+ make install # optional, copy compiled files into installation location
+This will install the LAMMPS executable and library, some tools (if
+configured) and additional files like LAMMPS API headers, manpages,
+potential and force field files. The location of the installation tree
+defaults to ``${HOME}/.local``.
-.. parsed-literal::
+.. _cmake_options:
- -D CMAKE_INSTALL_PREFIX=path # where to install LAMMPS executable/lib if desired
- -D CMAKE_BUILD_TYPE=type # type = RelWithDebInfo (default), Release, MinSizeRel, or Debug
- -G output # style of output CMake generates
- -DVARIABLE=value # setting for a LAMMPS feature to enable
- -D VARIABLE=value # ditto, but cannot come after CMakeLists.txt dir
- -C path/to/preset/file # load some CMake settings before configuring
+Configuration and build options
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-All the LAMMPS-specific -D variables that a LAMMPS build supports are
-described on the pages linked to from the :doc:`Build ` doc page.
-All of these variable names are upper-case and their values are
-lower-case, e.g. -D LAMMPS\_SIZES=smallbig. For boolean values, any of
-these forms can be used: yes/no, on/off, 1/0.
+The CMake commands have one mandatory argument: a folder containing a
+file called ``CMakeLists.txt`` (for LAMMPS it is located in the
+``cmake`` folder) or a build folder containing a file called
+``CMakeCache.txt``, which is generated at the end of the CMake
+configuration step. The cache file contains all current CMake settings.
-On Unix/Linux machines, CMake generates a Makefile by default to
-perform the LAMMPS build. Alternate forms of build info can be
-generated via the -G switch, e.g. Visual Studio on a Windows machine,
-Xcode on MacOS, or KDevelop on Linux. Type "cmake --help" to see the
-"Generator" styles of output your system supports.
-
-.. note::
-
- When CMake runs, it prints configuration info to the screen.
- You should review this to verify all the features you requested were
- enabled, including packages. You can also see what compilers and
- compile options will be used for the build. Any errors in CMake
- variable syntax will also be flagged, e.g. mis-typed variable names or
- variable values.
-
-CMake creates a CMakeCache.txt file when it runs. This stores all the
-settings, so that when running CMake again you can use the current
-folder '.' instead of the path to the LAMMPS cmake folder as the
-required argument to the CMake command. Either way the existing
-settings will be inherited unless the CMakeCache.txt file is removed.
-
-If you later want to change a setting you can rerun cmake in the build
-directory with different setting. Please note that some automatically
-detected variables will not change their value when you rerun cmake.
-In these cases it is usually better to first remove all the
-files/directories in the build directory, or start with a fresh build
-directory.
-
-
-----------
-
-
-**Curses version (terminal-style menu) of CMake**\ :
-
-
-.. parsed-literal::
-
- ccmake ../cmake
-
-You initiate the configuration and build environment generation steps
-separately. For the first you have to type **c**\ , for the second you
-have to type **g**\ . You may need to type **c** multiple times, and may be
-required to edit some of the entries of CMake configuration variables
-in between. Please see the `ccmake manual `_ for
-more information.
+To modify settings, enable or disable features, you need to set *variables*
+with either the *-D* command line flag (``-D VARIABLE1_NAME=value``) or
+change them in the text mode of graphical user interface. The *-D* flag
+can be used several times in one command.
+For your convenience we provide :ref:`CMake presets `
+that combine multiple settings to enable optional LAMMPS packages or use
+a different compiler tool chain. Those are loaded with the *-C* flag
+(``-C ../cmake/presets/minimal.cmake``). This step would only be needed
+once, as the settings from the preset files are stored in the
+``CMakeCache.txt`` file. It is also possible to customize the build
+by adding one or more *-D* flags to the CMake command line.
-----------
+Generating files for alternate build tools (e.g. Ninja) and project files
+for IDEs like Eclipse, CodeBlocks, or Kate can be selected using the *-G*
+command line flag. A list of available generator settings for your
+specific CMake version is given when running ``cmake --help``.
-**GUI version of CMake**\ :
-
-
-.. parsed-literal::
-
- cmake-gui ../cmake
-
-You initiate the configuration and build environment generation steps
-separately. For the first you have to click on the **Configure** button,
-for the second you have to click on the **Generate** button. You may
-need to click on **Configure** multiple times, and may be required to
-edit some of the entries of CMake configuration variables in between.
-Please see the `cmake-gui manual `_
-for more information.
-
-
-----------
-
-
-**Installing CMake**
+Installing CMake
+^^^^^^^^^^^^^^^^
Check if your machine already has CMake installed:
-
-.. parsed-literal::
+.. code-block:: bash
which cmake # do you have it?
which cmake3 # version 3 may have this name
@@ -225,21 +165,16 @@ Check if your machine already has CMake installed:
On clusters or supercomputers which use environment modules to manage
software packages, do this:
+.. code-block:: bash
-.. parsed-literal::
-
- module list # is a cmake module already loaded?
- module avail # is a cmake module available?
- module load cmake3 # load cmake module with appropriate name
-
-Most Linux distributions offer pre-compiled cmake packages through
-their package management system. If you do not have CMake or a new
-enough version, you can download the latest version at
-`https://cmake.org/download/ `_.
-Instructions on how to install it on various platforms can be found
-`on this page `_.
-
+ module list # is a module for cmake already loaded?
+ module avail # is a module for cmake available?
+ module load cmake # load cmake module with appropriate name
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
+Most Linux distributions offer pre-compiled cmake packages through their
+package management system. If you do not have CMake or a recent enough
+version (Note: for CentOS 7.x you need to enable the EPEL repository),
+you can download the latest version from `https://cmake.org/download/
+`_. Instructions on how to install it on
+various platforms can be found `on this page
+`_.
diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst
index 7286caf7b3be0b8d21cd9e839cfc456d7fe4e9ff..474e1fb833f2cec13861a5d06e5937386ddd2dac 100644
--- a/doc/src/Build_development.rst
+++ b/doc/src/Build_development.rst
@@ -1,63 +1,60 @@
Development build options (CMake only)
======================================
-The CMake build of LAMMPS has a few extra options which are useful during
-development, testing or debugging.
-
+The CMake build procedure of LAMMPS offers a few extra options which are
+useful during development, testing or debugging.
----------
-
.. _compilation:
Verify compilation flags
-------------------------------------------
+------------------------
Sometimes it is necessary to verify the complete sequence of compilation flags
generated by the CMake build. To enable a more verbose output during
compilation you can use the following option.
-
-.. parsed-literal::
+.. code-block:: bash
-D CMAKE_VERBOSE_MAKEFILE=value # value = no (default) or yes
Another way of doing this without reconfiguration is calling make with variable VERBOSE set to 1:
-
-.. parsed-literal::
+.. code-block:: bash
make VERBOSE=1
-
----------
-
.. _sanitizer:
Address, Undefined Behavior, and Thread Sanitizer Support
--------------------------------------------------------------------------
+---------------------------------------------------------
-Compilers such as GCC and Clang support generating binaries which use different
-sanitizers to detect problems in code during run-time. They can detect `memory leaks `_,
-code that runs into `undefined behavior `_ of the
-language and `data races `_ in threaded code.
+Compilers such as GCC and Clang support generating instrumented binaries
+which use different sanitizer libraries to detect problems in code
+during run-time. They can detect issues like:
-The following settings allow you enable these features if your compiler supports
-it. Please note that they come with a performance hit. However, they are
-usually faster than using tools like Valgrind.
+ - `memory leaks `_
+ - `undefined behavior `_
+ - `data races `_
+Please note that this kind of instrumentation usually comes with a small
+performance hit (much less than using tools like `Valgrind
+`_). The to enable these features additional
+compiler flags need to be added to the compilation and linking stages.
+This is most easily done through setting the ``CMAKE_TUNE_FLAGS``
+variable during configuration. Examples:
-.. parsed-literal::
-
- -D ENABLE_SANITIZE_ADDRESS=value # enable Address Sanitizer, value = no (default) or yes
- -D ENABLE_SANITIZE_UNDEFINED=value # enable Undefined Behaviour Sanitizer, value = no (default) or yes
- -D ENABLE_SANITIZE_THREAD=value # enable Thread Sanitizer, value = no (default) or yes
+.. code-block:: bash
+ -D CMAKE_TUNE_FLAGS=-fsanitize=address # enable address sanitizer / memory leak checker
+ -D CMAKE_TUNE_FLAGS=-fsanitize=undefined # enable undefined behavior sanitizer
+ -D CMAKE_TUNE_FLAGS=-fsanitize=thread # enable thread sanitizer
----------
-
.. _testing:
Code Coverage and Testing
@@ -71,50 +68,42 @@ developers can run the tests directly on their workstation.
this is incomplete and only represents a small subset of tests that we run
-
-.. parsed-literal::
+.. code-block:: bash
-D ENABLE_TESTING=value # enable simple run tests of LAMMPS, value = no (default) or yes
-D LAMMPS_TESTING_SOURCE_DIR=path # path to lammps-testing repository (option if in custom location)
-D LAMMPS_TESTING_GIT_TAG=value # version of lammps-testing repository that should be used, value = master (default) or custom git commit or tag
-If you enable testing in the CMake build it will create an additional target called "test". You can run them with:
-
+If you enable testing in the CMake build it will create an additional
+target called "test". You can run them with:
-.. parsed-literal::
+.. code-block:: bash
- make test
+ cmake --build . test
The test cases used come from the lammps-testing repository. They are
-derivatives of the examples folder with some modifications to make the run
-faster.
+derivatives of the examples folder with some modifications to make the
+run faster.
-You can also collect code coverage metrics while running the tests by enabling
-coverage support during building.
+You can also collect code coverage metrics while running the tests by
+enabling coverage support during building.
-
-.. parsed-literal::
+.. code-block:: bash
-D ENABLE_COVERAGE=value # enable coverage measurements, value = no (default) or yes
-This will also add the following targets to generate coverage reports after running the LAMMPS executable:
-
+This will also add the following targets to generate coverage reports
+after running the LAMMPS executable:
-.. parsed-literal::
+.. code-block:: bash
make test # run tests first!
make gen_coverage_html # generate coverage report in HTML format
make gen_coverage_xml # generate coverage report in XML format
-These reports require GCOVR to be installed. The easiest way to do this to install it via pip:
+These reports require GCOVR to be installed. The easiest way to do this
+to install it via pip:
-
-.. parsed-literal::
+.. code-block:: bash
pip install git+https://github.com/gcovr/gcovr.git
-
-
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst
index 2cba59bde0e68bff498cf6881bf790d43cfd64f5..5d6f2c65a7d3796cfb1a59ae1eb4e9b499e14a11 100644
--- a/doc/src/Build_extras.rst
+++ b/doc/src/Build_extras.rst
@@ -4,13 +4,17 @@ Packages with extra build options
When building with some packages, additional steps may be required,
in addition to:
+.. code-block:: bash
-.. parsed-literal::
+ $ cmake -D PKG_NAME=yes
+
+or
+
+.. code-block:: bash
- -D PKG_NAME=yes # CMake
- make yes-name # make
+ $ make yes-name
-as described on the :doc:`Build\_package ` doc page.
+as described on the :doc:`Build_package ` doc page.
For a CMake build there may be additional optional or required
variables to set. For a build with make, a provided library under the
@@ -20,22 +24,38 @@ You may need to tell LAMMPS where it is found on your system.
This is the list of packages that may require additional steps.
-+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+
-| :ref:`COMPRESS ` | :ref:`GPU ` | :ref:`KIM ` | :ref:`KOKKOS ` | :ref:`LATTE ` | :ref:`MESSAGE ` |
-+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+
-| :ref:`MSCG ` | :ref:`OPT ` | :ref:`POEMS ` | :ref:`PYTHON ` | :ref:`VORONOI ` | :ref:`USER-ADIOS ` |
-+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+
-| :ref:`USER-ATC ` | :ref:`USER-AWPMD ` | :ref:`USER-COLVARS ` | :ref:`USER-H5MD ` | :ref:`USER-INTEL ` | :ref:`USER-MOLFILE ` |
-+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+
-| :ref:`USER-NETCDF ` | :ref:`USER-PLUMED ` | :ref:`USER-OMP ` | :ref:`USER-QMMM ` | :ref:`USER-QUIP ` | :ref:`USER-SCAFACOS ` |
-+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+
-| :ref:`USER-SMD ` | :ref:`USER-VTK ` | | | | |
-+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+
-
+.. table_from_list::
+ :columns: 6
+
+ * :ref:`COMPRESS `
+ * :ref:`GPU `
+ * :ref:`KIM `
+ * :ref:`KOKKOS `
+ * :ref:`LATTE `
+ * :ref:`MESSAGE `
+ * :ref:`MSCG `
+ * :ref:`OPT `
+ * :ref:`POEMS `
+ * :ref:`PYTHON `
+ * :ref:`VORONOI `
+ * :ref:`USER-ADIOS `
+ * :ref:`USER-ATC `
+ * :ref:`USER-AWPMD `
+ * :ref:`USER-COLVARS `
+ * :ref:`USER-H5MD `
+ * :ref:`USER-INTEL `
+ * :ref:`USER-MOLFILE `
+ * :ref:`USER-NETCDF `
+ * :ref:`USER-PLUMED `
+ * :ref:`USER-OMP `
+ * :ref:`USER-QMMM `
+ * :ref:`USER-QUIP `
+ * :ref:`USER-SCAFACOS `
+ * :ref:`USER-SMD `
+ * :ref:`USER-VTK `
----------
-
.. _compress:
COMPRESS package
@@ -48,89 +68,112 @@ available on your system.
If CMake cannot find the library, you can set these variables:
-
-.. parsed-literal::
+.. code-block:: bash
-D ZLIB_INCLUDE_DIR=path # path to zlib.h header file
-D ZLIB_LIBRARIES=path # path to libz.a (.so) file
**Traditional make**\ :
-If make cannot find the library, you can edit the
-lib/compress/Makefile.lammps file to specify the paths and library
+If make cannot find the library, you can edit the file
+lib/compress/Makefile.lammps to specify the paths and library
name.
-
----------
-
.. _gpu:
GPU package
---------------------
To build with this package, you must choose options for precision and
-which GPU hardware to build for.
+which GPU hardware to build for. The GPU package currently supports
+three different types of backends: OpenCL, CUDA and HIP.
**CMake build**\ :
-
-.. parsed-literal::
-
- -D GPU_API=value # value = opencl (default) or cuda
- -D GPU_PREC=value # precision setting
- # value = double or mixed (default) or single
- -D OCL_TUNE=value # hardware choice for GPU_API=opencl
- # generic (default) or intel (Intel CPU) or fermi, kepler, cypress (NVIDIA)
- -D GPU_ARCH=value # primary GPU hardware choice for GPU_API=cuda
- # value = sm_XX, see below
- # default is sm_30
- -D CUDPP_OPT=value # optimization setting for GPU_API=cuda
- # enables CUDA Performance Primitives Optimizations
- # value = yes (default) or no
- -D CUDA_MPS_SUPPORT=value # enables some tweaks required to run with active nvidia-cuda-mps daemon
- # value = yes or no (default)
-
-GPU\_ARCH settings for different GPU hardware is as follows:
-
-* sm\_12 or sm\_13 for GT200 (supported by CUDA 3.2 until CUDA 6.5)
-* sm\_20 or sm\_21 for Fermi (supported by CUDA 3.2 until CUDA 7.5)
-* sm\_30 or sm\_35 or sm\_37 for Kepler (supported since CUDA 5)
-* sm\_50 or sm\_52 for Maxwell (supported since CUDA 6)
-* sm\_60 or sm\_61 for Pascal (supported since CUDA 8)
-* sm\_70 for Volta (supported since CUDA 9)
-* sm\_75 for Turing (supported since CUDA 10)
+.. code-block:: bash
+
+ -D GPU_API=value # value = opencl (default) or cuda or hip
+ -D GPU_PREC=value # precision setting
+ # value = double or mixed (default) or single
+ -D OCL_TUNE=value # hardware choice for GPU_API=opencl
+ # generic (default) or intel (Intel CPU) or fermi, kepler, cypress (NVIDIA)
+ -D GPU_ARCH=value # primary GPU hardware choice for GPU_API=cuda
+ # value = sm_XX, see below
+ # default is sm_30
+ -D HIP_ARCH=value # primary GPU hardware choice for GPU_API=hip
+ # value depends on selected HIP_PLATFORM
+ # default is 'gfx906' for HIP_PLATFORM=hcc and 'sm_30' for HIP_PLATFORM=nvcc
+ -D HIP_USE_DEVICE_SORT=value # enables GPU sorting
+ # value = yes (default) or no
+ -D CUDPP_OPT=value # optimization setting for GPU_API=cuda
+ # enables CUDA Performance Primitives Optimizations
+ # value = yes (default) or no
+ -D CUDA_MPS_SUPPORT=value # enables some tweaks required to run with active nvidia-cuda-mps daemon
+ # value = yes or no (default)
+
+:code:`GPU_ARCH` settings for different GPU hardware is as follows:
+
+* sm_12 or sm_13 for GT200 (supported by CUDA 3.2 until CUDA 6.5)
+* sm_20 or sm_21 for Fermi (supported by CUDA 3.2 until CUDA 7.5)
+* sm_30 or sm_35 or sm_37 for Kepler (supported since CUDA 5)
+* sm_50 or sm_52 for Maxwell (supported since CUDA 6)
+* sm_60 or sm_61 for Pascal (supported since CUDA 8)
+* sm_70 for Volta (supported since CUDA 9)
+* sm_75 for Turing (supported since CUDA 10)
A more detailed list can be found, for example,
at `Wikipedia's CUDA article `_
CMake can detect which version of the CUDA toolkit is used and thus can
include support for **all** major GPU architectures supported by this toolkit.
-Thus the GPU\_ARCH setting is merely an optimization, to have code for
+Thus the GPU_ARCH setting is merely an optimization, to have code for
the preferred GPU architecture directly included rather than having to wait
for the JIT compiler of the CUDA driver to translate it.
+If you are compiling with HIP, note that before running CMake you will have to
+set appropriate environment variables. Some variables such as
+:code:`HCC_AMDGPU_TARGET` or :code:`CUDA_PATH` are necessary for :code:`hipcc`
+and the linker to work correctly.
+
+.. code:: bash
+
+ # AMDGPU target
+ export HIP_PLATFORM=hcc
+ export HCC_AMDGPU_TARGET=gfx906
+ cmake -D PKG_GPU=on -D GPU_API=HIP -D HIP_ARCH=gfx906 -D CMAKE_CXX_COMPILER=hipcc ..
+ make -j 4
+
+.. code:: bash
+
+ # CUDA target
+ # !!! DO NOT set CMAKE_CXX_COMPILER !!!
+ export HIP_PLATFORM=nvcc
+ export CUDA_PATH=/usr/local/cuda
+ cmake -D PKG_GPU=on -D GPU_API=HIP -D HIP_ARCH=sm_70 ..
+ make -j 4
+
**Traditional make**\ :
-Before building LAMMPS, you must build the GPU library in lib/gpu.
+Before building LAMMPS, you must build the GPU library in ``lib/gpu``\ .
You can do this manually if you prefer; follow the instructions in
-lib/gpu/README. Note that the GPU library uses MPI calls, so you must
+``lib/gpu/README``. Note that the GPU library uses MPI calls, so you must
use the same MPI library (or the STUBS library) settings as the main
-LAMMPS code. This also applies to the -DLAMMPS\_BIGBIG,
--DLAMMPS\_SMALLBIG, or -DLAMMPS\_SMALLSMALL settings in whichever
+LAMMPS code. This also applies to the ``-DLAMMPS_BIGBIG``\ ,
+``-DLAMMPS_SMALLBIG``\ , or ``-DLAMMPS_SMALLSMALL`` settings in whichever
Makefile you use.
-You can also build the library in one step from the lammps/src dir,
-using a command like these, which simply invoke the lib/gpu/Install.py
+You can also build the library in one step from the ``lammps/src`` dir,
+using a command like these, which simply invoke the ``lib/gpu/Install.py``
script with the specified args:
+.. code-block:: bash
-.. parsed-literal::
-
- make lib-gpu # print help message
- make lib-gpu args="-b" # build GPU library with default Makefile.linux
- make lib-gpu args="-m xk7 -p single -o xk7.single" # create new Makefile.xk7.single, altered for single-precision
- make lib-gpu args="-m mpi -a sm_60 -p mixed -b" # build GPU library with mixed precision and P100 using other settings in Makefile.mpi
+ $ make lib-gpu # print help message
+ $ make lib-gpu args="-b" # build GPU library with default Makefile.linux
+ $ make lib-gpu args="-m xk7 -p single -o xk7.single" # create new Makefile.xk7.single, altered for single-precision
+ $ make lib-gpu args="-m mpi -a sm_60 -p mixed -b" # build GPU library with mixed precision and P100 using other settings in Makefile.mpi
Note that this procedure starts with a Makefile.machine in lib/gpu, as
specified by the "-m" switch. For your convenience, machine makefiles
@@ -141,22 +184,22 @@ Makefile.machine you start from via the corresponding -c, -a, -p, -e
switches (as in the examples above), and also save a copy of the new
Makefile if desired:
-* CUDA\_HOME = where NVIDIA CUDA software is installed on your system
-* CUDA\_ARCH = sm\_XX, what GPU hardware you have, same as CMake GPU\_ARCH above
-* CUDA\_PRECISION = precision (double, mixed, single)
-* EXTRAMAKE = which Makefile.lammps.\* file to copy to Makefile.lammps
+* ``CUDA_HOME`` = where NVIDIA CUDA software is installed on your system
+* ``CUDA_ARCH`` = sm_XX, what GPU hardware you have, same as CMake GPU_ARCH above
+* ``CUDA_PRECISION`` = precision (double, mixed, single)
+* ``EXTRAMAKE`` = which Makefile.lammps.\* file to copy to Makefile.lammps
-The file Makefile.linux\_multi is set up to include support for multiple
+The file Makefile.linux_multi is set up to include support for multiple
GPU architectures as supported by the CUDA toolkit in use. This is done
through using the "--gencode " flag, which can be used multiple times and
thus support all GPU architectures supported by your CUDA compiler.
If the library build is successful, 3 files should be created:
-lib/gpu/libgpu.a, lib/gpu/nvc\_get\_devices, and
-lib/gpu/Makefile.lammps. The latter has settings that enable LAMMPS
-to link with CUDA libraries. If the settings in Makefile.lammps for
+``lib/gpu/libgpu.a``\ , ``lib/gpu/nvc_get_devices``\ , and
+``lib/gpu/Makefile.lammps``\ . The latter has settings that enable LAMMPS
+to link with CUDA libraries. If the settings in ``Makefile.lammps`` for
your machine are not correct, the LAMMPS build will fail, and
-lib/gpu/Makefile.lammps may need to be edited.
+``lib/gpu/Makefile.lammps`` may need to be edited.
.. note::
@@ -166,21 +209,34 @@ lib/gpu/Makefile.lammps may need to be edited.
package uses the library settings from the lib/gpu/Makefile.machine
used to build the GPU library.
-
----------
-
.. _kim:
KIM package
---------------------
To build with this package, the KIM library with API v2 must be downloaded
-and built on your system. It must include the KIM models that you want to
-use with LAMMPS. If you want to use the :doc:`kim\_query `
+and built on your system. It must include the KIM models that you want to
+use with LAMMPS.
+
+If you would like to use the :doc:`kim_query `
command, you also need to have libcurl installed with the matching
development headers and the curl-config tool.
+If you would like to use the :doc:`kim_property `
+command, you need to build LAMMPS with the Python 3.6 or later package
+installed. See the :doc:`Python ` doc page for more info on building
+LAMMPS with the version of Python on your system.
+After successfully building LAMMPS with Python, you need to
+install the kim-property Python package, which can be easily done using
+*pip* as ``pip install kim-property``, or from the *conda-forge* channel as
+``conda install kim-property`` if LAMMPS is built in Conda. More detailed
+information is available at:
+`kim-property installation `_.
+
+In addition to installing the KIM API, it is also necessary to install the
+library of KIM models (interatomic potentials).
See `Obtaining KIM Models `_ to
learn how to install a pre-build binary of the OpenKIM Repository of Models.
See the list of all KIM models here: https://openkim.org/browse/models
@@ -191,182 +247,344 @@ minutes to hours) to build. Of course you only need to do that once.)
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D DOWNLOAD_KIM=value # download OpenKIM API v2 for build, value = no (default) or yes
-D LMP_DEBUG_CURL=value # set libcurl verbose mode on/off, value = off (default) or on
-D LMP_NO_SSL_CHECK=value # tell libcurl to not verify the peer, value = no (default) or yes
-If DOWNLOAD\_KIM is set, the KIM library will be downloaded and built
+If ``DOWNLOAD_KIM`` is set, the KIM library will be downloaded and built
inside the CMake build directory. If the KIM library is already on
-your system (in a location CMake cannot find it), set the PKG\_CONFIG\_PATH
+your system (in a location CMake cannot find it), set the ``PKG_CONFIG_PATH``
environment variable so that libkim-api can be found.
-For using OpenKIM web queries in LAMMPS.
+*For using OpenKIM web queries in LAMMPS*\ :
-If LMP\_DEBUG\_CURL is set, the libcurl verbose mode will be on, and any
-libcurl calls within the KIM web query display a lot of information about
-libcurl operations. You hardly ever want this set in production use, you will
-almost always want this when you debug/report problems.
+If the ``LMP_DEBUG_CURL`` environment variable is set, the libcurl verbose
+mode will be on, and any libcurl calls within the KIM web query display a
+lot of information about libcurl operations. You hardly ever want this
+set in production use, you will almost always want this when you debug or
+report problems.
The libcurl performs peer SSL certificate verification by default. This
verification is done using a CA certificate store that the SSL library can
use to make sure the peer's server certificate is valid. If SSL reports an
error ("certificate verify failed") during the handshake and thus refuses
-further communication with that server, you can set LMP\_NO\_SSL\_CHECK.
-If LMP\_NO\_SSL\_CHECK is set, libcurl does not verify the peer and connection
+further communication with that server, you can set ``LMP_NO_SSL_CHECK``\ .
+If ``LMP_NO_SSL_CHECK`` is set, libcurl does not verify the peer and connection
succeeds regardless of the names in the certificate. This option is insecure.
As an alternative, you can specify your own CA cert path by setting the
-environment variable CURL\_CA\_BUNDLE to the path of your choice. A call to the
-KIM web query would get this value from the environmental variable.
+environment variable ``CURL_CA_BUNDLE`` to the path of your choice. A call
+to the KIM web query would get this value from the environmental variable.
**Traditional make**\ :
You can download and build the KIM library manually if you prefer;
-follow the instructions in lib/kim/README. You can also do it in one
+follow the instructions in ``lib/kim/README``\ . You can also do it in one
step from the lammps/src dir, using a command like these, which simply
-invoke the lib/kim/Install.py script with the specified args.
+invoke the ``lib/kim/Install.py`` script with the specified args.
+.. code-block:: bash
-.. parsed-literal::
+ $ make lib-kim # print help message
+ $ make lib-kim args="-b " # (re-)install KIM API lib with only example models
+ $ make lib-kim args="-b -a Glue_Ercolessi_Adams_Al__MO_324507536345_001" # ditto plus one model
+ $ make lib-kim args="-b -a everything" # install KIM API lib with all models
+ $ make lib-kim args="-n -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # add one model or model driver
+ $ make lib-kim args="-p /usr/local" # use an existing KIM API installation at the provided location
+ $ make lib-kim args="-p /usr/local -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # ditto but add one model or driver
- make lib-kim # print help message
- make lib-kim args="-b " # (re-)install KIM API lib with only example models
- make lib-kim args="-b -a Glue_Ercolessi_Adams_Al__MO_324507536345_001" # ditto plus one model
- make lib-kim args="-b -a everything" # install KIM API lib with all models
- make lib-kim args="-n -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # add one model or model driver
- make lib-kim args="-p /usr/local" # use an existing KIM API installation at the provided location
- make lib-kim args="-p /usr/local -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # ditto but add one model or driver
+Settings for OpenKIM web queries discussed above need to be applied by adding
+them to the ``LMP_INC`` variable through editing the Makefile.machine you are
+using. For example:
+.. code-block:: make
-----------
+ LMP_INC = -DLMP_NO_SSL_CHECK
+----------
.. _kokkos:
KOKKOS package
----------------------------
+--------------
-To build with this package, you must choose which hardware you want to
-build for, either CPUs (multi-threading via OpenMP) or KNLs (OpenMP)
-or GPUs (NVIDIA Cuda).
-
-For a CMake or make build, these are the possible choices for the
-KOKKOS\_ARCH settings described below. Note that for CMake, these are
-really Kokkos variables, not LAMMPS variables. Hence you must use
-case-sensitive values, e.g. BDW, not bdw.
-
-* ARMv80 = ARMv8.0 Compatible CPU
-* ARMv81 = ARMv8.1 Compatible CPU
-* ARMv8-ThunderX = ARMv8 Cavium ThunderX CPU
-* BGQ = IBM Blue Gene/Q CPUs
-* Power8 = IBM POWER8 CPUs
-* Power9 = IBM POWER9 CPUs
-* SNB = Intel Sandy/Ivy Bridge CPUs
-* HSW = Intel Haswell CPUs
-* BDW = Intel Broadwell Xeon E-class CPUs
-* SKX = Intel Sky Lake Xeon E-class HPC CPUs (AVX512)
-* KNC = Intel Knights Corner Xeon Phi
-* KNL = Intel Knights Landing Xeon Phi
-* Kepler30 = NVIDIA Kepler generation CC 3.0
-* Kepler32 = NVIDIA Kepler generation CC 3.2
-* Kepler35 = NVIDIA Kepler generation CC 3.5
-* Kepler37 = NVIDIA Kepler generation CC 3.7
-* Maxwell50 = NVIDIA Maxwell generation CC 5.0
-* Maxwell52 = NVIDIA Maxwell generation CC 5.2
-* Maxwell53 = NVIDIA Maxwell generation CC 5.3
-* Pascal60 = NVIDIA Pascal generation CC 6.0
-* Pascal61 = NVIDIA Pascal generation CC 6.1
-* Volta70 = NVIDIA Volta generation CC 7.0
-* Volta72 = NVIDIA Volta generation CC 7.2
-* Turing75 = NVIDIA Turing generation CC 7.5
+Using the KOKKOS package requires choosing several settings. You have
+to select whether you want to compile with parallelization on the host
+and whether you want to include offloading of calculations to a device
+(e.g. a GPU). The default setting is to have no host parallelization
+and no device offloading. In addition, you can select the hardware
+architecture to select the instruction set. Since most hardware is
+backward compatible, you may choose settings for an older architecture
+to have an executable that will run on this and newer architectures.
-**CMake build**\ :
+.. note::
+ If you run Kokkos on a newer GPU architecture than what LAMMPS was
+ compiled with, there will be a delay during device initialization
+ since the just-in-time compiler has to recompile all GPU kernels
+ for the new hardware. This is, however, not possible when compiled
+ for NVIDIA GPUs with CC 3.x (Kepler) for GPUs with CC 5.0 (Maxwell)
+ and newer as they are not compatible.
+
+The settings discussed below have been tested with LAMMPS and are
+confirmed to work. Kokkos is an active project with ongoing improvements
+and projects working on including support for additional architectures.
+More information on Kokkos can be found on the
+`Kokkos GitHub project `_.
+
+Available Architecture settings
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+These are the possible choices for the Kokkos architecture ID. They must
+be specified in uppercase.
+
+.. list-table::
+ :header-rows: 0
+ :widths: auto
+
+ * - **Arch-ID**
+ - **HOST or GPU**
+ - **Description**
+ * - AMDAVX
+ - HOST
+ - AMD 64-bit x86 CPU (AVX 1)
+ * - EPYC
+ - HOST
+ - AMD EPYC Zen class CPU (AVX 2)
+ * - ARMV80
+ - HOST
+ - ARMv8.0 Compatible CPU
+ * - ARMV81
+ - HOST
+ - ARMv8.1 Compatible CPU
+ * - ARMV8_THUNDERX
+ - HOST
+ - ARMv8 Cavium ThunderX CPU
+ * - ARMV8_THUNDERX2
+ - HOST
+ - ARMv8 Cavium ThunderX2 CPU
+ * - WSM
+ - HOST
+ - Intel Westmere CPU (SSE 4.2)
+ * - SNB
+ - HOST
+ - Intel Sandy/Ivy Bridge CPU (AVX 1)
+ * - HSW
+ - HOST
+ - Intel Haswell CPU (AVX 2)
+ * - BDW
+ - HOST
+ - Intel Broadwell Xeon E-class CPU (AVX 2 + transactional mem)
+ * - SKX
+ - HOST
+ - Intel Sky Lake Xeon E-class HPC CPU (AVX512 + transactional mem)
+ * - KNC
+ - HOST
+ - Intel Knights Corner Xeon Phi
+ * - KNL
+ - HOST
+ - Intel Knights Landing Xeon Phi
+ * - BGQ
+ - HOST
+ - IBM Blue Gene/Q CPU
+ * - POWER7
+ - HOST
+ - IBM POWER7 CPU
+ * - POWER8
+ - HOST
+ - IBM POWER8 CPU
+ * - POWER9
+ - HOST
+ - IBM POWER9 CPU
+ * - KEPLER30
+ - GPU
+ - NVIDIA Kepler generation CC 3.0 GPU
+ * - KEPLER32
+ - GPU
+ - NVIDIA Kepler generation CC 3.2 GPU
+ * - KEPLER35
+ - GPU
+ - NVIDIA Kepler generation CC 3.5 GPU
+ * - KEPLER37
+ - GPU
+ - NVIDIA Kepler generation CC 3.7 GPU
+ * - MAXWELL50
+ - GPU
+ - NVIDIA Maxwell generation CC 5.0 GPU
+ * - MAXWELL52
+ - GPU
+ - NVIDIA Maxwell generation CC 5.2 GPU
+ * - MAXWELL53
+ - GPU
+ - NVIDIA Maxwell generation CC 5.3 GPU
+ * - PASCAL60
+ - GPU
+ - NVIDIA Pascal generation CC 6.0 GPU
+ * - PASCAL61
+ - GPU
+ - NVIDIA Pascal generation CC 6.1 GPU
+ * - VOLTA70
+ - GPU
+ - NVIDIA Volta generation CC 7.0 GPU
+ * - VOLTA72
+ - GPU
+ - NVIDIA Volta generation CC 7.2 GPU
+ * - TURING75
+ - GPU
+ - NVIDIA Turing generation CC 7.5 GPU
+ * - VEGA900
+ - GPU
+ - AMD GPU MI25 GFX900
+ * - VEGA906
+ - GPU
+ - AMD GPU MI50/MI60 GFX906
+
+Basic CMake build settings:
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
For multicore CPUs using OpenMP, set these 2 variables.
+.. code-block:: bash
-.. parsed-literal::
+ -D Kokkos_ARCH_HOSTARCH=yes # HOSTARCH = HOST from list above
+ -D Kokkos_ENABLE_OPENMP=yes
+ -D BUILD_OMP=yes
- -D KOKKOS_ARCH=archCPU # archCPU = CPU from list above
- -D KOKKOS_ENABLE_OPENMP=yes
+Please note that enabling OpenMP for KOKKOS requires that OpenMP is
+also :ref:`enabled for the rest of LAMMPS `.
-For Intel KNLs using OpenMP, set these 2 variables:
+For Intel KNLs using OpenMP, set these variables:
+.. code-block:: bash
-.. parsed-literal::
+ -D Kokkos_ARCH_KNL=yes
+ -D Kokkos_ENABLE_OPENMP=yes
- -D KOKKOS_ARCH=KNL
- -D KOKKOS_ENABLE_OPENMP=yes
+For NVIDIA GPUs using CUDA, set these variables:
-For NVIDIA GPUs using CUDA, set these 4 variables:
+.. code-block:: bash
+ -D Kokkos_ARCH_HOSTARCH=yes # HOSTARCH = HOST from list above
+ -D Kokkos_ARCH_GPUARCH=yes # GPUARCH = GPU from list above
+ -D Kokkos_ENABLE_CUDA=yes
+ -D Kokkos_ENABLE_OPENMP=yes
+ -D CMAKE_CXX_COMPILER=wrapper # wrapper = full path to Cuda nvcc wrapper
-.. parsed-literal::
+This will also enable executing FFTs on the GPU, either via the internal
+KISSFFT library, or - by preference - with the cuFFT library bundled
+with the CUDA toolkit, depending on whether CMake can identify its
+location. The *wrapper* value for ``CMAKE_CXX_COMPILER`` variable is
+the path to the CUDA nvcc compiler wrapper provided in the Kokkos
+library: ``lib/kokkos/bin/nvcc_wrapper``\ . The setting should include
+the full path name to the wrapper, e.g.
- -D KOKKOS_ARCH="archCPU;archGPU" # archCPU = CPU from list above that is hosting the GPU
- # archGPU = GPU from list above
- -D KOKKOS_ENABLE_CUDA=yes
- -D KOKKOS_ENABLE_OPENMP=yes
- -D CMAKE_CXX_COMPILER=wrapper # wrapper = full path to Cuda nvcc wrapper
+.. code-block:: bash
-The wrapper value is the Cuda nvcc compiler wrapper provided in the
-Kokkos library: lib/kokkos/bin/nvcc\_wrapper. The setting should
-include the full path name to the wrapper, e.g.
+ -D CMAKE_CXX_COMPILER=${HOME}/lammps/lib/kokkos/bin/nvcc_wrapper
+To simplify the compilation, three preset files are included in the
+``cmake/presets`` folder, ``kokkos-serial.cmake``, ``kokkos-openmp.cmake``,
+and ``kokkos-cuda.cmake``. They will enable the KOKKOS package and
+enable some hardware choice. So to compile with OpenMP host parallelization,
+CUDA device parallelization (for GPUs with CC 5.0 and up) with some
+common packages enabled, you can do the following:
-.. parsed-literal::
+.. code-block:: bash
- -D CMAKE_CXX_COMPILER=/home/username/lammps/lib/kokkos/bin/nvcc_wrapper
+ mkdir build-kokkos-cuda
+ cd build-kokkos-cuda
+ cmake -C ../cmake/presets/minimal.cmake -C ../cmake/presets/kokkos-cuda.cmake ../cmake
+ cmake --build .
-**Traditional make**\ :
+Basic traditional make settings:
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Choose which hardware to support in Makefile.machine via
-KOKKOS\_DEVICES and KOKKOS\_ARCH settings. See the
-src/MAKE/OPTIONS/Makefile.kokkos\* files for examples.
+Choose which hardware to support in ``Makefile.machine`` via
+``KOKKOS_DEVICES`` and ``KOKKOS_ARCH`` settings. See the
+``src/MAKE/OPTIONS/Makefile.kokkos*`` files for examples.
For multicore CPUs using OpenMP:
-
-.. parsed-literal::
+.. code-block:: make
KOKKOS_DEVICES = OpenMP
- KOKKOS_ARCH = archCPU # archCPU = CPU from list above
+ KOKKOS_ARCH = HOSTARCH # HOSTARCH = HOST from list above
For Intel KNLs using OpenMP:
-
-.. parsed-literal::
+.. code-block:: make
KOKKOS_DEVICES = OpenMP
KOKKOS_ARCH = KNL
For NVIDIA GPUs using CUDA:
-
-.. parsed-literal::
+.. code-block:: make
KOKKOS_DEVICES = Cuda
- KOKKOS_ARCH = archCPU,archGPU # archCPU = CPU from list above that is hosting the GPU
- # archGPU = GPU from list above
-
-For GPUs, you also need these 2 lines in your Makefile.machine before
-the CC line is defined, in this case for use with OpenMPI mpicxx. The
-2 lines define a nvcc wrapper compiler, which will use nvcc for
-compiling CUDA files and use a C++ compiler for non-Kokkos, non-CUDA
-files.
+ KOKKOS_ARCH = HOSTARCH,GPUARCH # HOSTARCH = HOST from list above that is hosting the GPU
+ KOKKOS_CUDA_OPTIONS = "enable_lambda"
+ # GPUARCH = GPU from list above
+ FFT_INC = -DFFT_CUFFT # enable use of cuFFT (optional)
+ FFT_LIB = -lcufft # link to cuFFT library
+For GPUs, you also need the following lines in your ``Makefile.machine``
+before the CC line is defined. They tell ``mpicxx`` to use an ``nvcc``
+compiler wrapper, which will use ``nvcc`` for compiling CUDA files and a
+C++ compiler for non-Kokkos, non-CUDA files.
-.. parsed-literal::
+.. code-block:: make
+ # For OpenMPI
KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd)
export OMPI_CXX = $(KOKKOS_ABSOLUTE_PATH)/config/nvcc_wrapper
- CC = mpicxx
+ CC = mpicxx
+.. code-block:: make
-----------
+ # For MPICH and derivatives
+ KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd)
+ CC = mpicxx -cxx=$(KOKKOS_ABSOLUTE_PATH)/config/nvcc_wrapper
+
+
+Advanced KOKKOS compilation settings
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+There are other allowed options when building with the KOKKOS package
+that can improve performance or assist in debugging or profiling. Below
+are some examples that may be useful in combination with LAMMPS. For
+the full list (which keeps changing as the Kokkos package itself evolves),
+please consult the Kokkos library documentation.
+
+As alternative to using multi-threading via OpenMP
+(``-DKokkos_ENABLE_OPENMP=on`` or ``KOKKOS_DEVICES=OpenMP``) it is also
+possible to use Posix threads directly (``-DKokkos_ENABLE_PTHREAD=on``
+or ``KOKKOS_DEVICES=Pthread``). While binding of threads to individual
+or groups of CPU cores is managed in OpenMP with environment variables,
+you need assistance from either the "hwloc" or "libnuma" library for the
+Pthread thread parallelization option. To enable use with CMake:
+``-DKokkos_ENABLE_HWLOC=on`` or ``-DKokkos_ENABLE_LIBNUMA=on``; and with
+conventional make: ``KOKKOS_USE_TPLS=hwloc`` or
+``KOKKOS_USE_TPLS=libnuma``.
+
+The CMake option ``-DKokkos_ENABLE_LIBRT=on`` or the makefile setting
+``KOKKOS_USE_TPLS=librt`` enables the use of a more accurate timer
+mechanism on many Unix-like platforms for internal profiling.
+
+The CMake option ``-DKokkos_ENABLE_DEBUG=on`` or the makefile setting
+``KOKKOS_DEBUG=yes`` enables printing of run-time
+debugging information that can be useful. It also enables runtime
+bounds checking on Kokkos data structures. As to be expected, enabling
+this option will negatively impact the performance and thus is only
+recommended when developing a Kokkos-enabled style in LAMMPS.
+
+The CMake option ``-DKokkos_ENABLE_CUDA_UVM=on`` or the makefile
+setting ``KOKKOS_CUDA_OPTIONS=enable_lambda,force_uvm`` enables the
+use of CUDA "Unified Virtual Memory" in Kokkos. Please note, that
+the LAMMPS KOKKOS package must **always** be compiled with the
+*enable_lambda* option when using GPUs.
+----------
.. _latte:
@@ -378,34 +596,32 @@ library.
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D DOWNLOAD_LATTE=value # download LATTE for build, value = no (default) or yes
-D LATTE_LIBRARY=path # LATTE library file (only needed if a custom location)
-If DOWNLOAD\_LATTE is set, the LATTE library will be downloaded and
+If ``DOWNLOAD_LATTE`` is set, the LATTE library will be downloaded and
built inside the CMake build directory. If the LATTE library is
already on your system (in a location CMake cannot find it),
-LATTE\_LIBRARY is the filename (plus path) of the LATTE library file,
+``LATTE_LIBRARY`` is the filename (plus path) of the LATTE library file,
not the directory the library file is in.
**Traditional make**\ :
You can download and build the LATTE library manually if you prefer;
-follow the instructions in lib/latte/README. You can also do it in
-one step from the lammps/src dir, using a command like these, which
-simply invokes the lib/latte/Install.py script with the specified
+follow the instructions in ``lib/latte/README``\ . You can also do it in
+one step from the ``lammps/src`` dir, using a command like these, which
+simply invokes the ``lib/latte/Install.py`` script with the specified
args:
+.. code-block:: bash
-.. parsed-literal::
-
- make lib-latte # print help message
- make lib-latte args="-b" # download and build in lib/latte/LATTE-master
- make lib-latte args="-p $HOME/latte" # use existing LATTE installation in $HOME/latte
- make lib-latte args="-b -m gfortran" # download and build in lib/latte and
- # copy Makefile.lammps.gfortran to Makefile.lammps
+ $ make lib-latte # print help message
+ $ make lib-latte args="-b" # download and build in lib/latte/LATTE-master
+ $ make lib-latte args="-p $HOME/latte" # use existing LATTE installation in $HOME/latte
+ $ make lib-latte args="-b -m gfortran" # download and build in lib/latte and
+ # copy Makefile.lammps.gfortran to Makefile.lammps
Note that 3 symbolic (soft) links, "includelink" and "liblink" and
"filelink.o", are created in lib/latte to point into the LATTE home
@@ -413,10 +629,8 @@ dir. When LAMMPS itself is built it will use these links. You should
also check that the Makefile.lammps file you create is appropriate for
the compiler you use on your system to build LATTE.
-
----------
-
.. _message:
MESSAGE package
@@ -428,8 +642,7 @@ be installed on your system.
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D MESSAGE_ZMQ=value # build with ZeroMQ support, value = no (default) or yes
-D ZMQ_LIBRARY=path # ZMQ library file (only needed if a custom location)
@@ -438,80 +651,73 @@ be installed on your system.
**Traditional make**\ :
Before building LAMMPS, you must build the CSlib library in
-lib/message. You can build the CSlib library manually if you prefer;
-follow the instructions in lib/message/README. You can also do it in
-one step from the lammps/src dir, using a command like these, which
-simply invoke the lib/message/Install.py script with the specified args:
+``lib/message``\ . You can build the CSlib library manually if you prefer;
+follow the instructions in ``lib/message/README``\ . You can also do it in
+one step from the ``lammps/src`` dir, using a command like these, which
+simply invoke the ``lib/message/Install.py`` script with the specified args:
+.. code-block:: bash
-.. parsed-literal::
-
- make lib-message # print help message
- make lib-message args="-m -z" # build with MPI and socket (ZMQ) support
- make lib-message args="-s" # build as serial lib with no ZMQ support
+ $ make lib-message # print help message
+ $ make lib-message args="-m -z" # build with MPI and socket (ZMQ) support
+ $ make lib-message args="-s" # build as serial lib with no ZMQ support
-The build should produce two files: lib/message/cslib/src/libmessage.a
-and lib/message/Makefile.lammps. The latter is copied from an
-existing Makefile.lammps.\* and has settings to link with the ZeroMQ
+The build should produce two files: ``lib/message/cslib/src/libmessage.a``
+and ``lib/message/Makefile.lammps``\ . The latter is copied from an
+existing ``Makefile.lammps.\*`` and has settings to link with the ZeroMQ
library if requested in the build.
-
----------
-
.. _mscg:
MSCG package
-----------------------
To build with this package, you must download and build the MS-CG
-library. Building the MS-CG library and using it from LAMMPS requires
-a C++11 compatible compiler and that the GSL (GNU Scientific Library)
-headers and libraries are installed on your machine. See the
-lib/mscg/README and MSCG/Install files for more details.
+library. Building the MS-CG library requires that the GSL
+(GNU Scientific Library) headers and libraries are installed on your
+machine. See the ``lib/mscg/README`` and ``MSCG/Install`` files for
+more details.
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D DOWNLOAD_MSCG=value # download MSCG for build, value = no (default) or yes
-D MSCG_LIBRARY=path # MSCG library file (only needed if a custom location)
-D MSCG_INCLUDE_DIR=path # MSCG include directory (only needed if a custom location)
-If DOWNLOAD\_MSCG is set, the MSCG library will be downloaded and built
+If ``DOWNLOAD_MSCG`` is set, the MSCG library will be downloaded and built
inside the CMake build directory. If the MSCG library is already on
-your system (in a location CMake cannot find it), MSCG\_LIBRARY is the
+your system (in a location CMake cannot find it), ``MSCG_LIBRARY`` is the
filename (plus path) of the MSCG library file, not the directory the
-library file is in. MSCG\_INCLUDE\_DIR is the directory the MSCG
+library file is in. ``MSCG_INCLUDE_DIR`` is the directory the MSCG
include file is in.
**Traditional make**\ :
You can download and build the MS-CG library manually if you prefer;
-follow the instructions in lib/mscg/README. You can also do it in one
-step from the lammps/src dir, using a command like these, which simply
-invoke the lib/mscg/Install.py script with the specified args:
+follow the instructions in ``lib/mscg/README``\ . You can also do it in one
+step from the ``lammps/src`` dir, using a command like these, which simply
+invoke the ``lib/mscg/Install.py`` script with the specified args:
+.. code-block:: bash
-.. parsed-literal::
-
- make lib-mscg # print help message
- make lib-mscg args="-b -m serial" # download and build in lib/mscg/MSCG-release-master
+ $ make lib-mscg # print help message
+ $ make lib-mscg args="-b -m serial" # download and build in lib/mscg/MSCG-release-master
# with the settings compatible with "make serial"
- make lib-mscg args="-b -m mpi" # download and build in lib/mscg/MSCG-release-master
+ $ make lib-mscg args="-b -m mpi" # download and build in lib/mscg/MSCG-release-master
# with the settings compatible with "make mpi"
- make lib-mscg args="-p /usr/local/mscg-release" # use the existing MS-CG installation in /usr/local/mscg-release
+ $ make lib-mscg args="-p /usr/local/mscg-release" # use the existing MS-CG installation in /usr/local/mscg-release
Note that 2 symbolic (soft) links, "includelink" and "liblink", will
-be created in lib/mscg to point to the MS-CG src/installation dir.
-When LAMMPS is built in src it will use these links. You should not
-need to edit the lib/mscg/Makefile.lammps file.
-
+be created in ``lib/mscg`` to point to the MS-CG ``src/installation``
+dir. When LAMMPS is built in src it will use these links. You should
+not need to edit the ``lib/mscg/Makefile.lammps`` file.
----------
-
.. _opt:
OPT package
@@ -519,7 +725,7 @@ OPT package
**CMake build**\ :
-No additional settings are needed besides "-D PKG\_OPT=yes".
+No additional settings are needed besides ``-D PKG_OPT=yes``
**Traditional make**\ :
@@ -528,10 +734,8 @@ package when using Intel compilers. It should be added to the CCFLAGS
line of your Makefile.machine. See src/MAKE/OPTIONS/Makefile.opt for
an example.
-
----------
-
.. _poems:
POEMS package
@@ -539,71 +743,65 @@ POEMS package
**CMake build**\ :
-No additional settings are needed besides "-D PKG\_OPT=yes".
+No additional settings are needed besides ``-D PKG_OPT=yes``
**Traditional make**\ :
-Before building LAMMPS, you must build the POEMS library in lib/poems.
+Before building LAMMPS, you must build the POEMS library in ``lib/poems``\ .
You can do this manually if you prefer; follow the instructions in
-lib/poems/README. You can also do it in one step from the lammps/src
+``lib/poems/README``\ . You can also do it in one step from the ``lammps/src``
dir, using a command like these, which simply invoke the
-lib/poems/Install.py script with the specified args:
+``lib/poems/Install.py`` script with the specified args:
+.. code-block:: bash
-.. parsed-literal::
+ $ make lib-poems # print help message
+ $ make lib-poems args="-m serial" # build with GNU g++ compiler (settings as with "make serial")
+ $ make lib-poems args="-m mpi" # build with default MPI C++ compiler (settings as with "make mpi")
+ $ make lib-poems args="-m icc" # build with Intel icc compiler
- make lib-poems # print help message
- make lib-poems args="-m serial" # build with GNU g++ compiler (settings as with "make serial")
- make lib-poems args="-m mpi" # build with default MPI C++ compiler (settings as with "make mpi")
- make lib-poems args="-m icc" # build with Intel icc compiler
-
-The build should produce two files: lib/poems/libpoems.a and
-lib/poems/Makefile.lammps. The latter is copied from an existing
-Makefile.lammps.\* and has settings needed to build LAMMPS with the
+The build should produce two files: ``lib/poems/libpoems.a`` and
+``lib/poems/Makefile.lammps``\ . The latter is copied from an existing
+``Makefile.lammps.\*`` and has settings needed to build LAMMPS with the
POEMS library (though typically the settings are just blank). If
-necessary, you can edit/create a new lib/poems/Makefile.machine file
-for your system, which should define an EXTRAMAKE variable to specify
-a corresponding Makefile.lammps.machine file.
-
+necessary, you can edit/create a new ``lib/poems/Makefile.machine`` file
+for your system, which should define an ``EXTRAMAKE`` variable to specify
+a corresponding ``Makefile.lammps.machine`` file.
----------
-
.. _python:
PYTHON package
---------------------------
Building with the PYTHON package requires you have a Python shared
-library available on your system, which needs to be a Python 2
-version, 2.6 or later. Python 3 is not yet supported. See
-lib/python/README for more details.
+library available on your system, which needs to be a Python 2.7
+version or a Python 3.x version. See ``lib/python/README`` for more
+details.
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D PYTHON_EXECUTABLE=path # path to Python executable to use
Without this setting, CMake will guess the default Python on your
system. To use a different Python version, you can either create a
virtualenv, activate it and then run cmake. Or you can set the
-PYTHON\_EXECUTABLE variable to specify which Python interpreter should
+PYTHON_EXECUTABLE variable to specify which Python interpreter should
be used. Note note that you will also need to have the development
headers installed for this version, e.g. python2-devel.
**Traditional make**\ :
-The build uses the lib/python/Makefile.lammps file in the compile/link
+The build uses the ``lib/python/Makefile.lammps`` file in the compile/link
process to find Python. You should only need to create a new
-Makefile.lammps.\* file (and copy it to Makefile.lammps) if the LAMMPS
-build fails.
-
+``Makefile.lammps.\*`` file (and copy it to ``Makefile.lammps``\ ) if
+the LAMMPS build fails.
----------
-
.. _voronoi:
VORONOI package
@@ -613,22 +811,19 @@ To build with this package, you must download and build the `Voro++ library
- make lib-voronoi args="-p $HOME/voro++" # use existing Voro++ installation in $HOME/voro++
- make lib-voronoi args="-b -v voro++0.4.6" # download and build the 0.4.6 version in lib/voronoi/voro++-0.4.6
+ $ make lib-voronoi # print help message
+ $ make lib-voronoi args="-b" # download and build the default version in lib/voronoi/voro++-
+ $ make lib-voronoi args="-p $HOME/voro++" # use existing Voro++ installation in $HOME/voro++
+ $ make lib-voronoi args="-b -v voro++0.4.6" # download and build the 0.4.6 version in lib/voronoi/voro++-0.4.6
Note that 2 symbolic (soft) links, "includelink" and "liblink", are
created in lib/voronoi to point to the Voro++ src dir. When LAMMPS
builds in src it will use these links. You should not need to edit
the lib/voronoi/Makefile.lammps file.
-
----------
-
.. _user-adios:
USER-ADIOS package
@@ -665,13 +857,12 @@ The USER-ADIOS package requires the `ADIOS I/O library `_.
-
+The USER-PLUMED package has been tested to work with Plumed versions
+2.4.x, 2.5.x, and 2.6.x and will error out, when trying to run calculations
+with a different version of the Plumed kernel.
PLUMED can be linked into MD codes in three different modes: static,
shared, and runtime. With the "static" mode, all the code that PLUMED
@@ -893,7 +1073,7 @@ LAMMPS uses can be updated without the need for a recompile of LAMMPS
for as long as the shared PLUMED library is ABI-compatible.
The third linkage mode is "runtime" which allows the user to specify
-which PLUMED kernel should be used at runtime by using the PLUMED\_KERNEL
+which PLUMED kernel should be used at runtime by using the PLUMED_KERNEL
environment variable. This variable should point to the location of the
libplumedKernel.so dynamical shared object, which is then loaded at
runtime. This mode of linking is particularly convenient for doing
@@ -910,32 +1090,31 @@ LAMMPS build.
**CMake build**\ :
-When the "-D PKG\_USER-PLUMED" flag is included in the cmake command you
+When the "-D PKG_USER-PLUMED" flag is included in the cmake command you
must ensure that GSL is installed in locations that are specified in
your environment. There are then two additional commands that control
the manner in which PLUMED is obtained and linked into LAMMPS.
-
-.. parsed-literal::
+.. code-block:: bash
-D DOWNLOAD_PLUMED=value # download PLUMED for build, value = no (default) or yes
-D PLUMED_MODE=value # Linkage mode for PLUMED, value = static (default), shared, or runtime
-If DOWNLOAD\_PLUMED is set to "yes", the PLUMED library will be
+If DOWNLOAD_PLUMED is set to "yes", the PLUMED library will be
downloaded (the version of PLUMED that will be downloaded is hard-coded
to a vetted version of PLUMED, usually a recent stable release version)
-and built inside the CMake build directory. If DOWNLOAD\_PLUMED is set
+and built inside the CMake build directory. If DOWNLOAD_PLUMED is set
to "no" (the default), CMake will try to detect and link to an installed
version of PLUMED. For this to work, the PLUMED library has to be
installed into a location where the pkg-config tool can find it or the
-PKG\_CONFIG\_PATH environment variable has to be set up accordingly.
+PKG_CONFIG_PATH environment variable has to be set up accordingly.
PLUMED should be installed in such a location if you compile it using
the default make; make install commands.
-The PLUMED\_MODE setting determines the linkage mode for the PLUMED
+The PLUMED_MODE setting determines the linkage mode for the PLUMED
library. The allowed values for this flag are "static" (default),
"shared", or "runtime". For a discussion of PLUMED linkage modes,
-please see above. When DOWNLOAD\_PLUMED is enabled the static linkage
+please see above. When DOWNLOAD_PLUMED is enabled the static linkage
mode is recommended.
**Traditional make**\ :
@@ -951,13 +1130,12 @@ discussion of PLUMED linkage modes, please see above.
Download/compilation/configuration of the plumed library can be done
from the src folder through the following make args:
+.. code-block:: bash
-.. parsed-literal::
-
- make lib-plumed # print help message
- make lib-plumed args="-b" # download and build PLUMED in lib/plumed/plumed2
- make lib-plumed args="-p $HOME/.local" # use existing PLUMED installation in $HOME/.local
- make lib-plumed args="-p /usr/local -m shared" # use existing PLUMED installation in
+ $ make lib-plumed # print help message
+ $ make lib-plumed args="-b" # download and build PLUMED in lib/plumed/plumed2
+ $ make lib-plumed args="-p $HOME/.local" # use existing PLUMED installation in $HOME/.local
+ $ make lib-plumed args="-p /usr/local -m shared" # use existing PLUMED installation in
# /usr/local and use shared linkage mode
Note that 2 symbolic (soft) links, "includelink" and "liblink" are
@@ -967,16 +1145,15 @@ suitable for LAMMPS to compile and link PLUMED using the desired linkage
mode. After this step is completed, you can install the USER-PLUMED
package and compile LAMMPS in the usual manner:
+.. code-block:: bash
-.. parsed-literal::
-
- make yes-user-plumed
- make machine
+ $ make yes-user-plumed
+ $ make machine
Once this compilation completes you should be able to run LAMMPS in the
usual way. For shared linkage mode, libplumed.so must be found by the
LAMMPS executable, which on many operating systems means, you have to
-set the LD\_LIBRARY\_PATH environment variable accordingly.
+set the LD_LIBRARY_PATH environment variable accordingly.
Support for the different linkage modes in LAMMPS varies for different
operating systems, using the static linkage is expected to be the most
@@ -987,10 +1164,8 @@ lib-plumed" with the desired settings **and** do a re-install if the
USER-PLUMED package with "make yes-user-plumed" to update the required
makefile settings with the changes in the lib/plumed folder.
-
----------
-
.. _user-h5md:
USER-H5MD package
@@ -1002,7 +1177,7 @@ the HDF5 library.
**CMake build**\ :
-No additional settings are needed besides "-D PKG\_USER-H5MD=yes".
+No additional settings are needed besides "-D PKG_USER-H5MD=yes".
This should auto-detect the H5MD library on your system. Several
advanced CMake H5MD options exist if you need to specify where it is
@@ -1018,11 +1193,10 @@ lib/h5md/README. You can also do it in one step from the lammps/src
dir, using a command like these, which simply invoke the
lib/h5md/Install.py script with the specified args:
+.. code-block:: bash
-.. parsed-literal::
-
- make lib-h5md # print help message
- make lib-h5md args="-m h5cc" # build with h5cc compiler
+ $ make lib-h5md # print help message
+ $ make lib-h5md args="-m h5cc" # build with h5cc compiler
The build should produce two files: lib/h5md/libch5md.a and
lib/h5md/Makefile.lammps. The latter is copied from an existing
@@ -1032,10 +1206,8 @@ lib/h5md/Makefile.machine file for your system, which should define an
EXTRAMAKE variable to specify a corresponding Makefile.lammps.machine
file.
-
----------
-
.. _user-intel:
USER-INTEL package
@@ -1049,8 +1221,7 @@ on the :doc:`Speed intel ` doc page.
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D INTEL_ARCH=value # value = cpu (default) or knl
-D INTEL_LRT_MODE=value # value = threads, none, or c++11
@@ -1070,14 +1241,13 @@ runs with other compilers and without TBB and MKL.
**Traditional make**\ :
Choose which hardware to compile for in Makefile.machine via the
-following settings. See src/MAKE/OPTIONS/Makefile.intel\_cpu\* and
+following settings. See src/MAKE/OPTIONS/Makefile.intel_cpu\* and
Makefile.knl files for examples. and src/USER-INTEL/README for
additional information.
For CPUs:
-
-.. parsed-literal::
+.. code-block:: make
OPTFLAGS = -xHost -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high
CCFLAGS = -g -qopenmp -DLAMMPS_MEMALIGN=64 -no-offload -fno-alias -ansi-alias -restrict $(OPTFLAGS)
@@ -1086,18 +1256,15 @@ For CPUs:
For KNLs:
-
-.. parsed-literal::
+.. code-block:: make
OPTFLAGS = -xMIC-AVX512 -O2 -fp-model fast=2 -no-prec-div -qoverride-limits
CCFLAGS = -g -qopenmp -DLAMMPS_MEMALIGN=64 -no-offload -fno-alias -ansi-alias -restrict $(OPTFLAGS)
LINKFLAGS = -g -qopenmp $(OPTFLAGS)
LIB = -ltbbmalloc
-
----------
-
.. _user-molfile:
USER-MOLFILE package
@@ -1105,14 +1272,13 @@ USER-MOLFILE package
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D MOLFILE_INCLUDE_DIRS=path # (optional) path where VMD molfile plugin headers are installed
-D PKG_USER-MOLFILE=yes
-Using "-D PKG\_USER-MOLFILE=yes" enables the package, and setting
-"-D MOLFILE\_INCLUDE DIRS" allows to provide a custom location for
+Using "-D PKG_USER-MOLFILE=yes" enables the package, and setting
+"-D MOLFILE_INCLUDE DIRS" allows to provide a custom location for
the molfile plugin header files. These should match the ABI of the
plugin files used, and thus one typically sets them to include
folder of the local VMD installation in use. LAMMPS ships with a
@@ -1132,10 +1298,8 @@ default headers, but these are not compatible with all VMD versions,
so it is often best to change this setting to the location of the
same include files of the local VMD installation in use.
-
----------
-
.. _user-netcdf:
USER-NETCDF package
@@ -1146,7 +1310,7 @@ on your system.
**CMake build**\ :
-No additional settings are needed besides "-D PKG\_USER-NETCDF=yes".
+No additional settings are needed besides "-D PKG_USER-NETCDF=yes".
This should auto-detect the NETCDF library if it is installed on your
system at standard locations. Several advanced CMake NETCDF options
@@ -1161,10 +1325,8 @@ and library files which LAMMPS needs to build with this package. If
the settings are not valid for your system, you will need to edit the
Makefile.lammps file. See lib/netcdf/README for details.
-
----------
-
.. _user-omp:
USER-OMP package
@@ -1172,7 +1334,7 @@ USER-OMP package
**CMake build**\ :
-No additional settings are required besides "-D PKG\_USER-OMP=yes". If
+No additional settings are required besides "-D PKG_USER-OMP=yes". If
CMake detects OpenMP support, the USER-OMP code will be compiled with
multi-threading support enabled, otherwise as optimized serial code.
@@ -1183,46 +1345,57 @@ styles supporting OpenMP) the following compile and link flags must
be added to your Makefile.machine file.
See src/MAKE/OPTIONS/Makefile.omp for an example.
-
.. parsed-literal::
- CCFLAGS: -fopenmp # for GNU Compilers
+ CCFLAGS: -fopenmp # for GNU and Clang Compilers
CCFLAGS: -qopenmp -restrict # for Intel compilers on Linux
- LINKFLAGS: -fopenmp # for GNU Compilers
+ LINKFLAGS: -fopenmp # for GNU and Clang Compilers
LINKFLAGS: -qopenmp # for Intel compilers on Linux
For other platforms and compilers, please consult the documentation
about OpenMP support for your compiler. Please see the note about
how to address compatibility :ref:`issues with the 'default(none)' directive ` of some compilers.
-
----------
-
.. _user-qmmm:
USER-QMMM package
---------------------------------
-.. note::
-
- The LAMMPS executable these steps produce is not yet functional
- for a QM/MM simulation. You must also build Quantum ESPRESSO and
- create a new executable (pwqmmm.x) which links LAMMPS and Quantum
- ESPRESSO together. These are steps 3 and 4 described in the
- lib/qmmm/README file. Unfortunately, the Quantum ESPRESSO developers
- have been breaking the interface that the QM/MM code in LAMMPS is using,
- so that currently (Summer 2018) using this feature requires either
- correcting the library interface feature in recent Quantum ESPRESSO
- releases, or using an outdated version of QE. The last version of
- Quantum ESPRESSO known to work with this QM/MM interface was version
- 5.4.1 from 2016.
+For using LAMMPS to do QM/MM simulations via the USER-QMMM package you
+need to build LAMMPS as a library. A LAMMPS executable with fix qmmm
+included can be built, but will not be able to do a QM/MM simulation
+on as such. You must also build a QM code - currently only Quantum
+ESPRESSO (QE) is supported - and create a new executable which links
+LAMMPS and the QM code together. Details are given in the
+lib/qmmm/README file. It is also recommended to read the instructions
+for :doc:`linking with LAMMPS as a library ` for
+background information. This requires compatible Quantum Espresso
+and LAMMPS versions. The current interface and makefiles have last
+been verified to work in February 2020 with Quantum Espresso versions
+6.3 to 6.5.
**CMake build**\ :
-The CMake build system currently does not support building the full
-QM/MM-capable hybrid executable of LAMMPS and QE called pwqmmm.x.
-You must use the traditional make build for this package.
+When using CMake, building a LAMMPS library is required and it is
+recommended to build a shared library, since any libraries built from
+the sources in the *lib* folder (including the essential libqmmm.a)
+are not included in the static LAMMPS library and (currently) not
+installed, while their code is included in the shared LAMMPS library.
+Thus a typical command line to configure building LAMMPS for USER-QMMM
+would be:
+
+.. code-block:: bash
+
+ cmake -C ../cmake/presets/minimal.cmake -D PKG_USER-QMMM=yes \
+ -D BUILD_LIB=yes -DBUILD_SHARED_LIBS=yes ../cmake
+
+After completing the LAMMPS build and also configuring and compiling
+Quantum ESPRESSO with external library support (via "make couple"),
+go back to the lib/qmmm folder and follow the instructions on the
+README file to build the combined LAMMPS/QE QM/MM executable
+(pwqmmm.x) in the lib/qmmm folder. You need to make certain, that
**Traditional make**\ :
@@ -1232,13 +1405,12 @@ explained in lib/qmmm/README. You can also do it in one step from the
lammps/src dir, using a command like these, which simply invoke the
lib/qmmm/Install.py script with the specified args:
+.. code-block:: bash
-.. parsed-literal::
-
- make lib-qmmm # print help message
- make lib-qmmm args="-m serial" # build with GNU Fortran compiler (settings as in "make serial")
- make lib-qmmm args="-m mpi" # build with default MPI compiler (settings as in "make mpi")
- make lib-qmmm args="-m gfortran" # build with GNU Fortran compiler
+ $ make lib-qmmm # print help message
+ $ make lib-qmmm args="-m serial" # build with GNU Fortran compiler (settings as in "make serial")
+ $ make lib-qmmm args="-m mpi" # build with default MPI compiler (settings as in "make mpi")
+ $ make lib-qmmm args="-m gfortran" # build with GNU Fortran compiler
The build should produce two files: lib/qmmm/libqmmm.a and
lib/qmmm/Makefile.lammps. The latter is copied from an existing
@@ -1250,14 +1422,13 @@ a corresponding Makefile.lammps.machine file.
You can then install QMMM package and build LAMMPS in the usual
manner. After completing the LAMMPS build and compiling Quantum
-ESPRESSO with external library support, go back to the lib/qmmm folder
-and follow the instructions on the README file to build the combined
-LAMMPS/QE QM/MM executable (pwqmmm.x) in the lib/qmmm folder.
-
+ESPRESSO with external library support (via "make couple"), go back to
+the lib/qmmm folder and follow the instructions in the README file to
+build the combined LAMMPS/QE QM/MM executable (pwqmmm.x) in the
+lib/qmmm folder.
----------
-
.. _user-quip:
USER-QUIP package
@@ -1271,29 +1442,26 @@ lib/quip/README file for details on how to do this.
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D QUIP_LIBRARY=path # path to libquip.a (only needed if a custom location)
CMake will not download and build the QUIP library. But once you have
-done that, a CMake build of LAMMPS with "-D PKG\_USER-QUIP=yes" should
-work. Set QUIP\_LIBRARY if CMake cannot find the QUIP library.
+done that, a CMake build of LAMMPS with "-D PKG_USER-QUIP=yes" should
+work. Set QUIP_LIBRARY if CMake cannot find the QUIP library.
**Traditional make**\ :
The download/build procedure for the QUIP library, described in
lib/quip/README file requires setting two environment variables,
-QUIP\_ROOT and QUIP\_ARCH. These are accessed by the
+QUIP_ROOT and QUIP_ARCH. These are accessed by the
lib/quip/Makefile.lammps file which is used when you compile and link
LAMMPS with this package. You should only need to edit
Makefile.lammps if the LAMMPS build can not use its settings to
successfully build on your system.
-
----------
-
.. _user-scafacos:
USER-SCAFACOS package
@@ -1303,22 +1471,19 @@ To build with this package, you must download and build the `ScaFaCoS Coulomb so
.. _scafacos-home: http://www.scafacos.de
-
-
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D DOWNLOAD_SCAFACOS=value # download ScaFaCoS for build, value = no (default) or yes
-D SCAFACOS_LIBRARY=path # ScaFaCos library file (only needed if at custom location)
-D SCAFACOS_INCLUDE_DIR=path # ScaFaCoS include directory (only needed if at custom location)
-If DOWNLOAD\_SCAFACOS is set, the ScaFaCoS library will be downloaded
+If DOWNLOAD_SCAFACOS is set, the ScaFaCoS library will be downloaded
and built inside the CMake build directory. If the ScaFaCoS library
is already on your system (in a location CMake cannot find it),
-SCAFACOS\_LIBRARY is the filename (plus path) of the ScaFaCoS library
-file, not the directory the library file is in. SCAFACOS\_INCLUDE\_DIR
+SCAFACOS_LIBRARY is the filename (plus path) of the ScaFaCoS library
+file, not the directory the library file is in. SCAFACOS_INCLUDE_DIR
is the directory the ScaFaCoS include file is in.
**Traditional make**\ :
@@ -1338,10 +1503,8 @@ created in lib/scafacos to point to the ScaFaCoS src dir. When LAMMPS
builds in src it will use these links. You should not need to edit
the lib/scafacos/Makefile.lammps file.
-
----------
-
.. _user-smd:
USER-SMD package
@@ -1352,15 +1515,14 @@ Eigen3 is a template library, so you do not need to build it.
**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D DOWNLOAD_EIGEN3 # download Eigen3, value = no (default) or yes
-D EIGEN3_INCLUDE_DIR=path # path to Eigen library (only needed if a custom location)
-If DOWNLOAD\_EIGEN3 is set, the Eigen3 library will be downloaded and
+If DOWNLOAD_EIGEN3 is set, the Eigen3 library will be downloaded and
inside the CMake build directory. If the Eigen3 library is already on
-your system (in a location CMake cannot find it), EIGEN3\_INCLUDE\_DIR
+your system (in a location CMake cannot find it), EIGEN3_INCLUDE_DIR
is the directory the Eigen3++ include file is in.
**Traditional make**\ :
@@ -1370,22 +1532,19 @@ instructions in lib/smd/README. You can also do it in one step from
the lammps/src dir, using a command like these, which simply invoke
the lib/smd/Install.py script with the specified args:
+.. code-block:: bash
-.. parsed-literal::
-
- make lib-smd # print help message
- make lib-smd args="-b" # download to lib/smd/eigen3
- make lib-smd args="-p /usr/include/eigen3" # use existing Eigen installation in /usr/include/eigen3
+ $ make lib-smd # print help message
+ $ make lib-smd args="-b" # download to lib/smd/eigen3
+ $ make lib-smd args="-p /usr/include/eigen3" # use existing Eigen installation in /usr/include/eigen3
Note that a symbolic (soft) link named "includelink" is created in
lib/smd to point to the Eigen dir. When LAMMPS builds it will use
this link. You should not need to edit the lib/smd/Makefile.lammps
file.
-
----------
-
.. _user-vtk:
USER-VTK package
@@ -1396,7 +1555,7 @@ your system.
**CMake build**\ :
-No additional settings are needed besides "-D PKG\_USER-VTK=yes".
+No additional settings are needed besides "-D PKG_USER-VTK=yes".
This should auto-detect the VTK library if it is installed on your
system at standard locations. Several advanced VTK options exist if
@@ -1412,8 +1571,3 @@ the settings are not valid for your system, check if one of the other
lib/vtk/Makefile.lammps.\* files is compatible and copy it to
Makefile.lammps. If none of the provided files work, you will need to
edit the Makefile.lammps file. See lib/vtk/README for details.
-
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
diff --git a/doc/src/Build_link.rst b/doc/src/Build_link.rst
index 8306fcb86f5930d89179a16b467a0cfecc9b0c62..39fc4fe40a2f43bc075478d9ad94ba758f8d3492 100644
--- a/doc/src/Build_link.rst
+++ b/doc/src/Build_link.rst
@@ -1,91 +1,259 @@
Link LAMMPS as a library to another code
========================================
-LAMMPS can be used as a library by another application, including
-Python scripts. The files src/library.cpp and library.h define the
-C-style API for using LAMMPS as a library. See the :doc:`Howto library ` doc page for a description of the
-interface and how to extend it for your needs.
+LAMMPS is designed as a library of C++ objects and can thus be
+integrated into other applications including Python scripts.
+The files ``src/library.cpp`` and ``src/library.h`` define a
+C-style API for using LAMMPS as a library. See the :doc:`Howto
+library ` doc page for a description of the interface
+and how to extend it for your needs.
The :doc:`Build basics ` doc page explains how to build
-LAMMPS as either a shared or static library. This results in one of
-these 2 files:
+LAMMPS as either a shared or static library. This results in a file
+in the compilation folder called ``liblammps.a`` or ``liblammps_.a``
+in case of building a static library. In case of a shared library
+the name is the same only that the suffix is going to be either ``.so``
+or ``.dylib`` or ``.dll`` instead of ``.a`` depending on the OS.
+In some cases the ``.so`` file may be a symbolic link to a file with
+the suffix ``.so.0`` (or some other number).
+
+.. note::
+
+ Care should be taken to use the same MPI library for the calling code
+ and the LAMMPS library. The ``library.h`` file includes ``mpi.h``
+ and uses definitions from it so those need to be available and
+ consistent. When LAMMPS is compiled with the included STUBS MPI
+ library, then its ``mpi.h`` file needs to be included. While it is
+ technically possible to use a full MPI library in the calling code
+ and link to a serial LAMMPS library compiled with MPI STUBS, it is
+ recommended to use the *same* MPI library for both, and then use
+ ``MPI_Comm_split()`` in the calling code to pass a suitable
+ communicator with a subset of MPI ranks to the function creating the
+ LAMMPS instance.
-liblammps.so # shared library
-liblammps.a # static library
+----------
+**Link with LAMMPS as a static library**\ :
-----------
+The calling application can link to LAMMPS as a static library with
+compilation and link commands as in the examples shown below. These
+are examples for a code written in C in the file *caller.c*.
+The benefit of linking to a static library is, that the resulting
+executable is independent of that library since all required
+executable code from the library is copied into the calling executable.
+*CMake build*\ :
-**Link with LAMMPS as a static library**\ :
+This assumes that LAMMPS has been configured without setting a
+``LAMMPS_MACHINE`` name, installed with "make install", and the
+``PKG_CONFIG_PATH`` environment variable has been updated to include the
+``liblammps.pc`` file installed into the configured destination folder.
+The commands to compile and link a coupled executable are then:
-The calling application can link to LAMMPS as a static library with a
-link command like this:
+.. code-block:: bash
-g++ caller.o -L/home/sjplimp/lammps/src -llammps -o caller
+ mpicc -c -O $(pkgconf liblammps --cflags) caller.c
+ mpicxx -o caller caller.o -$(pkgconf liblammps --libs)
-The -L argument is the path to where the liblammps.a file is. The
--llammps argument is shorthand for the file liblammps.a.
+*Traditional make*\ :
+This assumes that LAMMPS has been compiled in the folder
+``${HOME}/lammps/src`` with "make mpi". The commands to compile and link
+a coupled executable are then:
-----------
+.. code-block:: bash
+
+ mpicc -c -O -I${HOME}/lammps/src caller.c
+ mpicxx -o caller caller.o -L${HOME}/lammps/src -llammps_mpi
+
+The *-I* argument is the path to the location of the ``library.h``
+header file containing the interface to the LAMMPS C-style library
+interface. The *-L* argument is the path to where the ``liblammps_mpi.a``
+file is located. The *-llammps_mpi* argument is shorthand for telling the
+compiler to link the file ``liblammps_mpi.a``. If LAMMPS has been
+built as a shared library, then the linker will use ``liblammps_mpi.so``
+instead. If both files are available, the linker will usually prefer
+the shared library. In case of a shared library, you may need to update
+the ``LD_LIBRARY_PATH`` environment variable or running the ``caller``
+executable will fail since it cannot find the shared library at runtime.
+
+However, it is only as simple as shown above for the case of a plain
+LAMMPS library without any optional packages that depend on libraries
+(bundled or external) or when using a shared library. Otherwise, you
+need to include all flags, libraries, and paths for the coupled
+executable, that are also required to link the LAMMPS executable.
+
+*CMake build*\ :
+
+When using CMake, additional libraries with sources in the lib folder
+are built, but not included in ``liblammps.a`` and (currently) not
+installed with "make install" and not included in the *pkgconfig*
+configuration file. They can be found in the top level build folder,
+but you have to determine the necessary link flags manually. It is
+therefore recommended to either use the traditional make procedure to
+build and link with a static library or build and link with a shared
+library instead.
+
+.. TODO: this needs to be updated to reflect that latest CMake changes after they are complete.
+
+*Traditional make*\ :
+
+After you have compiled a static LAMMPS library using the conventional
+build system for example with "make mode=static serial". And you also
+have installed the ``POEMS`` package after building its bundled library
+in ``lib/poems``. Then the commands to build and link the coupled executable
+change to:
+
+.. code-block:: bash
+
+ gcc -c -O -I${HOME}/lammps/src/STUBS -I${HOME}/lammps/src -caller.c
+ g++ -o caller caller.o -L${HOME}/lammps/lib/poems \
+ -L${HOME}/lammps/src/STUBS -L${HOME}/lammps/src -llammps_serial -lpoems -lmpi_stubs
+
+Note, that you need to link with "g++" instead of "gcc", since the
+LAMMPS library is C++ code. You can display the currently applied
+settings for building LAMMPS for the "serial" machine target by using
+the command:
+
+.. code-block:: bash
+
+ make mode=print serial
+
+Which should output something like:
+
+.. code-block:: bash
+
+ # Compiler:
+ CXX=g++
+ # Linker:
+ LD=g++
+ # Compilation:
+ CXXFLAGS=-g -O3 -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 -I${HOME}/compile/lammps/lib/poems -I${HOME}/compile/lammps/src/STUBS
+ # Linking:
+ LDFLAGS=-g -O
+ # Libraries:
+ LDLIBS=-L${HOME}/compile/lammps/src -llammps_serial -L${HOME}/compile/lammps/lib/poems -L${HOME}/compile/lammps/src/STUBS -lpoems -lmpi_stubs
+From this you can gather the necessary paths and flags. With
+makefiles for other *machine* configurations you need to do the
+equivalent and replace "serial" with the corresponding *machine* name
+of the makefile.
+
+----------
**Link with LAMMPS as a shared library**\ :
-If you wish to link to liblammps.so, the operating system finds shared
-libraries to load at run-time using the environment variable
-LD\_LIBRARY\_PATH. To enable this you can do one of two things:
+When linking to LAMMPS built as a shared library, the situation becomes
+much simpler, as all dependent libraries and objects are either included
+in the shared library or registered as a dependent library in the shared
+library file. Thus those libraries need not to be specified when
+linking the calling executable. Only the *-I* flags are needed. So the
+example case from above of the serial version static LAMMPS library with
+the POEMS package installed becomes:
+
+*CMake build*\ :
+
+The commands with a shared LAMMPS library compiled with the CMake
+build process are the same as for the static library.
+
+.. code-block:: bash
+
+ mpicc -c -O $(pkgconf liblammps --cflags) caller.c
+ mpicxx -o caller caller.o -$(pkgconf --libs)
+
+*Traditional make*\ :
+
+The commands with a shared LAMMPS library compiled with the
+traditional make build using "make mode=shared serial" becomes:
+
+.. code-block:: bash
+
+ gcc -c -O -I${HOME}/lammps/src/STUBS -I${HOME}/lammps/src -caller.c
+ g++ -o caller caller.o -L${HOME}/lammps/src -llammps_serial
-(1) Copy the liblammps.so file to a location the system can find it,
-such as /usr/local/lib. I.e. a directory already listed in your
-LD\_LIBRARY\_PATH variable. You can type
+*Locating liblammps.so at runtime*\ :
+However, now the ``liblammps.so`` file is required at runtime and needs
+to be in a folder, where the shared linker program of the operating
+system can find it. This would be either a folder like ``/usr/local/lib64``
+or ``${HOME}/.local/lib64`` or a folder pointed to by the ``LD_LIBRARY_PATH``
+environment variable. You can type
-.. parsed-literal::
+.. code-block:: bash
printenv LD_LIBRARY_PATH
to see what directories are in that list.
-(2) Add the LAMMPS src directory (or the directory you perform CMake
-build in) to your LD\_LIBRARY\_PATH, so that the current version of the
-shared library is always available to programs that use it.
+Or you can add the LAMMPS src directory (or the directory you performed
+a CMake style build in) to your ``LD_LIBRARY_PATH``, so that the current
+version of the shared library is always available to programs that use it.
-For the csh or tcsh shells, you would add something like this to your
-~/.cshrc file:
+For the Bourne or Korn shells (/bin/sh, /bin/ksh, /bin/bash etc.), you
+would add something like this to your ``${HOME}/.profile`` file:
+.. code-block:: bash
-.. parsed-literal::
+ LD_LIBRARY_PATH ${LD_LIBRARY_PATH-/usr/lib64}:${HOME}/lammps/src
+ export LD_LIBRARY_PATH
- setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/sjplimp/lammps/src
+For the csh or tcsh shells, you would equivalently add something like this
+to your ``${HOME}/.cshrc`` file:
+.. code-block:: csh
-----------
+ setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${HOME}/lammps/src
+
+You can verify whether all required shared libraries are found with the
+``ldd`` tool. Example:
+
+.. code-block:: bash
+
+ $ LD_LIBRARY_PATH=/home/user/lammps/src ldd caller
+ linux-vdso.so.1 (0x00007ffe729e0000)
+ liblammps.so => /home/user/lammps/src/liblammps.so (0x00007fc91bb9e000)
+ libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fc91b984000)
+ libm.so.6 => /lib64/libm.so.6 (0x00007fc91b83e000)
+ libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc91b824000)
+ libc.so.6 => /lib64/libc.so.6 (0x00007fc91b65b000)
+ /lib64/ld-linux-x86-64.so.2 (0x00007fc91c094000)
+
+If a required library is missing, you would get a 'not found' entry:
+.. code-block:: bash
+
+ $ ldd caller
+ linux-vdso.so.1 (0x00007ffd672fe000)
+ liblammps.so => not found
+ libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fb7c7e86000)
+ libm.so.6 => /usr/lib64/libm.so.6 (0x00007fb7c7d40000)
+ libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007fb7c7d26000)
+ libc.so.6 => /usr/lib64/libc.so.6 (0x00007fb7c7b5d000)
+ /lib64/ld-linux-x86-64.so.2 (0x00007fb7c80a2000)
+
+----------
**Calling the LAMMPS library**\ :
Either flavor of library (static or shared) allows one or more LAMMPS
-objects to be instantiated from the calling program.
+objects to be instantiated from the calling program. When used from a
+C++ program, most of the symbols and functions in LAMMPS are wrapped
+in a ``LAMMPS_NS`` namespace; you can safely use any of its classes and
+methods from within the calling code, as needed, and you will not incur
+conflicts with functions and variables in your code that share the name.
+This, however, does not extend to all additional libraries bundled with
+LAMMPS in the lib folder and some of the low-level code of some packages.
-When used from a C++ program, all of LAMMPS is wrapped in a LAMMPS\_NS
-namespace; you can safely use any of its classes and methods from
-within the calling code, as needed.
-
-When used from a C or Fortran program, the library has a simple
-C-style interface, provided in src/library.cpp and src/library.h.
+To be compatible with C, Fortran, Python programs, the library has a simple
+C-style interface, provided in ``src/library.cpp`` and ``src/library.h``.
See the :doc:`Python library ` doc page for a
description of the Python interface to LAMMPS, which wraps the C-style
-interface.
+interface from a shared library through the `ctypes python module `_.
-See the sample codes in examples/COUPLE/simple for examples of C++ and
+See the sample codes in ``examples/COUPLE/simple`` for examples of C++ and
C and Fortran codes that invoke LAMMPS through its library interface.
Other examples in the COUPLE directory use coupling ideas discussed on
the :doc:`Howto couple ` doc page.
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
+.. _ctypes: https://docs.python.org/3/library/ctypes.html
diff --git a/doc/src/Build_make.rst b/doc/src/Build_make.rst
index 8f1966f1014bc120cc9858c88fb23afe1ba92613..af5e319121768b41b0016f9be88f83a31965dfb8 100644
--- a/doc/src/Build_make.rst
+++ b/doc/src/Build_make.rst
@@ -2,71 +2,109 @@ Build LAMMPS with make
======================
Building LAMMPS with traditional makefiles requires that you have a
-Makefile."machine" file appropriate for your system in the src/MAKE,
-src/MAKE/MACHINES, src/MAKE/OPTIONS, or src/MAKE/MINE directory (see
-below). It can include various options for customizing your LAMMPS
-build with a number of global compilation options and features.
-
-To include LAMMPS packages (i.e. optional commands and styles) you
-must install them first, as discussed on the :doc:`Build package ` doc page. If the packages require
-provided or external libraries, you must build those libraries before
-building LAMMPS. Building :doc:`LAMMPS with CMake ` can
-automate all of this for many types of machines, especially
-workstations, desktops and laptops, so we suggest you try it first.
-
-These commands perform a default LAMMPS build, producing the LAMMPS
-executable lmp\_serial or lmp\_mpi in lammps/src:
-
-
-.. parsed-literal::
-
- cd lammps/src
- make serial # build a serial LAMMPS executable
+``Makefile.`` file appropriate for your system in either the
+``src/MAKE``, ``src/MAKE/MACHINES``, ``src/MAKE/OPTIONS``, or
+``src/MAKE/MINE`` directory (see below). It can include various options
+for customizing your LAMMPS build with a number of global compilation
+options and features.
+
+Requirements
+^^^^^^^^^^^^
+
+Those makefiles are written for and tested with GNU make and may not
+be compatible with other make programs. In most cases, if the "make"
+program is not GNU make, then there will be a GNU make program
+available under the name "gmake". If GNU make or a compatible make is
+not available, you may have to first install it or switch to building
+with :doc:`CMake `. The makefiles of the traditional
+make based build process and the scripts they are calling expect a few
+additional tools to be available and functioning.
+
+ * a working C/C++ compiler toolchain supporting the C++11 standard; on
+ Linux these are often the GNU compilers. Some older compilers
+ require adding flags like ``-std=c++11`` to enable the C++11 mode.
+ * a Bourne shell compatible "Unix" shell program (often this is ``bash``)
+ * a few shell utilities: ``ls``, ``mv``, ``ln``, ``rm``, ``grep``, ``sed``, ``tr``, ``cat``, ``touch``, ``diff``, ``dirname``
+ * python (optional, required for ``make lib-`` in the src folder).
+ python scripts are currently tested with python 2.7 and 3.6. The procedure
+ for :doc:`building the documentation ` requires python 3.
+
+Getting started
+^^^^^^^^^^^^^^^
+
+To include LAMMPS packages (i.e. optional commands and styles) you must
+enable (or "install") them first, as discussed on the :doc:`Build
+package ` doc page. If a packages requires (provided or
+external) libraries, you must configure and build those libraries
+**before** building LAMMPS itself and especially **before** enabling
+such a package with ``make yes-``. Building :doc:`LAMMPS with
+CMake ` can automate much of this for many types of
+machines, especially workstations, desktops, and laptops, so we suggest
+you try it first when building LAMMPS in those cases.
+
+The commands below perform a default LAMMPS build, producing the LAMMPS
+executable ``lmp_serial`` and ``lmp_mpi`` in ``lammps/src``:
+
+.. code-block:: bash
+
+ cd lammps/src # change to main LAMMPS source folder
+ make serial # build a serial LAMMPS executable using GNU g++
make mpi # build a parallel LAMMPS executable with MPI
make # see a variety of make options
-This initial compilation can take a long time, since LAMMPS is a large
-project with many features. If your machine has multiple CPU cores
-(most do these days), using a command like "make -jN mpi" (with N =
-the number of available CPU cores) can be much faster. If you plan to
-do development on LAMMPS or need to re-compile LAMMPS repeatedly, the
-installation of the ccache (= Compiler Cache) software may speed up
-compilation even more.
+Compilation can take a long time, since LAMMPS is a large project with
+many features. If your machine has multiple CPU cores (most do these
+days), you can speed this up by compiling sources in parallel with
+``make -j N`` (with N being the maximum number of concurrently executed
+tasks). Also installation of the `ccache `_ (=
+Compiler Cache) software may speed up repeated compilation even more,
+e.g. during code development.
After the initial build, whenever you edit LAMMPS source files, or add
or remove new files to the source directory (e.g. by installing or
uninstalling packages), you must re-compile and relink the LAMMPS
-executable with the same "make" command. This makefiles dependencies
-should insure that only the subset of files that need to be are
-re-compiled.
+executable with the same ``make `` command. The makefile's
+dependency tracking should insure that only the necessary subset of
+files are re-compiled. If you change settings in the makefile, you have
+to recompile *everything*. To delete all objects you can use ``make
+clean-``.
.. note::
- When you build LAMMPS for the first time, a long list of \*.d
- files will be printed out rapidly. This is not an error; it is the
- Makefile doing its normal creation of dependencies.
-
+ Before the actual compilation starts, LAMMPS will perform several
+ steps to collect information from the configuration and setup that
+ is then embedded into the executable. When you build LAMMPS for
+ the first time, it will also compile a tool to quickly assemble
+ a list of dependencies, that are required for the make program to
+ correctly detect which parts need to be recompiled after changes
+ were made to the sources.
-----------
+Customized builds and alternate makefiles
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The ``src/MAKE`` directory tree contains the ``Makefile.``
+files included in the LAMMPS distribution. Typing ``make example`` uses
+``Makefile.example`` from one of those folders, if available. Thus the
+``make serial`` and ``make mpi`` lines above use
+``src/MAKE/Makefile.serial`` and ``src/MAKE/Makefile.mpi``,
+respectively. Other makefiles are in these directories:
-The lammps/src/MAKE tree contains all the Makefile.machine files
-included in the LAMMPS distribution. Typing "make machine" uses
-Makefile.machine. Thus the "make serial" or "make mpi" lines above
-use Makefile.serial and Makefile.mpi. Others are in these dirs:
-
-
-.. parsed-literal::
+.. code-block:: bash
OPTIONS # Makefiles which enable specific options
MACHINES # Makefiles for specific machines
MINE # customized Makefiles you create (you may need to create this folder)
-Typing "make" lists all the available Makefile.machine files. A file
-with the same name can appear in multiple folders (not a good idea).
-The order the dirs are searched is as follows: src/MAKE/MINE,
-src/MAKE, src/MAKE/OPTIONS, src/MAKE/MACHINES. This gives preference
-to a customized file you put in src/MAKE/MINE.
+Simply typing ``make`` lists all the available ``Makefile.``
+files with a single line description toward the end of the output. A
+file with the same name can appear in multiple folders (not a good
+idea). The order the directories are searched is as follows:
+``src/MAKE/MINE``, ``src/MAKE``, ``src/MAKE/OPTIONS``,
+``src/MAKE/MACHINES``. This gives preference to a customized file you
+put in ``src/MAKE/MINE``. If you create your own custom makefile under
+a new name, please edit the first line with the description and machine
+name, so you will not confuse yourself, when looking at the machine
+summary.
Makefiles you may wish to try include these (some require a package
first be installed). Many of these include specific compiler flags
@@ -75,8 +113,7 @@ customized machine Makefile are contributed by users. Since both
compilers, OS configurations, and LAMMPS itself keep changing, their
settings may become outdated:
-
-.. parsed-literal::
+.. code-block:: bash
make mac # build serial LAMMPS on a Mac
make mac_mpi # build parallel LAMMPS on a Mac
@@ -87,8 +124,3 @@ settings may become outdated:
make kokkos_omp # build with the KOKKOS package for OpenMP
make kokkos_cuda_mpi # build with the KOKKOS package for GPUs
make kokkos_phi # build with the KOKKOS package for KNLs
-
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
diff --git a/doc/src/Build_package.rst b/doc/src/Build_package.rst
index 9f56f3f329d7c13d78874ddafdb0b7e7e9402ffc..f2511bb6a4a229a2bd8ef16b69e4c1ef0b4fee46 100644
--- a/doc/src/Build_package.rst
+++ b/doc/src/Build_package.rst
@@ -14,10 +14,13 @@ package. In general there is no need to include a package if you
never plan to use its features.
If you get a run-time error that a LAMMPS command or style is
-"Unknown", it is often because the command is contained in a package,
-and your build did not include that package. Running LAMMPS with the
-:doc:`-h command-line switch ` will print all the included
-packages and commands for that executable.
+"unknown", it is often because the command is contained in a package,
+and your build did not include that package. If the command or style
+*is* available in a package included in the LAMMPS distribution,
+the error message will indicate which package would be needed.
+Running LAMMPS with the :doc:`-h command-line switch `
+will print *all* optional commands and packages that were enabled
+when building that executable.
For the majority of packages, if you follow the single step below to
include it, you can then build LAMMPS exactly the same as you would
@@ -42,17 +45,15 @@ packages:
The mechanism for including packages is simple but different for CMake
versus make.
-**CMake variables**\ :
+**CMake build**\ :
-
-.. parsed-literal::
+.. code-block:: csh
-D PKG_NAME=value # yes or no (default)
Examples:
-
-.. parsed-literal::
+.. code-block:: csh
-D PKG_MANYBODY=yes
-D PKG_USER-INTEL=yes
@@ -73,8 +74,7 @@ once with CMake.
**Traditional make**\ :
-
-.. parsed-literal::
+.. code-block:: bash
cd lammps/src
make ps # check which packages are currently installed
@@ -84,8 +84,7 @@ once with CMake.
Examples:
-
-.. parsed-literal::
+.. code-block:: bash
make no-rigid
make yes-user-intel
@@ -119,7 +118,7 @@ are already included. Likewise, if a package is excluded, other files
dependent on that package are also excluded.
When you download a LAMMPS tarball or download LAMMPS source files
-from the Git or SVN repositories, no packages are pre-installed in the
+from the git repository, no packages are pre-installed in the
src directory.
.. note::
@@ -129,16 +128,17 @@ src directory.
That is no longer the case, so that CMake will build as-is without the
need to un-install those packages.
-
----------
+.. _cmake_presets:
**CMake shortcuts for installing many packages**\ :
Instead of specifying all the CMake options via the command-line,
-CMake allows initializing the variable cache using script files. These
-are regular CMake files which can manipulate and set variables, and
-can also contain control flow constructs.
+CMake allows initializing its settings cache using script files.
+These are regular CMake files which can manipulate and set CMake
+variables (which represent selected options), and can also contain
+control flow constructs for more complex operations.
LAMMPS includes several of these files to define configuration
"presets", similar to the options that exist for the Make based
@@ -146,33 +146,27 @@ system. Using these files you can enable/disable portions of the
available packages in LAMMPS. If you need a custom preset you can take
one of them as a starting point and customize it to your needs.
-+-------------------------------------------------------------+-----------------------------------------------------------+
-| cmake -C ../cmake/presets/all\_on.cmake [OPTIONS] ../cmake | enable all packages |
-+-------------------------------------------------------------+-----------------------------------------------------------+
-| cmake -C ../cmake/presets/all\_off.cmake [OPTIONS] ../cmake | disable all packages |
-+-------------------------------------------------------------+-----------------------------------------------------------+
-| cmake -C ../cmake/presets/minimal.cmake [OPTIONS] ../cmake | enable just a few core packages |
-+-------------------------------------------------------------+-----------------------------------------------------------+
-| cmake -C ../cmake/presets/most.cmake [OPTIONS] ../cmake | enable most common packages |
-+-------------------------------------------------------------+-----------------------------------------------------------+
-| cmake -C ../cmake/presets/nolib.cmake [OPTIONS] ../cmake | disable packages that do require extra libraries or tools |
-+-------------------------------------------------------------+-----------------------------------------------------------+
-| cmake -C ../cmake/presets/clang.cmake [OPTIONS] ../cmake | change settings to use the Clang compilers by default |
-+-------------------------------------------------------------+-----------------------------------------------------------+
-| cmake -C ../cmake/presets/mingw.cmake [OPTIONS] ../cmake | enable all packages compatible with MinGW compilers |
-+-------------------------------------------------------------+-----------------------------------------------------------+
+.. code-block:: bash
+
+ cmake -C ../cmake/presets/minimal.cmake [OPTIONS] ../cmake # enable just a few core packages
+ cmake -C ../cmake/presets/most.cmake [OPTIONS] ../cmake # enable most packages
+ cmake -C ../cmake/presets/nolib.cmake [OPTIONS] ../cmake # disable packages that do require extra libraries or tools
+ cmake -C ../cmake/presets/clang.cmake [OPTIONS] ../cmake # change settings to use the Clang compilers by default
+ cmake -C ../cmake/presets/intel.cmake [OPTIONS] ../cmake # change settings to use the Intel compilers by default
+ cmake -C ../cmake/presets/all_on.cmake [OPTIONS] ../cmake # enable all packages
+ cmake -C ../cmake/presets/all_off.cmake [OPTIONS] ../cmake # disable all packages
+ mingw64-cmake -C ../cmake/presets/mingw-cross.cmake [OPTIONS] ../cmake # compile with MinGW cross compilers
.. note::
- Running cmake this way manipulates the variable cache in your
+ Running cmake this way manipulates the CMake settings cache in your
current build directory. You can combine multiple presets and options
in a single cmake run, or change settings incrementally by running
cmake with new flags.
**Example:**
-
-.. parsed-literal::
+.. code-block:: bash
# build LAMMPS with most commonly used packages, but then remove
# those requiring additional library or tools, but still enable
@@ -188,49 +182,40 @@ one of them as a starting point and customize it to your needs.
# but leaving all other settings untouched. You can run:
cmake -C ../cmake/presets/no_all.cmake .
-
----------
-
**Make shortcuts for installing many packages**\ :
The following commands are useful for managing package source files
and their installation when building LAMMPS via traditional make.
-Just type "make" in lammps/src to see a one-line summary.
+Just type ``make`` in lammps/src to see a one-line summary.
These commands install/un-install sets of packages:
-+-----------------------------------+-----------------------------------------------------+
-| make yes-all | install all packages |
-+-----------------------------------+-----------------------------------------------------+
-| make no-all | un-install all packages |
-+-----------------------------------+-----------------------------------------------------+
-| make yes-standard or make yes-std | install standard packages |
-+-----------------------------------+-----------------------------------------------------+
-| make no-standard or make no-std | un-install standard packages |
-+-----------------------------------+-----------------------------------------------------+
-| make yes-user | install user packages |
-+-----------------------------------+-----------------------------------------------------+
-| make no-user | un-install user packages |
-+-----------------------------------+-----------------------------------------------------+
-| make yes-lib | install packages that require extra libraries |
-+-----------------------------------+-----------------------------------------------------+
-| make no-lib | un-install packages that require extra libraries |
-+-----------------------------------+-----------------------------------------------------+
-| make yes-ext | install packages that require external libraries |
-+-----------------------------------+-----------------------------------------------------+
-| make no-ext | un-install packages that require external libraries |
-+-----------------------------------+-----------------------------------------------------+
-
-which install/un-install various sets of packages. Typing "make
-package" will list all the these commands.
+.. code-block:: bash
+
+ make yes-all # install all packages
+ make no-all # uninstall all packages
+ make yes-standard or make yes-std # install standard packages
+ make no-standard or make no-std # uninstall standard packages
+ make yes-user # install user packages
+ make no-user # uninstall user packages
+ make yes-lib # install packages that require extra libraries
+ make no-lib # uninstall packages that require extra libraries
+ make yes-ext # install packages that require external libraries
+ make no-ext # uninstall packages that require external libraries
+
+which install/un-install various sets of packages. Typing ``make
+package`` will list all the these commands.
.. note::
- Installing or un-installing a package works by simply copying
- files back and forth between the main src directory and
- sub-directories with the package name (e.g. src/KSPACE, src/USER-ATC),
- so that the files are included or excluded when LAMMPS is built.
+ Installing or un-installing a package for the make based build process
+ works by simply copying files back and forth between the main source
+ directory src and the sub-directories with the package name (e.g.
+ src/KSPACE, src/USER-ATC), so that the files are included or excluded
+ when LAMMPS is built. Only source files in the src folder will be
+ compiled.
The following make commands help manage files that exist in both the
src directory and in package sub-directories. You do not normally
@@ -238,28 +223,23 @@ need to use these commands unless you are editing LAMMPS files or are
:doc:`installing a patch ` downloaded from the LAMMPS web
site.
-Type "make package-status" or "make ps" to show which packages are
+Type ``make package-status`` or ``make ps`` to show which packages are
currently installed. For those that are installed, it will list any
files that are different in the src directory and package
sub-directory.
-Type "make package-installed" or "make pi" to show which packages are
+Type ``make package-installed`` or ``make pi`` to show which packages are
currently installed, without listing the status of packages that are
not installed.
-Type "make package-update" or "make pu" to overwrite src files with
+Type ``make package-update`` or ``make pu`` to overwrite src files with
files from the package sub-directories if the package is installed.
It should be used after a :doc:`patch has been applied `,
since patches only update the files in the package sub-directory, but
not the src files.
-Type "make package-overwrite" to overwrite files in the package
+Type ``make package-overwrite`` to overwrite files in the package
sub-directories with src files.
-Type "make package-diff" to list all differences between pairs of
-files in both the src dir and a package dir.
-
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
+Type ``make package-diff`` to list all differences between pairs of
+files in both the source directory and the package directory.
diff --git a/doc/src/Build_settings.rst b/doc/src/Build_settings.rst
index 07d427db49860a522797a46d7b875177287b8948..01792507e7d5128bee2d3cfc690d72b647559215 100644
--- a/doc/src/Build_settings.rst
+++ b/doc/src/Build_settings.rst
@@ -4,77 +4,49 @@ Optional build settings
LAMMPS can be built with several optional settings. Each sub-section
explain how to do this for building both with CMake and make.
-| :ref:`C++11 standard compliance test ` when building all of LAMMPS
-| :ref:`FFT library ` for use with the :doc:`kspace\_style pppm ` command
-| :ref:`Size of LAMMPS data types `
-| :ref:`Read or write compressed files `
-| :ref:`Output of JPG and PNG files ` via the :doc:`dump image ` command
-| :ref:`Output of movie files ` via the :doc:`dump\_movie ` command
-| :ref:`Memory allocation alignment `
-| :ref:`Workaround for long long integers `
-| :ref:`Error handling exceptions ` when using LAMMPS as a library
-|
-
+* :ref:`C++11 standard compliance ` when building all of LAMMPS
+* :ref:`FFT library ` for use with the :doc:`kspace_style pppm ` command
+* :ref:`Size of LAMMPS data types `
+* :ref:`Read or write compressed files `
+* :ref:`Output of JPG and PNG files ` via the :doc:`dump image ` command
+* :ref:`Output of movie files ` via the :doc:`dump_movie ` command
+* :ref:`Memory allocation alignment `
+* :ref:`Workaround for long long integers `
+* :ref:`Error handling exceptions ` when using LAMMPS as a library
----------
-
.. _cxx11:
-C++11 standard compliance test
+C++11 standard compliance
------------------------------------------
-The LAMMPS developers plan to transition to make the C++11 standard the
-minimum requirement for compiling LAMMPS. Currently this only applies to
-some packages like KOKKOS while the rest aims to be compatible with the C++98
-standard. Most currently used compilers are compatible with C++11; some need
-to set extra flags to switch. To determine the impact of requiring C++11,
-we have added a simple compliance test to the source code, that will cause
-the compilation to abort, if C++11 compliance is not available or enabled.
-To bypass this check, you need to change a setting in the makefile or
-when calling CMake.
-
-**CMake variable**\ :
-
-
-.. parsed-literal::
-
- -D DISABLE_CXX11_REQUIREMENT=yes
-
-You can set additional C++ compiler flags (beyond those selected by CMake)
-through the CMAKE\_CXX\_FLAGS variable. Example for CentOS 7:
-
-
-.. parsed-literal::
-
- -D CMAKE_CXX_FLAGS="-O3 -g -fopenmp -DNDEBUG -std=c++11"
-
-**Makefile.machine setting**\ :
+A C++11 standard compatible compiler is a requirement for compiling LAMMPS.
+LAMMPS version 3 March 2020 is the last version compatible with the previous
+C++98 standard for the core code and most packages. Most currently used
+C++ compilers are compatible with C++11, but some older ones may need extra
+flags to enable C++11 compliance. Example for GNU c++ 4.8.x:
+.. code-block:: make
-.. parsed-literal::
-
- LMP_INC = -DLAMMPS_CXX98
-
+ CCFLAGS = -g -O3 -std=c++11
----------
-
.. _fft:
FFT library
---------------------
When the KSPACE package is included in a LAMMPS build, the
-:doc:`kspace\_style pppm ` command performs 3d FFTs which
+:doc:`kspace_style pppm ` command performs 3d FFTs which
require use of an FFT library to compute 1d FFTs. The KISS FFT
library is included with LAMMPS but other libraries can be faster.
LAMMPS can use them if they are available on your system.
**CMake variables**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D FFT=value # FFTW3 or MKL or KISS, default is FFTW3 if found, else KISS
-D FFT_SINGLE=value # yes or no (default), no = double precision
@@ -86,70 +58,83 @@ LAMMPS can use them if they are available on your system.
an exception to the rule that all CMake variables can be specified
with lower-case values.
-Usually these settings are all that is needed. If CMake cannot find
-the FFT library, you can set these variables:
-
+Usually these settings are all that is needed. If FFTW3 is selected,
+then CMake will try to detect, if threaded FFTW libraries are available
+and enable them by default. This setting is independent of whether
+OpenMP threads are enabled and a packages like KOKKOS or USER-OMP is
+used. If CMake cannot detect the FFT library, you can set these variables
+to assist:
-.. parsed-literal::
+.. code-block:: bash
-D FFTW3_INCLUDE_DIRS=path # path to FFTW3 include files
-D FFTW3_LIBRARIES=path # path to FFTW3 libraries
+ -D FFT_FFTW_THREADS=on # enable using threaded FFTW3 libraries
-D MKL_INCLUDE_DIRS=path # ditto for Intel MKL library
+ -D FFT_MKL_THREADS=on # enable using threaded FFTs with MKL libraries
-D MKL_LIBRARIES=path
**Makefile.machine settings**\ :
-
-.. parsed-literal::
+.. code-block:: make
FFT_INC = -DFFT_FFTW3 # -DFFT_FFTW3, -DFFT_FFTW (same as -DFFT_FFTW3), -DFFT_MKL, or -DFFT_KISS
# default is KISS if not specified
FFT_INC = -DFFT_SINGLE # do not specify for double precision
+ FFT_INC = -DFFT_FFTW_THREADS # enable using threaded FFTW3 libraries
+ FFT_INC = -DFFT_MKL_THREADS # enable using threaded FFTs with MKL libraries
FFT_INC = -DFFT_PACK_ARRAY # or -DFFT_PACK_POINTER or -DFFT_PACK_MEMCPY
-# default is FFT\_PACK\_ARRAY if not specified
-
+# default is FFT_PACK_ARRAY if not specified
-.. parsed-literal::
+.. code-block:: make
FFT_INC = -I/usr/local/include
FFT_PATH = -L/usr/local/lib
FFT_LIB = -lfftw3 # FFTW3 double precision
+ FFT_LIB = -lfftw3 -lfftw3_omp # FFTW3 double precision with threads (needs -DFFT_FFTW_THREADS)
FFT_LIB = -lfftw3 -lfftw3f # FFTW3 single precision
- FFT_LIB = -lmkl_intel_lp64 -lmkl_sequential -lmkl_core # MKL with Intel compiler
- FFT_LIB = -lmkl_gf_lp64 -lmkl_sequential -lmkl_core # MKL with GNU compier
+ FFT_LIB = -lmkl_intel_lp64 -lmkl_sequential -lmkl_core # MKL with Intel compiler, serial interface
+ FFT_LIB = -lmkl_gf_lp64 -lmkl_sequential -lmkl_core # MKL with GNU compiler, serial interface
+ FFT_LIB = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core # MKL with Intel compiler, threaded interface
+ FFT_LIB = -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core # MKL with GNU compiler, threaded interface
+ FFT_LIB = -lmkl_rt # MKL with automatic runtime selection of interface libs
-As with CMake, you do not need to set paths in FFT\_INC or FFT\_PATH, if
-make can find the FFT header and library files. You must specify
-FFT\_LIB with the appropriate FFT libraries to include in the link.
+As with CMake, you do not need to set paths in ``FFT_INC`` or ``FFT_PATH``, if
+the compiler can find the FFT header and library files in its default search path.
+You must specify ``FFT_LIB`` with the appropriate FFT libraries to include in the link.
**CMake and make info**\ :
The `KISS FFT library `_ is included in the LAMMPS
-distribution. It is portable across all platforms. Depending on the
-size of the FFTs and the number of processors used, the other
-libraries listed here can be faster.
+distribution. It is portable across all platforms. Depending on the size
+of the FFTs and the number of processors used, the other libraries listed
+here can be faster.
However, note that long-range Coulombics are only a portion of the
per-timestep CPU cost, FFTs are only a portion of long-range
Coulombics, and 1d FFTs are only a portion of the FFT cost (parallel
communication can be costly). A breakdown of these timings is printed
-to the screen at the end of a run using the :doc:`kspace\_style pppm ` command. The :doc:`Run output `
-doc page gives more details.
+to the screen at the end of a run when using the
+:doc:`kspace_style pppm ` command. The :doc:`Run output `
+doc page gives more details. A more detailed (and time consuming)
+report of the FFT performance is generated with the
+:doc:`kspace_modify fftbench yes ` command.
FFTW is a fast, portable FFT library that should also work on any
platform and can be faster than the KISS FFT library. You can
download it from `www.fftw.org `_. LAMMPS requires
version 3.X; the legacy version 2.1.X is no longer supported.
-Building FFTW for your box should be as simple as ./configure; make;
-make install. The install command typically requires root privileges
+Building FFTW for your box should be as simple as ``./configure; make;
+make install``\ . The install command typically requires root privileges
(e.g. invoke it via sudo), unless you specify a local directory with
-the "--prefix" option of configure. Type "./configure --help" to see
+the "--prefix" option of configure. Type ``./configure --help`` to see
various options.
The Intel MKL math library is part of the Intel compiler suite. It
-can be used with the Intel or GNU compiler (see FFT\_LIB setting above).
+can be used with the Intel or GNU compiler (see the ``FFT_LIB`` setting
+above).
Performing 3d FFTs in parallel can be time consuming due to data
access and required communication. This cost can be reduced by
@@ -158,33 +143,30 @@ precision means the real and imaginary parts of a complex datum are
4-byte floats. Double precision means they are 8-byte doubles. Note
that Fourier transform and related PPPM operations are somewhat less
sensitive to floating point truncation errors and thus the resulting
-error is less than the difference in precision. Using the -DFFT\_SINGLE
+error is less than the difference in precision. Using the ``-DFFT_SINGLE``
setting trades off a little accuracy for reduced memory use and
parallel communication costs for transposing 3d FFT data.
-When using -DFFT\_SINGLE with FFTW3 you may need to build the FFTW
+When using ``-DFFT_SINGLE`` with FFTW3 you may need to build the FFTW
library a second time with support for single-precision.
For FFTW3, do the following, which should produce the additional
-library libfftw3f.a
-
+library ``libfftw3f.a`` or ``libfftw3f.so``\ .
-.. parsed-literal::
+.. code-block:: bash
make clean
./configure --enable-single; make; make install
Performing 3d FFTs requires communication to transpose the 3d FFT
grid. The data packing/unpacking for this can be done in one of 3
-modes (ARRAY, POINTER, MEMCPY) as set by the FFT\_PACK syntax above.
+modes (ARRAY, POINTER, MEMCPY) as set by the FFT_PACK syntax above.
Depending on the machine, the size of the FFT grid, the number of
processors used, one option may be slightly faster. The default is
ARRAY mode.
-
----------
-
.. _size:
Size of LAMMPS data types
@@ -196,19 +178,18 @@ adequate.
**CMake variable**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D LAMMPS_SIZES=value # smallbig (default) or bigbig or smallsmall
**Makefile.machine setting**\ :
-
-.. parsed-literal::
+.. code-block:: make
LMP_INC = -DLAMMPS_SMALLBIG # or -DLAMMPS_BIGBIG or -DLAMMPS_SMALLSMALL
-# default is LAMMPS\_SMALLBIG if not specified
+The default setting is ``-DLAMMPS_SMALLBIG`` if nothing is specified
+
**CMake and make info**\ :
The default "smallbig" setting allows for simulations with:
@@ -235,7 +216,7 @@ support 8-byte integers. It allows for:
Atom IDs are not required for atomic systems which do not store bond
topology information, though IDs are enabled by default. The
-:doc:`atom\_modify id no ` command will turn them off. Atom
+:doc:`atom_modify id no ` command will turn them off. Atom
IDs are required for molecular systems with bond topology (bonds,
angles, dihedrals, etc). Thus if you model a molecular system with
more than 2 billion atoms, you need the "bigbig" setting.
@@ -256,12 +237,10 @@ than crashing randomly or corrupting data.
Also note that the GPU package requires its lib/gpu library to be
compiled with the same size setting, or the link will fail. A CMake
build does this automatically. When building with make, the setting
-in whichever lib/gpu/Makefile is used must be the same as above.
-
+in whichever ``lib/gpu/Makefile`` is used must be the same as above.
----------
-
.. _graphics:
Output of JPG, PNG, and movie files
@@ -274,22 +253,20 @@ following settings:
**CMake variables**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D WITH_JPEG=value # yes or no
- # default = yes if CMake finds JPEG files, else no
+ # default = yes if CMake finds JPEG files, else no
-D WITH_PNG=value # yes or no
- # default = yes if CMake finds PNG and ZLIB files, else no
+ # default = yes if CMake finds PNG and ZLIB files, else no
-D WITH_FFMPEG=value # yes or no
- # default = yes if CMake can find ffmpeg, else no
+ # default = yes if CMake can find ffmpeg, else no
Usually these settings are all that is needed. If CMake cannot find
the graphics header, library, executable files, you can set these
variables:
-
-.. parsed-literal::
+.. code-block:: bash
-D JPEG_INCLUDE_DIR=path # path to jpeglib.h header file
-D JPEG_LIBRARIES=path # path to libjpeg.a (.so) file
@@ -301,8 +278,7 @@ variables:
**Makefile.machine settings**\ :
-
-.. parsed-literal::
+.. code-block:: make
LMP_INC = -DLAMMPS_JPEG
LMP_INC = -DLAMMPS_PNG
@@ -312,28 +288,27 @@ variables:
JPG_PATH = -L/usr/lib # paths to libjpeg.a, libpng.a, libz.a (.so) files if make cannot find them
JPG_LIB = -ljpeg -lpng -lz # library names
-As with CMake, you do not need to set JPG\_INC or JPG\_PATH, if make can
-find the graphics header and library files. You must specify JPG\_LIB
+As with CMake, you do not need to set ``JPG_INC`` or ``JPG_PATH``,
+if make can find the graphics header and library files. You must
+specify ``JPG_LIB``
with a list of graphics libraries to include in the link. You must
insure ffmpeg is in a directory where LAMMPS can find it at runtime,
-i.e. a dir in your PATH environment variable.
+that is a directory in your PATH environment variable.
**CMake and make info**\ :
-Using ffmpeg to output movie files requires that your machine
+Using ``ffmpeg`` to output movie files requires that your machine
supports the "popen" function in the standard runtime library.
.. note::
On some clusters with high-speed networks, using the fork()
- library calls (required by popen()) can interfere with the fast
+ library call (required by popen()) can interfere with the fast
communication library and lead to simulations using ffmpeg to hang or
crash.
-
----------
-
.. _gzip:
Read or write compressed files
@@ -341,12 +316,11 @@ Read or write compressed files
If this option is enabled, large files can be read or written with
gzip compression by several LAMMPS commands, including
-:doc:`read\_data `, :doc:`rerun `, and :doc:`dump `.
+:doc:`read_data `, :doc:`rerun `, and :doc:`dump `.
**CMake variables**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D WITH_GZIP=value # yes or no
# default is yes if CMake can find gzip, else no
@@ -354,8 +328,7 @@ gzip compression by several LAMMPS commands, including
**Makefile.machine setting**\ :
-
-.. parsed-literal::
+.. code-block:: make
LMP_INC = -DLAMMPS_GZIP
@@ -368,22 +341,20 @@ found by LAMMPS during a run.
.. note::
On some clusters with high-speed networks, using the fork()
- library calls (required by popen()) can interfere with the fast
+ library call (required by popen()) can interfere with the fast
communication library and lead to simulations using compressed output
or input to hang or crash. For selected operations, compressed file
I/O is also available using a compression library instead, which is
what the :ref:`COMPRESS package ` enables.
-
----------
-
.. _align:
Memory allocation alignment
---------------------------------------
-This setting enables the use of the posix\_memalign() call instead of
+This setting enables the use of the posix_memalign() call instead of
malloc() when LAMMPS allocates large chunks or memory. This can make
vector instructions on CPUs more efficient, if dynamically allocated
memory is aligned on larger-than-default byte boundaries.
@@ -394,33 +365,29 @@ aligned on 64-byte boundaries.
**CMake variable**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D LAMMPS_MEMALIGN=value # 0, 8, 16, 32, 64 (default)
-Use a LAMMPS\_MEMALIGN value of 0 to disable using posix\_memalign()
+Use a ``LAMMPS_MEMALIGN`` value of 0 to disable using posix_memalign()
and revert to using the malloc() C-library function instead. When
compiling LAMMPS for Windows systems, malloc() will always be used
and this setting ignored.
**Makefile.machine setting**\ :
-
-.. parsed-literal::
+.. code-block:: make
LMP_INC = -DLAMMPS_MEMALIGN=value # 8, 16, 32, 64
-Do not set -DLAMMPS\_MEMALIGN, if you want to have memory allocated
-with the malloc() function call instead. -DLAMMPS\_MEMALIGN **cannot**
+Do not set ``-DLAMMPS_MEMALIGN``, if you want to have memory allocated
+with the malloc() function call instead. ``-DLAMMPS_MEMALIGN`` **cannot**
be used on Windows, as it does use different function calls for
allocating aligned memory, that are not compatible with how LAMMPS
manages its dynamical memory.
-
----------
-
.. _longlong:
Workaround for long long integers
@@ -433,47 +400,37 @@ those systems:
**CMake variable**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D LAMMPS_LONGLONG_TO_LONG=value # yes or no (default)
**Makefile.machine setting**\ :
-
-.. parsed-literal::
+.. code-block:: make
LMP_INC = -DLAMMPS_LONGLONG_TO_LONG
-
----------
-
.. _exceptions:
Exception handling when using LAMMPS as a library
------------------------------------------------------------------
This setting is useful when external codes drive LAMMPS as a library.
-With this option enabled LAMMPS errors do not kill the caller.
+With this option enabled, LAMMPS errors do not kill the calling code.
Instead, the call stack is unwound and control returns to the caller,
-e.g. to Python.
+e.g. to Python. Of course the calling code has to be set up to
+*catch* exceptions from within LAMMPS.
**CMake variable**\ :
-
-.. parsed-literal::
+.. code-block:: bash
-D LAMMPS_EXCEPTIONS=value # yes or no (default)
**Makefile.machine setting**\ :
-
-.. parsed-literal::
+.. code-block:: make
LMP_INC = -DLAMMPS_EXCEPTIONS
-
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
diff --git a/doc/src/Build_windows.rst b/doc/src/Build_windows.rst
index fd96b379839bf298d9ce57d51358d206c2b6be50..1ad9dee1233b6e6468a222c9a1d99910e4b07e12 100644
--- a/doc/src/Build_windows.rst
+++ b/doc/src/Build_windows.rst
@@ -6,10 +6,8 @@ Notes for building LAMMPS on Windows
* :ref:`Using GNU GCC ported to Windows `
* :ref:`Using a cross-compiler `
-
----------
-
.. _generic:
General remarks
@@ -17,9 +15,9 @@ General remarks
LAMMPS is developed and tested primarily on Linux machines. The vast
majority of HPC clusters and supercomputers today runs on Linux as well.
-Thus portability to other platforms is desired, but not always achieved.
+While portability to other platforms is desired, it is not always achieved.
The LAMMPS developers strongly rely on LAMMPS users giving feedback and
-providing assistance in resolving portability issues. This particularly
+providing assistance in resolving portability issues. This is particularly
true for compiling LAMMPS on Windows, since this platform has significant
differences with some low-level functionality.
@@ -31,18 +29,20 @@ Running Linux on Windows
So before trying to build LAMMPS on Windows, please consider if using
the pre-compiled Windows binary packages are sufficient for your needs
(as an aside, those packages themselves are build on a Linux machine
-using cross-compilers). If it is necessary for your to compile LAMMPS
+using cross-compilers). If it is necessary for you to compile LAMMPS
on a Windows machine (e.g. because it is your main desktop), please also
-consider using a virtual machine software and run a Linux virtual machine,
-or - if have a recently updated Windows 10 installation - consider using
-the Windows subsystem for Linux, which allows to run a bash shell from
-Ubuntu and from there on, you can pretty much use that shell like you
-are running on an Ubuntu Linux machine (e.g. installing software via
-apt-get). For more details on that, please see :doc:`this tutorial `
+consider using a virtual machine software and compile and run LAMMPS in
+a Linux virtual machine, or - if you have a recently updated Windows 10
+installation - consider using the Windows subsystem for Linux. This
+optional Windows feature allows you to run the bash shell from Ubuntu
+from within Windows and from there on, you can pretty much use that
+shell like you are running on an Ubuntu Linux machine (e.g. installing
+software via apt-get and more). For more details on that, please
+see :doc:`this tutorial `
.. _gnu:
-Using GNU GCC ported to Windows
+Using a GNU GCC ported to Windows
-----------------------------------------
One option for compiling LAMMPS on Windows natively, that has been known
@@ -55,8 +55,8 @@ and the corresponding new code. A machine makefile for using cygwin for
the old build system is provided. Using CMake for this mode of compilation
is untested and not likely to work.
-When compiling for Windows do **not** set the -DLAMMPS\_MEMALIGN define
-in the LMP\_INC makefile variable and add -lwsock32 -lpsapi to the linker
+When compiling for Windows do **not** set the -DLAMMPS_MEMALIGN define
+in the LMP_INC makefile variable and add -lwsock32 -lpsapi to the linker
flags in LIB makefile variable. Try adding -static-libgcc or -static or
both to the linker flags when your resulting LAMMPS Windows executable
complains about missing .dll files. The CMake configuration should set
@@ -83,13 +83,19 @@ traditional build system, but CMake has also been successfully tested
using the mingw32-cmake and mingw64-cmake wrappers that are bundled
with the cross-compiler environment on Fedora machines. A CMake preset
selecting all packages compatible with this cross-compilation build
-is provided. You likely need to disable the GPU package unless you
-download and install the contents of the pre-compiled `OpenCL ICD loader library `_
-into your MinGW64 cross-compiler environment. The cross-compilation
-currently will only produce non-MPI serial binaries.
-
-Please keep in mind, though, that this only applies to compiling LAMMPS.
-Whether the resulting binaries do work correctly is no tested by the
+is provided. The GPU package can only be compiled with OpenCL support
+and you need to download and install the pre-compiled
+`OpenCL ICD loader library `_
+into your MinGW64 cross-compiler environment. With CMake this will be
+done transparently. To compile with MPI support, a pre-compiled
+library and the corresponding header files are required. There is
+`one package for 32-bit Windows `_
+and `a second package for 64-bit Windows `_.
+When building with CMake, the matching package will be downloaded
+automatically, but MPI support has to be explicitly enabled with ``-DBUILD_MPI=on``.
+
+Please keep in mind, though, that this only applies to **compiling** LAMMPS.
+Whether the resulting binaries do work correctly is not tested by the
LAMMPS developers. We instead rely on the feedback of the users
of these pre-compiled LAMMPS packages for Windows. We will try to resolve
issues to the best of our abilities if we become aware of them. However
@@ -104,8 +110,3 @@ Support for the Visual C++ compilers is currently not available. The
CMake build system is capable of creating suitable a Visual Studio
style build environment, but the LAMMPS code itself is not fully ported
to support Visual C++. Volunteers to take on this task are welcome.
-
-
-.. _lws: http://lammps.sandia.gov
-.. _ld: Manual.html
-.. _lc: Commands_all.html
diff --git a/doc/src/Commands.rst b/doc/src/Commands.rst
index f192d6a59dd193c36cde8a7627ee3aee84a79622..72a98159ff0a689bda2c727de3b23786b48a6081 100644
--- a/doc/src/Commands.rst
+++ b/doc/src/Commands.rst
@@ -4,7 +4,6 @@ Commands
These pages describe how a LAMMPS input script is formatted and the
commands in it are used to define a LAMMPS simulation.
-
.. toctree::
:maxdepth: 1
diff --git a/doc/src/Commands_all.rst b/doc/src/Commands_all.rst
index 6e87ffbad6e51a514c1dafac5a6b75f7ea6e9f4f..92c0ba107aadc080950f1a312291cb335fc4e022 100644
--- a/doc/src/Commands_all.rst
+++ b/doc/src/Commands_all.rst
@@ -17,7 +17,7 @@ General commands
An alphabetic list of all general LAMMPS commands.
.. table_from_list::
- :columns: 6
+ :columns: 5
* :doc:`angle_coeff `
* :doc:`angle_style `
@@ -70,6 +70,7 @@ An alphabetic list of all general LAMMPS commands.
* :doc:`kim_init `
* :doc:`kim_interactions `
* :doc:`kim_param `
+ * :doc:`kim_property `
* :doc:`kim_query `
* :doc:`kspace_modify `
* :doc:`kspace_style `
@@ -136,4 +137,3 @@ An alphabetic list of all general LAMMPS commands.
* :doc:`write_data `
* :doc:`write_dump `
* :doc:`write_restart `
-
diff --git a/doc/src/Commands_bond.rst b/doc/src/Commands_bond.rst
index 5412675ee420326e608b6fb6b24d4fcc8978ec27..0cb1b723b8755ed87c1d8cc1a364b7792faa7fc3 100644
--- a/doc/src/Commands_bond.rst
+++ b/doc/src/Commands_bond.rst
@@ -99,7 +99,6 @@ have accelerated versions. This is indicated by additional letters in
parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t =
OPT.
-
.. table_from_list::
:columns: 4
@@ -131,7 +130,7 @@ OPT.
Improper_style potentials
=========================
-All LAMMPS :doc:`improper\_style ` commands. Some styles
+All LAMMPS :doc:`improper_style ` commands. Some styles
have accelerated versions. This is indicated by additional letters in
parenthesis: g = GPU, i = USER-INTEL, k = KOKKOS, o = USER-OMP, t =
OPT.
diff --git a/doc/src/Commands_category.rst b/doc/src/Commands_category.rst
index b1b0e0cadcf6e83d1875c7728566f7a2e5e01494..da40ada9998844f53d0bdacd53b7abc848791cf0 100644
--- a/doc/src/Commands_category.rst
+++ b/doc/src/Commands_category.rst
@@ -7,126 +7,163 @@ alphabetically. Style options for entries like fix, compute, pair etc.
have their own pages where they are listed alphabetically.
Initialization:
+------------------------------
-* :doc:`newton `,
-* :doc:`package `,
-* :doc:`processors `,
-* :doc:`suffix `,
-* :doc:`units `
+.. table_from_list::
+ :columns: 5
+
+ * :doc:`newton `
+ * :doc:`package `
+ * :doc:`processors `
+ * :doc:`suffix `
+ * :doc:`units `
Setup simulation box:
+------------------------------
-* :doc:`boundary `,
-* :doc:`box `,
-* :doc:`change\_box `,
-* :doc:`create\_box `,
-* :doc:`dimension `,
-* :doc:`lattice `,
-* :doc:`region `
+.. table_from_list::
+ :columns: 4
-Setup atoms:
+ * :doc:`boundary `
+ * :doc:`box `
+ * :doc:`change_box `
+ * :doc:`create_box `
+ * :doc:`dimension `
+ * :doc:`lattice `
+ * :doc:`region `
-* :doc:`atom\_modify `,
-* :doc:`atom\_style `,
-* :doc:`balance `,
-* :doc:`create\_atoms `,
-* :doc:`create\_bonds `,
-* :doc:`delete\_atoms `,
-* :doc:`delete\_bonds `,
-* :doc:`displace\_atoms `,
-* :doc:`group `,
-* :doc:`mass `,
-* :doc:`molecule `,
-* :doc:`read\_data