diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2686011281..1b4cae3aaa 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -61,12 +61,14 @@ src/GPU/pair_vashishta_gpu.* @andeplane src/KOKKOS/pair_vashishta_kokkos.* @andeplane src/MANYBODY/pair_vashishta_table.* @andeplane src/MANYBODY/pair_atm.* @sergeylishchuk +src/MANYBODY/pair_nb3b_screened.* @flodesani src/REPLICA/*_grem.* @dstelter92 src/EXTRA-COMPUTE/compute_stress_mop*.* @RomainVermorel src/EXTRA-COMPUTE/compute_born_matrix.* @Bibobu @athomps src/MISC/*_tracker.* @jtclemm src/MC/fix_gcmc.* @athomps src/MC/fix_sgcmc.* @athomps +src/REPLICA/fix_pimd_langevin.* @Yi-FanLi # core LAMMPS classes src/lammps.* @sjplimp @@ -134,6 +136,7 @@ src/timer.* @akohlmey src/utils.* @akohlmey @rbberger src/verlet.* @sjplimp @stanmoore1 src/math_eigen_impl.h @jewettaij +src/fix_press_langevin.* @Bibobu # tools tools/coding_standard/* @akohlmey @rbberger @@ -150,12 +153,12 @@ tools/vim/* @hammondkd unittest/* @akohlmey # cmake -cmake/* @rbberger +cmake/* @akohlmey cmake/Modules/LAMMPSInterfacePlugin.cmake @akohlmey cmake/Modules/MPI4WIN.cmake @akohlmey cmake/Modules/OpenCLLoader.cmake @akohlmey -cmake/Modules/Packages/COLVARS.cmake @rbberger @giacomofiorin -cmake/Modules/Packages/KIM.cmake @rbberger @ellio167 +cmake/Modules/Packages/COLVARS.cmake @giacomofiorin +cmake/Modules/Packages/KIM.cmake @ellio167 cmake/presets/*.cmake @akohlmey # python diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 44a5ced761..891d1ad5e5 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,13 +1,13 @@ # Contributing to LAMMPS via GitHub -Thank your for considering to contribute to the LAMMPS software project. +Thank you for considering to contribute to the LAMMPS software project. The following is a set of guidelines as well as explanations of policies and work flows for contributing to the LAMMPS molecular dynamics software project. These guidelines focus on submitting issues or pull requests on the LAMMPS GitHub project. Thus please also have a look at: -* [The guide for submitting new features in the LAMMPS manual](https://www.lammps.org/doc/Modify_contribute.html) -* [The guide on programming style and requirement in the LAMMPS manual](https://www.lammps.org/doc/Modify_style.html) -* [The GitHub tutorial in the LAMMPS manual](http://lammps.sandia.gov/doc/Howto_github.html) +* [The guide for submitting new features in the LAMMPS manual](https://docs.lammps.org/Modify_contribute.html) +* [The guide on programming style and requirement in the LAMMPS manual](https://docs.lammps.org/Modify_requirements.html) +* [The GitHub tutorial in the LAMMPS manual](http://docs.lammps.org/Howto_github.html) ## Table of Contents @@ -27,17 +27,17 @@ __ ## I don't want to read this whole thing I just have a question! -> **Note:** Please do not file an issue to ask a general question about LAMMPS, its features, how to use specific commands, or how perform simulations or analysis in LAMMPS. Instead post your question to either the ['lammps-users' mailing list](https://lammps.sandia.gov/mail.html) or the [LAMMPS Material Science Discourse forum](https://matsci.org/lammps). You do not need to be subscribed to post to the list (but a mailing list subscription avoids having your post delayed until it is approved by a mailing list moderator). Most posts to the mailing list receive a response within less than 24 hours. Before posting to the mailing list, please read the [mailing list guidelines](https://lammps.sandia.gov/guidelines.html). Following those guidelines will help greatly to get a helpful response. Always mention which LAMMPS version you are using. The LAMMPS forum was recently created as part of a larger effort to build a materials science community and have discussions not just about using LAMMPS. Thus the forum may be also used for discussions that would be off-topic for the mailing list. Those will just have to be posted to a more general category. +> **Note:** Please do not file an issue to ask a general question about LAMMPS, its features, how to use specific commands, or how perform simulations or analysis in LAMMPS. Instead post your question to the [LAMMPS Material Science Discourse forum](https://matsci.org/lammps). Before posting to the forum, please read the general [guidelines](https://www.lammps.org/guidelines.html) and the forum specific [suggestions](https://matsci.org/t/please-read-this-first-guidelines-and-suggestions-for-posting-lammps-questions/49913). Following those guidelines and suggestions will help greatly to get a helpful response. *Always* mention which LAMMPS version you are using. The MatSci website may be also used for discussions that would be off-topic for the LAMMPS categories. Those will just have to be posted to a different category. ## How Can I Contribute? There are several ways how you can actively contribute to the LAMMPS project: you can discuss compiling and using LAMMPS, and solving LAMMPS related problems with other LAMMPS users on the lammps-users mailing list or the forum, you can report bugs or suggest enhancements by creating issues on GitHub (or posting them to the lammps-users mailing list or posting in the LAMMPS Materials Science Discourse forum), and you can contribute by submitting pull requests on GitHub or e-mail your code -to one of the [LAMMPS core developers](https://lammps.sandia.gov/authors.html). As you may see from the aforementioned developer page, the LAMMPS software package includes the efforts of a very large number of contributors beyond the principal authors and maintainers. +to one of the [LAMMPS core developers](https://www.lammps.org/authors.html). As you may see from the aforementioned developer page, the LAMMPS software package includes the efforts of a very large number of contributors beyond the principal authors and maintainers. ### Discussing How To Use LAMMPS The LAMMPS mailing list is hosted at SourceForge. The mailing list began in 2005, and now includes tens of thousands of messages in thousands of threads. LAMMPS developers try to respond to posted questions in a timely manner, but there are no guarantees. Please consider that people live in different timezone and may not have time to answer e-mails outside of their work hours. -You can post to list by sending your email to lammps-users at lists.sourceforge.net (no subscription required), but before posting, please read the [mailing list guidelines](https://lammps.sandia.gov/guidelines.html) to maximize your chances to receive a helpful response. +You can post to list by sending your email to lammps-users at lists.sourceforge.net (no subscription required), but before posting, please read the [mailing list guidelines](https://www.lammps.org/guidelines.html) to maximize your chances to receive a helpful response. Anyone can browse/search previous questions/answers in the archives. You do not have to subscribe to the list to post questions, receive answers (to your questions), or browse/search the archives. You **do** need to subscribe to the list if you want emails for **all** the posts (as individual messages or in digest form), or to answer questions yourself. Feel free to sign up and help us out! Answering questions from fellow LAMMPS users is a great way to pay back the community for providing you a useful tool for free, and to pass on the advice you have received yourself to others. It improves your karma and helps you understand your own research better. @@ -47,7 +47,7 @@ The LAMMPS Materials Science Discourse forum was created recently to facilitate ### Reporting Bugs -While developers writing code for LAMMPS are careful to test their code, LAMMPS is such a large and complex software, that it is impossible to test for all combinations of features under all normal and not so normal circumstances. Thus bugs do happen, and if you suspect, that you have encountered one, please try to document it and report it as an [Issue](https://github.com/lammps/lammps/issues) on the LAMMPS GitHub project web page. However, before reporting a bug, you need to check whether this is something that may have already been corrected. The [Latest Features and Bug Fixes in LAMMPS](https://lammps.sandia.gov/bug.html) web page lists all significant changes to LAMMPS over the years. It also tells you what the current latest development version of LAMMPS is, and you should test whether your issue still applies to that version. +While developers writing code for LAMMPS are careful to test their code, LAMMPS is such a large and complex software, that it is impossible to test for all combinations of features under all normal and not so normal circumstances. Thus bugs do happen, and if you suspect, that you have encountered one, please try to document it and report it as an [Issue](https://github.com/lammps/lammps/issues) on the LAMMPS GitHub project web page. However, before reporting a bug, you need to check whether this is something that may have already been corrected. The [Latest Features and Bug Fixes in LAMMPS](https://www.lammps.org/bug.html) web page lists all significant changes to LAMMPS over the years. It also tells you what the current latest development version of LAMMPS is, and you should test whether your issue still applies to that version. When you click on the green "New Issue" button, you will be provided with a text field, where you can enter your message. That text field with contain a template with several headlines and some descriptions. Keep the headlines that are relevant to your reported potential bug and replace the descriptions with the information as suggested by the descriptions. You can also attach small text files (please add the file name extension `.txt` or it will be rejected), images, or small compressed text files (using gzip, do not use RAR or 7-ZIP or similar tools that are uncommon outside of Windows machines). In many cases, bugs are best illustrated by providing a small input deck (do **not** attach your entire production input, but remove everything that is not required to reproduce the issue, and scale down your system size, that the resulting calculation runs fast and can be run on small desktop quickly). @@ -65,9 +65,9 @@ To be able to submit an issue on GitHub, you have to register for an account (fo We encourage users to submit new features or modifications for LAMMPS. Instructions, guidelines, requirements, and recommendations are in the following sections of the LAMMPS manual: -* [The guide for submitting new features in the LAMMPS manual](https://lammps.sandia.gov/doc/Modify_contribute.html) -* [The guide on programming style and requirement in the LAMMPS manual](https://lammps.sandia.gov/doc/Modify_contribute.html) -* [The GitHub tutorial in the LAMMPS manual](http://lammps.sandia.gov/doc/Howto_github.html) +* [The guide for submitting new features in the LAMMPS manual](https://docs.lammps.org/Modify_contribute.html) +* [The guide on programming style and requirement in the LAMMPS manual](https://docs.lammps.org/Modify_requirements.html) +* [The GitHub tutorial in the LAMMPS manual](http://docs.lammps.org/Howto_github.html) ## GitHub Workflows @@ -85,7 +85,7 @@ For bug reports, the next step is that one of the core LAMMPS developers will se ### Pull Requests Pull requests are the **only** way that changes get made to the LAMMPS distribution. So also the LAMMPS core developers will submit pull requests for their own changes and discuss them on GitHub. Thus if you submit a pull request it will be treated in a similar fashion. When you submit a pull request you may opt to submit a "Draft" pull request. That means your changes are visible and will be subject to testing, but reviewers will not be (auto-)assigned and comments will take into account that this is not complete. On the other hand, this is a perfect way to ask the LAMMPS developers for comments on non-obvious changes and get feedback and possible suggestions for improvements or recommendations about what to avoid. -Immediately after the submission, the LAMMPS continuing integration server at ci.lammps.org will download your submitted branch and perform a number of tests: it will tests whether it compiles cleanly under various conditions, it will also do a check on whether your included documentation translates cleanly and run some unit tests and other checks. Whether these tests are successful or fail will be recorded. If a test fails, please inspect the corresponding output on the CI server and take the necessary steps, if needed, so that the code can compile cleanly again. The test will be re-run each time the pull request is updated with a push to the remote branch on GitHub. If you are unsure about what you need to change, ask a question in the discussion area of the pull request. +Immediately after the submission, the LAMMPS continuing integration server at https://ci.lammps.org will download your submitted branch and perform a number of tests: it will tests whether it compiles cleanly under various conditions, it will also do a check on whether your included documentation translates cleanly and run some unit tests and other checks. Whether these tests are successful or fail will be recorded. If a test fails, please inspect the corresponding output on the CI server and take the necessary steps, if needed, so that the code can compile cleanly again. The test will be re-run each time the pull request is updated with a push to the remote branch on GitHub. If you are unsure about what you need to change, ask a question in the discussion area of the pull request. Next a LAMMPS core developer will self-assign and do an overall technical assessment of the submission. If you submitted a draft pull request, this will not happen unless you mark it "ready for review". If you are not yet invited as a LAMMPS collaborator, and your contribution seems significant, you may also receive an invitation for collaboration on the LAMMPS repository. As part of the assessment, the pull request will be categorized with labels. There are two special labels: `needs_work` (indicates that work from the submitter of the pull request is needed) and `work_in_progress` (indicates, that the assigned LAMMPS developer will make changes, if not done by the contributor who made the submit). You may also receive comments and suggestions on the overall submission or specific details and on occasion specific requests for changes as part of the review. If permitted, also additional changes may be pushed into your pull request branch or a pull request may be filed in your LAMMPS fork on GitHub to include those changes. The LAMMPS developer may then decide to assign the pull request to another developer (e.g. when that developer is more knowledgeable about the submitted feature or enhancement or has written the modified code). It may also happen, that additional developers are requested to provide a review and approve the changes. For submissions, that may change the general behavior of LAMMPS, or where a possibility of unwanted side effects exists, additional tests may be requested by the assigned developer. diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c33628ac04..c7dd945f5f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -25,17 +25,17 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} config-file: ./.github/codeql/${{ matrix.language }}.yml @@ -55,4 +55,4 @@ jobs: cmake --build . --parallel 2 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/compile-msvc.yml b/.github/workflows/compile-msvc.yml index 5ae0654ee0..1a0f1ea62f 100644 --- a/.github/workflows/compile-msvc.yml +++ b/.github/workflows/compile-msvc.yml @@ -19,12 +19,12 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 - name: Select Python version - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.11' diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 7bda3a071f..00a4596cc8 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 @@ -59,16 +59,13 @@ jobs: -D BUILD_SHARED_LIBS=on \ -D LAMMPS_SIZES=SMALLBIG \ -D LAMMPS_EXCEPTIONS=off \ - -D PKG_MESSAGE=on \ - -D PKG_MPIIO=on \ -D PKG_ATC=on \ -D PKG_AWPMD=on \ - -D PKG_BOCS=on \ - -D PKG_EFF=on \ -D PKG_H5MD=on \ -D PKG_INTEL=on \ -D PKG_LATBOLTZ=on \ -D PKG_MANIFOLD=on \ + -D PKG_MDI=on \ -D PKG_MGPT=on \ -D PKG_ML-PACE=on \ -D PKG_ML-RANN=on \ @@ -77,7 +74,6 @@ jobs: -D PKG_PTM=on \ -D PKG_QTB=on \ -D PKG_SMTBQ=on \ - -D PKG_TALLY=on \ ../cmake - name: Run Coverity Scan diff --git a/.github/workflows/unittest-macos.yml b/.github/workflows/unittest-macos.yml index ea979ca94f..6970faceaa 100644 --- a/.github/workflows/unittest-macos.yml +++ b/.github/workflows/unittest-macos.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 diff --git a/.gitignore b/.gitignore index a89f75cc9a..4faef4b8db 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,6 @@ out/x86 out/x64 src/Makefile.package-e src/Makefile.package.settings-e +/cmake/build/x64-Debug-Clang +/install/x64-GUI-MSVC +/install diff --git a/cmake/CMakeLists.jpeg b/cmake/CMakeLists.jpeg deleted file mode 100644 index f0bd85a90d..0000000000 --- a/cmake/CMakeLists.jpeg +++ /dev/null @@ -1,615 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -# When using CMake 3.4 and later, don't export symbols from executables unless -# the CMAKE_ENABLE_EXPORTS variable is set. -if(POLICY CMP0065) - cmake_policy(SET CMP0065 NEW) -endif() -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() -if(CMAKE_EXECUTABLE_SUFFIX) - set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX}) -endif() - -project(libjpeg-turbo C) -set(VERSION 2.1.3) -set(COPYRIGHT_YEAR "1991-2022") -string(REPLACE "." ";" VERSION_TRIPLET ${VERSION}) -list(GET VERSION_TRIPLET 0 VERSION_MAJOR) -list(GET VERSION_TRIPLET 1 VERSION_MINOR) -list(GET VERSION_TRIPLET 2 VERSION_REVISION) -function(pad_number NUMBER OUTPUT_LEN) - string(LENGTH "${${NUMBER}}" INPUT_LEN) - if(INPUT_LEN LESS OUTPUT_LEN) - math(EXPR ZEROES "${OUTPUT_LEN} - ${INPUT_LEN} - 1") - set(NUM ${${NUMBER}}) - foreach(C RANGE ${ZEROES}) - set(NUM "0${NUM}") - endforeach() - set(${NUMBER} ${NUM} PARENT_SCOPE) - endif() -endfunction() -pad_number(VERSION_MINOR 3) -pad_number(VERSION_REVISION 3) -set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVISION}) - -# CMake 3.14 and later sets CMAKE_MACOSX_BUNDLE to TRUE by default when -# CMAKE_SYSTEM_NAME is iOS, tvOS, or watchOS, which breaks the libjpeg-turbo -# build. (Specifically, when CMAKE_MACOSX_BUNDLE is TRUE, executables for -# Apple platforms are built as application bundles, which causes CMake to -# complain that our install() directives for executables do not specify a -# BUNDLE DESTINATION. Even if CMake did not complain, building executables as -# application bundles would break our iOS packages.) -set(CMAKE_MACOSX_BUNDLE FALSE) - -string(TIMESTAMP DEFAULT_BUILD "%Y%m%d") -set(BUILD ${DEFAULT_BUILD} CACHE STRING "Build string (default: ${DEFAULT_BUILD})") - -# NOTE: On Windows, this does nothing except when using MinGW or Cygwin. -# CMAKE_BUILD_TYPE has no meaning in Visual Studio, and it always defaults to -# Debug when using NMake. -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif() -message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") - -message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}") - -include(cmakescripts/PackageInfo.cmake) - -# Detect CPU type and whether we're building 64-bit or 32-bit code -math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8") -string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC) -set(COUNT 1) -foreach(ARCH ${CMAKE_OSX_ARCHITECTURES}) - if(COUNT GREATER 1) - message(FATAL_ERROR "The libjpeg-turbo build system does not support multiple values in CMAKE_OSX_ARCHITECTURES.") - endif() - math(EXPR COUNT "${COUNT}+1") -endforeach() -if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32") - if(BITS EQUAL 64 OR CMAKE_C_COMPILER_ABI MATCHES "ELF X32") - set(CPU_TYPE x86_64) - else() - set(CPU_TYPE i386) - endif() - if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ${CPU_TYPE}) - set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE}) - endif() -elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^arm") - if(BITS EQUAL 64) - set(CPU_TYPE arm64) - else() - set(CPU_TYPE arm) - endif() -elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^ppc" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^powerpc") - set(CPU_TYPE powerpc) -else() - set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC}) -endif() -if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR - CMAKE_OSX_ARCHITECTURES MATCHES "arm64" OR - CMAKE_OSX_ARCHITECTURES MATCHES "i386") - set(CPU_TYPE ${CMAKE_OSX_ARCHITECTURES}) -endif() -if(CMAKE_OSX_ARCHITECTURES MATCHES "ppc") - set(CPU_TYPE powerpc) -endif() -if(MSVC_IDE AND CMAKE_GENERATOR_PLATFORM MATCHES "arm64") - set(CPU_TYPE arm64) -endif() - -message(STATUS "${BITS}-bit build (${CPU_TYPE})") - -macro(report_directory var) - if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var}) - message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}") - else() - message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}} (${CMAKE_INSTALL_FULL_${var}})") - endif() - mark_as_advanced(CLEAR CMAKE_INSTALL_${var}) -endmacro() - -set(DIRLIST "BINDIR;DATAROOTDIR;DOCDIR;INCLUDEDIR;LIBDIR") -if(UNIX) - list(APPEND DIRLIST "MANDIR") -endif() -foreach(dir ${DIRLIST}) - report_directory(${dir}) -endforeach() - - -############################################################################### -# CONFIGURATION OPTIONS -############################################################################### - -macro(boolean_number var) - if(${var}) - set(${var} 1 ${ARGN}) - else() - set(${var} 0 ${ARGN}) - endif() -endmacro() - -option(ENABLE_SHARED "Build shared libraries" FALSE) -boolean_number(ENABLE_SHARED) -option(ENABLE_STATIC "Build static libraries" TRUE) -boolean_number(ENABLE_STATIC) -option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE) -boolean_number(REQUIRE_SIMD) -option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE) -boolean_number(WITH_12BIT) -option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE) -boolean_number(WITH_ARITH_DEC) -option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE) -boolean_number(WITH_ARITH_ENC) -if(CMAKE_C_COMPILER_ABI MATCHES "ELF X32") - set(WITH_JAVA 0) -else() - option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE) - boolean_number(WITH_JAVA) -endif() -option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE) -boolean_number(WITH_JPEG7) -option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE) -boolean_number(WITH_JPEG8) -option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE) -boolean_number(WITH_MEM_SRCDST) -option(WITH_SIMD "Include SIMD extensions, if available for this platform" FALSE) -boolean_number(WITH_SIMD) -option(WITH_TURBOJPEG "Include the TurboJPEG API library and associated test programs" FALSE) -boolean_number(WITH_TURBOJPEG) -option(WITH_FUZZ "Build fuzz targets" FALSE) - -macro(report_option var desc) - if(${var}) - message(STATUS "${desc} enabled (${var} = ${${var}})") - else() - message(STATUS "${desc} disabled (${var} = ${${var}})") - endif() -endmacro() - -if(WITH_JAVA) - set(ENABLE_SHARED 1) -endif() - -# Explicitly setting CMAKE_POSITION_INDEPENDENT_CODE=FALSE disables PIC for all -# targets, which will cause the shared library builds to fail. Thus, if shared -# libraries are enabled and CMAKE_POSITION_INDEPENDENT_CODE is explicitly set -# to FALSE, we need to unset it, thus restoring the default behavior -# (automatically using PIC for shared library targets.) -if(DEFINED CMAKE_POSITION_INDEPENDENT_CODE AND - NOT CMAKE_POSITION_INDEPENDENT_CODE AND ENABLE_SHARED) - unset(CMAKE_POSITION_INDEPENDENT_CODE CACHE) -endif() - -report_option(ENABLE_SHARED "Shared libraries") -report_option(ENABLE_STATIC "Static libraries") - -if(ENABLE_SHARED) - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) -endif() - -if(WITH_JPEG8 OR WITH_JPEG7) - set(WITH_ARITH_ENC 1) - set(WITH_ARITH_DEC 1) -endif() -if(WITH_JPEG8) - set(WITH_MEM_SRCDST 0) -endif() - -if(WITH_12BIT) - set(WITH_ARITH_DEC 0) - set(WITH_ARITH_ENC 0) - set(WITH_JAVA 0) - set(WITH_SIMD 0) - set(WITH_TURBOJPEG 0) - set(BITS_IN_JSAMPLE 12) -else() - set(BITS_IN_JSAMPLE 8) -endif() -report_option(WITH_12BIT "12-bit JPEG support") - -if(WITH_ARITH_DEC) - set(D_ARITH_CODING_SUPPORTED 1) -endif() -if(NOT WITH_12BIT) - report_option(WITH_ARITH_DEC "Arithmetic decoding support") -endif() - -if(WITH_ARITH_ENC) - set(C_ARITH_CODING_SUPPORTED 1) -endif() -if(NOT WITH_12BIT) - report_option(WITH_ARITH_ENC "Arithmetic encoding support") -endif() - -if(NOT WITH_12BIT) - report_option(WITH_TURBOJPEG "TurboJPEG API library") - report_option(WITH_JAVA "TurboJPEG Java wrapper") -endif() - -if(WITH_MEM_SRCDST) - set(MEM_SRCDST_SUPPORTED 1) - set(MEM_SRCDST_FUNCTIONS "global: jpeg_mem_dest; jpeg_mem_src;") -endif() -if(NOT WITH_JPEG8) - report_option(WITH_MEM_SRCDST "In-memory source/destination managers") -endif() - -set(SO_AGE 2) -if(WITH_MEM_SRCDST) - set(SO_AGE 3) -endif() - -if(WITH_JPEG8) - set(JPEG_LIB_VERSION 80) -elseif(WITH_JPEG7) - set(JPEG_LIB_VERSION 70) -else() - set(JPEG_LIB_VERSION 62) -endif() - -math(EXPR JPEG_LIB_VERSION_DIV10 "${JPEG_LIB_VERSION} / 10") -math(EXPR JPEG_LIB_VERSION_MOD10 "${JPEG_LIB_VERSION} % 10") -if(JPEG_LIB_VERSION STREQUAL "62") - set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION}) -else() - set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION_DIV10}) -endif() -if(JPEG_LIB_VERSION STREQUAL "80") - set(DEFAULT_SO_MINOR_VERSION 2) -else() - set(DEFAULT_SO_MINOR_VERSION 0) -endif() - -# This causes SO_MAJOR_VERSION/SO_MINOR_VERSION to reset to defaults if -# WITH_JPEG7 or WITH_JPEG8 has changed. -if((DEFINED WITH_JPEG7_INT AND NOT WITH_JPEG7 EQUAL WITH_JPEG7_INT) OR - (DEFINED WITH_JPEG8_INT AND NOT WITH_JPEG8 EQUAL WITH_JPEG8_INT)) - set(FORCE_SO_VERSION "FORCE") -endif() -set(WITH_JPEG7_INT ${WITH_JPEG7} CACHE INTERNAL "") -set(WITH_JPEG8_INT ${WITH_JPEG8} CACHE INTERNAL "") - -set(SO_MAJOR_VERSION ${DEFAULT_SO_MAJOR_VERSION} CACHE STRING - "Major version of the libjpeg API shared library (default: ${DEFAULT_SO_MAJOR_VERSION})" - ${FORCE_SO_VERSION}) -set(SO_MINOR_VERSION ${DEFAULT_SO_MINOR_VERSION} CACHE STRING - "Minor version of the libjpeg API shared library (default: ${DEFAULT_SO_MINOR_VERSION})" - ${FORCE_SO_VERSION}) - -set(JPEG_LIB_VERSION_DECIMAL "${JPEG_LIB_VERSION_DIV10}.${JPEG_LIB_VERSION_MOD10}") -message(STATUS "Emulating libjpeg API/ABI v${JPEG_LIB_VERSION_DECIMAL} (WITH_JPEG7 = ${WITH_JPEG7}, WITH_JPEG8 = ${WITH_JPEG8})") -message(STATUS "libjpeg API shared library version = ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION}") - -# Because the TurboJPEG API library uses versioned symbols and changes the -# names of functions whenever they are modified in a backward-incompatible -# manner, it is always backward-ABI-compatible with itself, so the major and -# minor SO versions don't change. However, we increase the middle number (the -# SO "age") whenever functions are added to the API. -set(TURBOJPEG_SO_MAJOR_VERSION 0) -set(TURBOJPEG_SO_AGE 2) -set(TURBOJPEG_SO_VERSION 0.${TURBOJPEG_SO_AGE}.0) - - -############################################################################### -# COMPILER SETTINGS -############################################################################### - -if(MSVC) - option(WITH_CRT_DLL - "Link all ${CMAKE_PROJECT_NAME} libraries and executables with the C run-time DLL (msvcr*.dll) instead of the static C run-time library (libcmt*.lib.) The default is to use the C run-time DLL only with the libraries and executables that need it." - FALSE) - if(NOT WITH_CRT_DLL) - # Use the static C library for all build types - foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) - if(${var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}") - endif() - endforeach() - endif() - add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) -endif() - -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") - # Use the maximum optimization level for release builds - foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO) - if(${var} MATCHES "-O2") - string(REGEX REPLACE "-O2" "-O3" ${var} "${${var}}") - endif() - endforeach() -endif() - -if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") - if(CMAKE_C_COMPILER_ID MATCHES "SunPro") - # Use the maximum optimization level for release builds - foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO) - if(${var} MATCHES "-xO3") - string(REGEX REPLACE "-xO3" "-xO5" ${var} "${${var}}") - endif() - if(${var} MATCHES "-xO2") - string(REGEX REPLACE "-xO2" "-xO5" ${var} "${${var}}") - endif() - endforeach() - endif() -endif() - -string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) - -set(EFFECTIVE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}") -message(STATUS "Compiler flags = ${EFFECTIVE_C_FLAGS}") - -set(EFFECTIVE_LD_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}") -message(STATUS "Linker flags = ${EFFECTIVE_LD_FLAGS}") - -include(CheckCSourceCompiles) -include(CheckIncludeFiles) -include(CheckTypeSize) - -check_type_size("size_t" SIZE_T) -check_type_size("unsigned long" UNSIGNED_LONG) - -if(SIZE_T EQUAL UNSIGNED_LONG) - check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc; return __builtin_ctzl(a); }" - HAVE_BUILTIN_CTZL) -endif() -if(MSVC) - check_include_files("intrin.h" HAVE_INTRIN_H) -endif() - -if(UNIX) - if(CMAKE_CROSSCOMPILING) - set(RIGHT_SHIFT_IS_UNSIGNED 0) - else() - include(CheckCSourceRuns) - check_c_source_runs(" - #include - #include - int is_shifting_signed (long arg) { - long res = arg >> 4; - if (res == -0x7F7E80CL) - return 1; /* right shift is signed */ - /* see if unsigned-shift hack will fix it. */ - /* we can't just test exact value since it depends on width of long... */ - res |= (~0L) << (32-4); - if (res == -0x7F7E80CL) - return 0; /* right shift is unsigned */ - printf(\"Right shift isn't acting as I expect it to.\\\\n\"); - printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\"); - return 0; /* try it with unsigned anyway */ - } - int main (void) { - exit(is_shifting_signed(-0x7F7E80B1L)); - }" RIGHT_SHIFT_IS_UNSIGNED) - endif() -endif() - -if(MSVC) - set(INLINE_OPTIONS "__inline;inline") -else() - set(INLINE_OPTIONS "__inline__;inline") -endif() -option(FORCE_INLINE "Force function inlining" TRUE) -boolean_number(FORCE_INLINE) -if(FORCE_INLINE) - if(MSVC) - list(INSERT INLINE_OPTIONS 0 "__forceinline") - else() - list(INSERT INLINE_OPTIONS 0 "inline __attribute__((always_inline))") - list(INSERT INLINE_OPTIONS 0 "__inline__ __attribute__((always_inline))") - endif() -endif() -foreach(inline ${INLINE_OPTIONS}) - check_c_source_compiles("${inline} static int foo(void) { return 0; } int main(void) { return foo(); }" - INLINE_WORKS) - if(INLINE_WORKS) - set(INLINE ${inline}) - break() - endif() -endforeach() -if(NOT INLINE_WORKS) - message(FATAL_ERROR "Could not determine how to inline functions.") -endif() -message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})") - -if(WITH_TURBOJPEG) - if(MSVC) - set(THREAD_LOCAL "__declspec(thread)") - else() - set(THREAD_LOCAL "__thread") - endif() - check_c_source_compiles("${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }" HAVE_THREAD_LOCAL) - if(HAVE_THREAD_LOCAL) - message(STATUS "THREAD_LOCAL = ${THREAD_LOCAL}") - else() - message(WARNING "Thread-local storage is not available. The TurboJPEG API library's global error handler will not be thread-safe.") - unset(THREAD_LOCAL) - endif() -endif() - -if(UNIX AND NOT APPLE) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map "VERS_1 { global: *; };") - set(CMAKE_REQUIRED_FLAGS - "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") - check_c_source_compiles("int main(void) { return 0; }" HAVE_VERSION_SCRIPT) - set(CMAKE_REQUIRED_FLAGS) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map) - if(HAVE_VERSION_SCRIPT) - message(STATUS "Linker supports GNU-style version scripts") - set(MAPFLAG "-Wl,--version-script,") - set(TJMAPFLAG "-Wl,--version-script,") - else() - message(STATUS "Linker does not support GNU-style version scripts") - if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") - # The Solaris linker doesn't like our version script for the libjpeg API - # library, but the version script for the TurboJPEG API library should - # still work. - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map - "VERS_1 { global: foo; local: *; }; VERS_2 { global: foo2; } VERS_1;") - set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map -shared") - check_c_source_compiles("int foo() { return 0; } int foo2() { return 2; }" - HAVE_MAPFILE) - set(CMAKE_REQUIRED_FLAGS) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map) - if(HAVE_MAPFILE) - message(STATUS "Linker supports mapfiles") - set(TJMAPFLAG "-Wl,-M,") - else() - message(STATUS "Linker does not support mapfiles") - endif() - endif() - endif() -endif() - -# Generate files -if(WIN32) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win/jconfig.h.in jconfig.h) -else() - configure_file(jconfig.h.in jconfig.h) -endif() -configure_file(jconfigint.h.in jconfigint.h) -configure_file(jversion.h.in jversion.h) -if(UNIX) - configure_file(libjpeg.map.in libjpeg.map) -endif() - -# Include directories and compiler definitions -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) - - -############################################################################### -# TARGETS -############################################################################### - -if(CMAKE_EXECUTABLE_SUFFIX_TMP) - set(CMAKE_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX_TMP}) -endif() -message(STATUS "CMAKE_EXECUTABLE_SUFFIX = ${CMAKE_EXECUTABLE_SUFFIX}") - -set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c - jcicc.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c - jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c - jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c - jdtrans.c jerror.c jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c - jidctint.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c) - -if(WITH_ARITH_ENC OR WITH_ARITH_DEC) - set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c) -endif() - -if(WITH_ARITH_ENC) - set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c) -endif() - -if(WITH_ARITH_DEC) - set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c) -endif() - -if(WITH_SIMD) - add_subdirectory(simd) - if(NEON_INTRINSICS) - add_definitions(-DNEON_INTRINSICS) - endif() -elseif(NOT WITH_12BIT) - message(STATUS "SIMD extensions: None (WITH_SIMD = ${WITH_SIMD})") -endif() -if(WITH_SIMD) - message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})") - if(MSVC_IDE OR XCODE) - set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1) - endif() -else() - add_library(simd OBJECT jsimd_none.c) - if(NOT WIN32 AND (CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED)) - set_target_properties(simd PROPERTIES POSITION_INDEPENDENT_CODE 1) - endif() -endif() - -if(WITH_JAVA) - add_subdirectory(java) -endif() - -if(ENABLE_SHARED) - add_subdirectory(sharedlib) -endif() - -if(ENABLE_STATIC) - add_library(jpeg-static STATIC ${JPEG_SOURCES} $ - ${SIMD_OBJS}) - if(NOT MSVC) - set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg) - endif() -endif() - -if(WITH_TURBOJPEG) - if(ENABLE_SHARED) - set(TURBOJPEG_SOURCES ${JPEG_SOURCES} $ ${SIMD_OBJS} - turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c rdppm.c - wrbmp.c wrppm.c) - set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile) - if(WITH_JAVA) - set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c) - include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) - set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile.jni) - endif() - if(MSVC) - configure_file(${CMAKE_SOURCE_DIR}/win/turbojpeg.rc.in - ${CMAKE_BINARY_DIR}/win/turbojpeg.rc) - set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} - ${CMAKE_BINARY_DIR}/win/turbojpeg.rc) - endif() - add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES}) - set_property(TARGET turbojpeg PROPERTY COMPILE_FLAGS - "-DBMP_SUPPORTED -DPPM_SUPPORTED") - if(WIN32) - set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE) - endif() - if(MINGW) - set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at) - endif() - if(APPLE AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR - CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.4)) - if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) - set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") - endif() - set_target_properties(turbojpeg PROPERTIES MACOSX_RPATH 1) - endif() - set_target_properties(turbojpeg PROPERTIES - SOVERSION ${TURBOJPEG_SO_MAJOR_VERSION} VERSION ${TURBOJPEG_SO_VERSION}) - if(TJMAPFLAG) - set_target_properties(turbojpeg PROPERTIES - LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}") - endif() - endif() - - if(ENABLE_STATIC) - add_library(turbojpeg-static STATIC ${JPEG_SOURCES} $ - ${SIMD_OBJS} turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c - rdppm.c wrbmp.c wrppm.c) - set_property(TARGET turbojpeg-static PROPERTY COMPILE_FLAGS - "-DBMP_SUPPORTED -DPPM_SUPPORTED") - if(NOT MSVC) - set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg) - endif() - endif() -endif() - -if(WIN32) - set(USE_SETMODE "-DUSE_SETMODE") -endif() -if(WITH_12BIT) - set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED ${USE_SETMODE}") -else() - set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}") - set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c) - set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c) -endif() \ No newline at end of file diff --git a/cmake/CMakeLists.png b/cmake/CMakeLists.png deleted file mode 100644 index 2521ab41be..0000000000 --- a/cmake/CMakeLists.png +++ /dev/null @@ -1,741 +0,0 @@ -# CMakeLists.txt - -# Copyright (C) 2018 Cosmin Truta -# Copyright (C) 2007,2009-2018 Glenn Randers-Pehrson -# Written by Christian Ehrlicher, 2007 -# Revised by Roger Lowman, 2009-2010 -# Revised by Clifford Yapp, 2011-2012,2017 -# Revised by Roger Leigh, 2016 -# Revised by Andreas Franek, 2016 -# Revised by Sam Serrels, 2017 -# Revised by Vadim Barkov, 2017 -# Revised by Vicky Pfau, 2018 -# Revised by Cameron Cawley, 2018 -# Revised by Cosmin Truta, 2018 -# Revised by Kyle Bentley, 2018 - -# This code is released under the libpng license. -# For conditions of distribution and use, see the disclaimer -# and license in png.h - -cmake_minimum_required(VERSION 3.10) -cmake_policy(VERSION 3.1) -# When using CMake 3.4 and later, don't export symbols from executables unless -# the CMAKE_ENABLE_EXPORTS variable is set. -if(POLICY CMP0065) - cmake_policy(SET CMP0065 NEW) -endif() -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) - -project(libpng C ASM) -enable_testing() - -set(PNGLIB_MAJOR 1) -set(PNGLIB_MINOR 6) -set(PNGLIB_RELEASE 37) -set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) -set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) - -include(GNUInstallDirs) - -# needed packages - -# Allow users to specify location of Zlib. -# Useful if zlib is being built alongside this as a sub-project. -option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" ON) - -if(NOT PNG_BUILD_ZLIB) - find_package(ZLIB REQUIRED) - include_directories(${ZLIB_INCLUDE_DIR}) -endif() - -if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU) - find_library(M_LIBRARY m) -else() - # libm is not needed and/or not available - set(M_LIBRARY "") -endif() - -# COMMAND LINE OPTIONS -option(PNG_SHARED "Build shared lib" OFF) -option(PNG_STATIC "Build static lib" ON) -option(PNG_TESTS "Build libpng tests" OFF) - -# Many more configuration options could be added here -option(PNG_FRAMEWORK "Build OS X framework" OFF) -option(PNG_DEBUG "Build with debug output" OFF) -option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" OFF) - -set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names") -set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") - -if(PNG_HARDWARE_OPTIMIZATIONS) - -# set definitions and sources for arm -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") - set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) - set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations: - check: (default) use internal checking code; - off: disable the optimizations; - on: turn on unconditionally.") - set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS - ${PNG_ARM_NEON_POSSIBLE_VALUES}) - list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) - if(index EQUAL -1) - message(FATAL_ERROR - "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") - elseif(NOT ${PNG_ARM_NEON} STREQUAL "off") - set(libpng_arm_sources - arm/arm_init.c - arm/filter_neon.S - arm/filter_neon_intrinsics.c - arm/palette_neon_intrinsics.c) - - if(${PNG_ARM_NEON} STREQUAL "on") - add_definitions(-DPNG_ARM_NEON_OPT=2) - elseif(${PNG_ARM_NEON} STREQUAL "check") - add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED) - endif() - else() - add_definitions(-DPNG_ARM_NEON_OPT=0) - endif() -endif() - -# set definitions and sources for powerpc -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*") - set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) - set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations: - off: disable the optimizations.") - set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS - ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) - list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) - if(index EQUAL -1) - message(FATAL_ERROR - "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") - elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off") - set(libpng_powerpc_sources - powerpc/powerpc_init.c - powerpc/filter_vsx_intrinsics.c) - if(${PNG_POWERPC_VSX} STREQUAL "on") - add_definitions(-DPNG_POWERPC_VSX_OPT=2) - endif() - else() - add_definitions(-DPNG_POWERPC_VSX_OPT=0) - endif() -endif() - -# set definitions and sources for intel -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*") - set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) - set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations: - off: disable the optimizations") - set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS - ${PNG_INTEL_SSE_POSSIBLE_VALUES}) - list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) - if(index EQUAL -1) - message(FATAL_ERROR - "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") - elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off") - set(libpng_intel_sources - intel/intel_init.c - intel/filter_sse2_intrinsics.c) - if(${PNG_INTEL_SSE} STREQUAL "on") - add_definitions(-DPNG_INTEL_SSE_OPT=1) - endif() - else() - add_definitions(-DPNG_INTEL_SSE_OPT=0) - endif() -endif() - -# set definitions and sources for MIPS -if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*") - set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) - set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations: - off: disable the optimizations") - set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS - ${PNG_MIPS_MSA_POSSIBLE_VALUES}) - list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index) - if(index EQUAL -1) - message(FATAL_ERROR - "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") - elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off") - set(libpng_mips_sources - mips/mips_init.c - mips/filter_msa_intrinsics.c) - if(${PNG_MIPS_MSA} STREQUAL "on") - add_definitions(-DPNG_MIPS_MSA_OPT=2) - endif() - else() - add_definitions(-DPNG_MIPS_MSA_OPT=0) - endif() -endif() - -else(PNG_HARDWARE_OPTIMIZATIONS) - -# set definitions and sources for arm -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") - add_definitions(-DPNG_ARM_NEON_OPT=0) -endif() - -# set definitions and sources for powerpc -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*") - add_definitions(-DPNG_POWERPC_VSX_OPT=0) -endif() - -# set definitions and sources for intel -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*") - add_definitions(-DPNG_INTEL_SSE_OPT=0) -endif() - -# set definitions and sources for MIPS -if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*") - add_definitions(-DPNG_MIPS_MSA_OPT=0) -endif() - -endif(PNG_HARDWARE_OPTIMIZATIONS) - -# SET LIBNAME -set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) - -# to distinguish between debug and release lib -set(CMAKE_DEBUG_POSTFIX "d") - -include(CheckCSourceCompiles) -option(ld-version-script "Enable linker version script" ON) -if(ld-version-script AND NOT APPLE) - # Check if LD supports linker scripts. - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { - global: sym; - local: *; -}; - -VERS_2 { - global: sym2; - main; -} VERS_1; -") - set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") - check_c_source_compiles("void sym(void) {} -void sym2(void) {} -int main(void) {return 0;} -" HAVE_LD_VERSION_SCRIPT) - if(NOT HAVE_LD_VERSION_SCRIPT) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") - check_c_source_compiles("void sym(void) {} -void sym2(void) {} -int main(void) {return 0;} -" HAVE_SOLARIS_LD_VERSION_SCRIPT) - endif() - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") -endif() - -# Find symbol prefix. Likely obsolete and unnecessary with recent -# toolchains (it's not done in many other projects). -function(symbol_prefix) - set(SYMBOL_PREFIX) - - execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-" - INPUT_FILE /dev/null - OUTPUT_VARIABLE OUT - RESULT_VARIABLE STATUS) - - if(CPP_FAIL) - message(WARNING "Failed to run the C preprocessor") - endif() - - string(REPLACE "\n" ";" OUT "${OUT}") - foreach(line ${OUT}) - string(REGEX MATCH "^PREFIX=" found_match "${line}") - if(found_match) - string(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}") - string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}") - if(found_match) - string(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}") - endif() - set(SYMBOL_PREFIX "${prefix}") - endif() - endforeach() - - message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}") - set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE) -endfunction() - -if(UNIX) - symbol_prefix() -endif() - -find_program(AWK NAMES gawk awk) - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -if(NOT AWK OR ANDROID) - # No awk available to generate sources; use pre-built pnglibconf.h - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt - ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) - add_custom_target(genfiles) # Dummy -else() - include(CMakeParseArguments) - # Generate .chk from .out with awk - # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) - function(generate_chk) - set(options) - set(oneValueArgs INPUT OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GC_INPUT) - message(FATAL_ERROR "generate_chk: Missing INPUT argument") - endif() - if(NOT _GC_OUTPUT) - message(FATAL_ERROR "generate_chk: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${_GC_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DINPUT=${_GC_INPUT}" - "-DOUTPUT=${_GC_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake" - DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Generate .out from .c with awk - # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) - function(generate_out) - set(options) - set(oneValueArgs INPUT OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GO_INPUT) - message(FATAL_ERROR "generate_out: Missing INPUT argument") - endif() - if(NOT _GO_OUTPUT) - message(FATAL_ERROR "generate_out: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${_GO_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DINPUT=${_GO_INPUT}" - "-DOUTPUT=${_GO_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake" - DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Generate specific source file with awk - # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]]) - function(generate_source) - set(options) - set(oneValueArgs OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GSO_OUTPUT) - message(FATAL_ERROR "generate_source: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DOUTPUT=${_GSO_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" - DEPENDS ${_GSO_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Copy file - function(generate_copy source destination) - add_custom_command(OUTPUT "${destination}" - COMMAND "${CMAKE_COMMAND}" -E remove "${destination}" - COMMAND "${CMAKE_COMMAND}" -E copy "${source}" - "${destination}" - DEPENDS "${source}") - endfunction() - - # Generate scripts/pnglibconf.h - generate_source(OUTPUT "scripts/pnglibconf.c" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") - - # Generate pnglibconf.c - generate_source(OUTPUT "pnglibconf.c" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") - - if(PNG_PREFIX) - set(PNGLIBCONF_H_EXTRA_DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst") - set(PNGPREFIX_H_EXTRA_DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") - endif() - - generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") - - # Generate pnglibconf.h - generate_source(OUTPUT "pnglibconf.h" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" - ${PNGLIBCONF_H_EXTRA_DEPENDS}) - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") - - # Generate pngprefix.h - generate_source(OUTPUT "pngprefix.h" - DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS}) - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") - - generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def") - - add_custom_target(symbol-check DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk") - - generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" - "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") - generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" - "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") - - add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") - add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") - - add_custom_target("genprebuilt" - COMMAND "${CMAKE_COMMAND}" - "-DOUTPUT=scripts/pnglibconf.h.prebuilt" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - - # A single target handles generation of all generated files. If - # they are depended upon separately by multiple targets, this - # confuses parallel make (it would require a separate top-level - # target for each file to track the dependencies properly). - add_custom_target(genfiles DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" - "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" - "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") -endif(NOT AWK OR ANDROID) - -# OUR SOURCES -set(libpng_public_hdrs - png.h - pngconf.h - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" -) -set(libpng_private_hdrs - pngpriv.h - pngdebug.h - pnginfo.h - pngstruct.h -) -if(AWK AND NOT ANDROID) - list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") -endif() -set(libpng_sources - ${libpng_public_hdrs} - ${libpng_private_hdrs} - png.c - pngerror.c - pngget.c - pngmem.c - pngpread.c - pngread.c - pngrio.c - pngrtran.c - pngrutil.c - pngset.c - pngtrans.c - pngwio.c - pngwrite.c - pngwtran.c - pngwutil.c - ${libpng_arm_sources} - ${libpng_intel_sources} - ${libpng_mips_sources} - ${libpng_powerpc_sources} -) -set(pngtest_sources - pngtest.c -) -set(pngvalid_sources - contrib/libtests/pngvalid.c -) -set(pngstest_sources - contrib/libtests/pngstest.c -) -set(pngunknown_sources - contrib/libtests/pngunknown.c -) -set(pngimage_sources - contrib/libtests/pngimage.c -) -set(pngfix_sources - contrib/tools/pngfix.c -) -set(png_fix_itxt_sources - contrib/tools/png-fix-itxt.c -) - -if(MSVC) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) -endif() - -if(PNG_DEBUG) - add_definitions(-DPNG_DEBUG) -endif() - -# NOW BUILD OUR TARGET -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) - -unset(PNG_LIB_TARGETS) - -if(PNG_STATIC) - # does not work without changing name - set(PNG_LIB_NAME_STATIC png_static) - add_library(png_static STATIC ${libpng_sources}) - add_dependencies(png_static genfiles) - # MSVC doesn't use a different file extension for shared vs. static - # libs. We are able to change OUTPUT_NAME to remove the _static - # for all other platforms. - if(NOT MSVC) - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}" - CLEAN_DIRECT_OUTPUT 1) - else() - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}_static" - CLEAN_DIRECT_OUTPUT 1) - endif() - list(APPEND PNG_LIB_TARGETS png_static) - if(MSVC) - # msvc does not append 'lib' - do it here to have consistent name - set_target_properties(png_static PROPERTIES PREFIX "lib") - endif() - target_link_libraries(png_static ${M_LIBRARY}) -endif() - -if(NOT PNG_LIB_TARGETS) - message(SEND_ERROR - "No library variant selected to build. " - "Please enable at least one of the following options: " - "PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK") -endif() - -# Set a variable with CMake code which: -# Creates a symlink from src to dest (if possible) or alternatively -# copies if different. -include(CMakeParseArguments) - -function(create_symlink DEST_FILE) - - cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN}) - - if(NOT S_TARGET AND NOT S_FILE) - message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument") - endif() - - if(S_TARGET AND S_FILE) - message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.") - endif() - - if(S_FILE) - # If we don't need to symlink something that's coming from a build target, - # we can go ahead and symlink/copy at configure time. - if(CMAKE_HOST_WIN32 AND NOT CYGWIN) - execute_process( - COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - else() - execute_process( - COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endif() - endif() - - if(S_TARGET) - # We need to use generator expressions, which can be a bit tricky, so for - # simplicity make the symlink a POST_BUILD step and use the TARGET - # signature of add_custom_command. - if(CMAKE_HOST_WIN32 AND NOT CYGWIN) - add_custom_command(TARGET ${S_TARGET} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy_if_different $ $/${DEST_FILE}) - else() - add_custom_command(TARGET ${S_TARGET} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E create_symlink $ $/${DEST_FILE}) - endif() - endif() - -endfunction() - -# Create source generation scripts. -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY) - -# libpng is a library so default to 'lib' -if(NOT DEFINED CMAKE_INSTALL_LIBDIR) - set(CMAKE_INSTALL_LIBDIR lib) -endif() - -# CREATE PKGCONFIG FILES -# We use the same files like ./configure, so we have to set its vars. -# Only do this on Windows for Cygwin - the files don't make much sense outside -# of a UNIX look-alike. -if(NOT WIN32 OR CYGWIN OR MINGW) - set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix ${CMAKE_INSTALL_PREFIX}) - set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) - set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) - set(LIBS "-lz -lm") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY) - create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc) - - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in - ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY) - create_symlink(libpng-config FILE ${PNGLIB_NAME}-config) -endif() - -# SET UP LINKS -if(PNG_SHARED) - set_target_properties(png PROPERTIES -# VERSION 16.${PNGLIB_RELEASE}.1.6.37 - VERSION 16.${PNGLIB_RELEASE}.0 - SOVERSION 16 - CLEAN_DIRECT_OUTPUT 1) -endif() - -# INSTALL -if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) - install(TARGETS ${PNG_LIB_TARGETS} - EXPORT libpng - RUNTIME DESTINATION bin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) - - if(PNG_SHARED) - # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin - if(CYGWIN OR MINGW) - create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png) - install(FILES $/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - - if(NOT WIN32) - create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png) - install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - endif() - - if(PNG_STATIC) - if(NOT WIN32 OR CYGWIN OR MINGW) - create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static) - install(FILES $/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - endif() -endif() - -if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) - install(FILES ${libpng_public_hdrs} DESTINATION include) - install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME}) -endif() -if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL) - if(NOT WIN32 OR CYGWIN OR MINGW) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) - endif() -endif() - -if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL) - install(TARGETS ${PNG_BIN_TARGETS} - RUNTIME DESTINATION bin) -endif() - -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) - # Install man pages - if(NOT PNG_MAN_DIR) - set(PNG_MAN_DIR "share/man") - endif() - install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3) - install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5) - # Install pkg-config files - if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config - DESTINATION bin) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config - DESTINATION bin) - endif() -endif() - -# Create an export file that CMake users can include() to import our targets. -if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) - install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake) -endif() - -# what's with libpng-manual.txt and all the extra files? - -# UNINSTALL -# do we need this? - -# DIST -# do we need this? - -# to create msvc import lib for mingw compiled shared lib -# pexports libpng.dll > libpng.def -# lib /def:libpng.def /machine:x86 diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 88b7ec422e..f7e9b314bd 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,8 +1,8 @@ +# -*- CMake -*- master configuration file for building LAMMPS ######################################## # CMake build system # This file is part of LAMMPS -# Created by Christoph Junghans and Richard Berger -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) ######################################## # set policy to silence warnings about ignoring _ROOT but use it if(POLICY CMP0074) @@ -12,22 +12,11 @@ endif() if(POLICY CMP0075) cmake_policy(SET CMP0075 NEW) endif() -# set policy to silence warnings about missing executable permissions in -# pythonx.y-config when cross-compiling. review occasionally if it may be set to NEW -if(POLICY CMP0109) - cmake_policy(SET CMP0109 OLD) -endif() # set policy to silence warnings about timestamps of downloaded files. review occasionally if it may be set to NEW if(POLICY CMP0135) cmake_policy(SET CMP0135 OLD) endif() -######################################## -# Use CONFIGURE_DEPENDS as option for file(GLOB...) when available -if(CMAKE_VERSION VERSION_LESS 3.12) - unset(CONFIGURE_DEPENDS) -else() - set(CONFIGURE_DEPENDS CONFIGURE_DEPENDS) -endif() + ######################################## project(lammps CXX) @@ -116,7 +105,7 @@ 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_TUNE_DEFAULT "-xCOMMON-AVX512") else() - set(CMAKE_TUNE_DEFAULT "-xHost -fp-model fast=2 -no-prec-div -qoverride-limits -diag-disable=10441 -diag-disable=2196") + set(CMAKE_TUNE_DEFAULT "-xHost -fp-model fast=2 -no-prec-div -qoverride-limits -diag-disable=10441 -diag-disable=11074 -diag-disable=11076 -diag-disable=2196") endif() endif() endif() @@ -136,15 +125,15 @@ if((PKG_KOKKOS) AND (Kokkos_ENABLE_CUDA) AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL set(CMAKE_TUNE_DEFAULT "${CMAKE_TUNE_DEFAULT} -Xcudafe --diag_suppress=unrecognized_pragma") endif() -# we require C++11 without extensions. Kokkos requires at least C++14 (currently) +# we require C++11 without extensions. Kokkos requires at least C++17 (currently) if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) endif() if(CMAKE_CXX_STANDARD LESS 11) message(FATAL_ERROR "C++ standard must be set to at least 11") endif() -if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 14)) - set(CMAKE_CXX_STANDARD 14) +if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 17)) + set(CMAKE_CXX_STANDARD 17) endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Use compiler extensions") @@ -155,6 +144,7 @@ if(MSVC) add_compile_options(/Zc:__cplusplus) add_compile_options(/wd4244) add_compile_options(/wd4267) + add_compile_options(/wd4250) add_compile_options(/EHsc) endif() add_compile_definitions(_CRT_SECURE_NO_WARNINGS) @@ -168,17 +158,20 @@ endif() ######################################################################## # User input options # ######################################################################## -# set path to python interpreter and thus enforcing python version when -# in a virtual environment and PYTHON_EXECUTABLE is not set on command line -if(DEFINED ENV{VIRTUAL_ENV} AND NOT PYTHON_EXECUTABLE) - if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - set(PYTHON_EXECUTABLE "$ENV{VIRTUAL_ENV}/Scripts/python.exe") - else() - set(PYTHON_EXECUTABLE "$ENV{VIRTUAL_ENV}/bin/python") - endif() +# backward compatibility with CMake before 3.12 and older LAMMPS documentation +if (PYTHON_EXECUTABLE) set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") +endif() +# set path to python interpreter and thus enforcing python version when +# in a virtual environment and Python_EXECUTABLE is not set on command line +if(DEFINED ENV{VIRTUAL_ENV} AND NOT Python_EXECUTABLE) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(Python_EXECUTABLE "$ENV{VIRTUAL_ENV}/Scripts/python.exe") + else() + set(Python_EXECUTABLE "$ENV{VIRTUAL_ENV}/bin/python") + endif() message(STATUS "Running in virtual environment: $ENV{VIRTUAL_ENV}\n" - " Setting Python interpreter to: ${PYTHON_EXECUTABLE}") + " Setting Python interpreter to: ${Python_EXECUTABLE}") endif() set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary (WON'T enable any features automatically") @@ -192,6 +185,7 @@ option(BUILD_SHARED_LIBS "Build shared library" OFF) option(CMAKE_POSITION_INDEPENDENT_CODE "Create object compatible with shared libraries" ON) option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF) option(BUILD_LAMMPS_SHELL "Build and install the LAMMPS shell" OFF) +option(BUILD_LAMMPS_GUI "Build and install the LAMMPS GUI" OFF) # Support using clang-tidy for C++ files with selected options set(ENABLE_CLANG_TIDY OFF CACHE BOOL "Include clang-tidy processing when compiling") @@ -202,8 +196,8 @@ else() endif() include(GNUInstallDirs) -file(GLOB ALL_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) -file(GLOB MAIN_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/main.cpp) +file(GLOB ALL_SOURCES CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) +file(GLOB MAIN_SOURCES CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/main.cpp) list(REMOVE_ITEM ALL_SOURCES ${MAIN_SOURCES}) add_library(lammps ${ALL_SOURCES}) @@ -277,8 +271,6 @@ set(STANDARD_PACKAGES MOFFF MOLECULE MOLFILE - MPIIO - MSCG NETCDF ORIENT PERI @@ -384,15 +376,9 @@ if(NOT ${LAMMPS_MEMALIGN} STREQUAL "0") 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)" ${ENABLE_TESTING}) -if(LAMMPS_EXCEPTIONS) - target_compile_definitions(lammps PUBLIC -DLAMMPS_EXCEPTIONS) -endif() - # "hard" dependencies between packages resulting # in an error instead of skipping over files pkg_depends(ML-IAP ML-SNAP) -pkg_depends(MPIIO MPI) pkg_depends(ATC MANYBODY) pkg_depends(LATBOLTZ MPI) pkg_depends(SCAFACOS MPI) @@ -403,6 +389,7 @@ pkg_depends(CG-DNA MOLECULE) pkg_depends(CG-DNA ASPHERE) pkg_depends(ELECTRODE KSPACE) pkg_depends(EXTRA-MOLECULE MOLECULE) +pkg_depends(MESONT MOLECULE) # detect if we may enable OpenMP support by default set(BUILD_OMP_DEFAULT OFF) @@ -440,14 +427,26 @@ if(BUILD_OMP) target_link_libraries(lmp PRIVATE OpenMP::OpenMP_CXX) endif() -if(PKG_MSCG OR PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_ML-POD OR PKG_ELECTRODE OR BUILD_TOOLS) +# lower C++ standard for fmtlib sources when using Intel classic compiler +if((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_STANDARD GREATER_EQUAL 17) + AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2021.10)) + message(STATUS "Lowering C++ standard for compiling fmtlib sources with Intel Classic compiler") + get_filename_component(LMP_UTILS_SRC "${LAMMPS_SOURCE_DIR}/utils.cpp" ABSOLUTE) + get_filename_component(LMP_VARIABLE_SRC "${LAMMPS_SOURCE_DIR}/variable.cpp" ABSOLUTE) + get_filename_component(FMT_FORMAT_SRC "${LAMMPS_SOURCE_DIR}/fmtlib_format.cpp" ABSOLUTE) + get_filename_component(FMT_OS_SRC "${LAMMPS_SOURCE_DIR}/fmtlib_os.cpp" ABSOLUTE) + set_source_files_properties("${FMT_FORMAT_SRC}" "${FMT_OS_SRC}" "${LMP_VARIABLE_SRC}" "${LMP_UTILS_SRC}" + PROPERTIES COMPILE_OPTIONS "-std=c++14") +endif() + +if(PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_ML-POD OR PKG_ELECTRODE OR BUILD_TOOLS) enable_language(C) if (NOT USE_INTERNAL_LINALG) find_package(LAPACK) find_package(BLAS) endif() if(NOT LAPACK_FOUND OR NOT BLAS_FOUND OR USE_INTERNAL_LINALG) - file(GLOB LINALG_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.cpp) + file(GLOB LINALG_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.cpp) add_library(linalg STATIC ${LINALG_SOURCES}) set_target_properties(linalg PROPERTIES OUTPUT_NAME lammps_linalg${LAMMPS_MACHINE}) set(BLAS_LIBRARIES "$") @@ -465,12 +464,7 @@ option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND}) if(WITH_JPEG) find_package(JPEG REQUIRED) target_compile_definitions(lammps PRIVATE -DLAMMPS_JPEG) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(lammps PRIVATE ${JPEG_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${JPEG_LIBRARIES}) - else() - target_link_libraries(lammps PRIVATE JPEG::JPEG) - endif() + target_link_libraries(lammps PRIVATE JPEG::JPEG) endif() find_package(PNG QUIET) @@ -520,7 +514,7 @@ else() endif() foreach(PKG_WITH_INCL KSPACE PYTHON ML-IAP VORONOI COLVARS ML-HDNNP MDI MOLFILE NETCDF - PLUMED QMMM ML-QUIP SCAFACOS MACHDYN VTK KIM MSCG COMPRESS ML-PACE LEPTON) + PLUMED QMMM ML-QUIP SCAFACOS MACHDYN VTK KIM COMPRESS ML-PACE LEPTON) if(PKG_${PKG_WITH_INCL}) include(Packages/${PKG_WITH_INCL}) endif() @@ -582,8 +576,8 @@ endforeach() foreach(PKG ${STANDARD_PACKAGES}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) - file(GLOB ${PKG}_SOURCES ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.cpp) - file(GLOB ${PKG}_HEADERS ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.h) + file(GLOB ${PKG}_SOURCES CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.cpp) + file(GLOB ${PKG}_HEADERS CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.h) # check for package files in src directory due to old make system DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) @@ -599,19 +593,12 @@ foreach(PKG ${STANDARD_PACKAGES}) RegisterPackages(${${PKG}_SOURCES_DIR}) endforeach() -# packages that need defines set -foreach(PKG MPIIO) - if(PKG_${PKG}) - target_compile_definitions(lammps PRIVATE -DLMP_${PKG}) - endif() -endforeach() - # dedicated check for entire contents of accelerator packages foreach(PKG ${SUFFIX_PACKAGES}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) - file(GLOB ${PKG}_SOURCES ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.cpp) - file(GLOB ${PKG}_HEADERS ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.h) + file(GLOB ${PKG}_SOURCES CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.cpp) + file(GLOB ${PKG}_HEADERS CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.h) # check for package files in src directory due to old make system DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) @@ -625,7 +612,7 @@ endforeach() foreach(PKG_LIB POEMS ATC AWPMD H5MD) if(PKG_${PKG_LIB}) string(TOLOWER "${PKG_LIB}" PKG_LIB) - file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${CONFIGURE_DEPENDS} + file(GLOB_RECURSE ${PKG_LIB}_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp) add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_MACHINE}) @@ -795,9 +782,11 @@ include(Tools) include(Documentation) ############################################################################### -# Install potential and force field files in data directory +# Install bench, potential and force field files in data directory ############################################################################### -set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps) +set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/lammps) + +install(DIRECTORY ${LAMMPS_DIR}/bench DESTINATION ${LAMMPS_INSTALL_DATADIR}) install(DIRECTORY ${LAMMPS_POTENTIALS_DIR} DESTINATION ${LAMMPS_INSTALL_DATADIR}) if(BUILD_TOOLS) install(DIRECTORY ${LAMMPS_TOOLS_DIR}/msi2lmp/frc_files DESTINATION ${LAMMPS_INSTALL_DATADIR}) @@ -818,20 +807,8 @@ install( # This is primarily for people that only want to use the Python wrapper. ############################################################################### if(BUILD_SHARED_LIBS) - if(CMAKE_VERSION VERSION_LESS 3.12) - # adjust so we find Python 3 versions before Python 2 on old systems with old CMake - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - else() - # backward compatibility - if(PYTHON_EXECUTABLE) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - find_package(Python COMPONENTS Interpreter) - endif() + # backward compatibility + find_package(Python COMPONENTS Interpreter) if(BUILD_IS_MULTI_CONFIG) set(MY_BUILD_DIR ${CMAKE_BINARY_DIR}/$) else() @@ -890,13 +867,23 @@ else() endif() include(FeatureSummary) feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND) +if(GIT_FOUND AND EXISTS ${LAMMPS_DIR}/.git) + execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty=-modified --always + OUTPUT_VARIABLE GIT_DESCRIBE + ERROR_QUIET + WORKING_DIRECTORY ${LAMMPS_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() message(STATUS "<<< Build configuration >>> - LAMMPS Version: ${PROJECT_VERSION} + LAMMPS Version: ${PROJECT_VERSION} ${GIT_DESCRIBE} Operating System: ${CMAKE_SYSTEM_NAME} ${CMAKE_LINUX_DISTRO} ${CMAKE_DISTRO_VERSION} CMake Version: ${CMAKE_VERSION} Build type: ${LAMMPS_BUILD_TYPE} Install path: ${CMAKE_INSTALL_PREFIX} Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}") +if(CMAKE_CROSSCOMPILING) + message(STATUS "Cross compiling on ${CMAKE_HOST_SYSTEM}") +endif() ############################################################################### # Print package summary ############################################################################### @@ -940,11 +927,9 @@ if(_index GREATER -1) endif() message(STATUS "<<< Linker flags: >>>") message(STATUS "Executable name: ${LAMMPS_BINARY}") -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - get_target_property(OPTIONS lammps LINK_OPTIONS) - if(OPTIONS) - message(STATUS "Linker options: ${OPTIONS}") - endif() +get_target_property(OPTIONS lammps LINK_OPTIONS) +if(OPTIONS) + message(STATUS "Linker options: ${OPTIONS}") endif() if(CMAKE_EXE_LINKER_FLAGS) message(STATUS "Executable linker flags: ${CMAKE_EXE_LINKER_FLAGS}") @@ -986,33 +971,53 @@ if(PKG_KOKKOS) endif() endif() if(PKG_KSPACE) - 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() - elseif(Kokkos_ENABLE_HIP) - if(FFT STREQUAL "KISS") - message(STATUS "Kokkos FFT: KISS") - else() - message(STATUS "Kokkos FFT: hipFFT") - endif() + if (LMP_HEFFTE) + message(STATUS "<<< FFT settings >>> +-- Primary FFT lib: heFFTe") + if (HEFFTE_BACKEND) + message(STATUS "heFFTe backend: ${HEFFTE_BACKEND}") else() - message(STATUS "Kokkos FFT: ${FFT}") + message(STATUS "heFFTe backend: stock (builtin FFT implementation, tested for corrected but not optimized for production)") + endif() + if(FFT_SINGLE) + message(STATUS "Using single precision FFTs") + else() + message(STATUS "Using double precision FFTs") + endif() + else() + 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 (FFT_HEFFTE) + message(STATUS "Using distributed algorithms from heFTTe") + else() + message(STATUS "Using builtin distributed algorithms") + endif() + if(PKG_KOKKOS) + if(Kokkos_ENABLE_CUDA) + if(FFT STREQUAL "KISS") + message(STATUS "Kokkos FFT: KISS") + else() + message(STATUS "Kokkos FFT: cuFFT") + endif() + elseif(Kokkos_ENABLE_HIP) + if(FFT STREQUAL "KISS") + message(STATUS "Kokkos FFT: KISS") + else() + message(STATUS "Kokkos FFT: hipFFT") + endif() + else() + message(STATUS "Kokkos FFT: ${FFT}") + endif() endif() endif() endif() @@ -1025,6 +1030,14 @@ endif() if(BUILD_LAMMPS_SHELL) message(STATUS "<<< Building LAMMPS Shell >>>") endif() +if(BUILD_LAMMPS_GUI) + message(STATUS "<<< Building LAMMPS GUI >>>") + if(LAMMPS_GUI_USE_PLUGIN) + message(STATUS "Loading LAMMPS library as plugin at run time") + else() + message(STATUS "Linking LAMMPS library at compile time") + endif() +endif() if(ENABLE_TESTING) message(STATUS "<<< Building Unit Tests >>>") if(ENABLE_COVERAGE) diff --git a/cmake/CMakeLists.zlib b/cmake/CMakeLists.zlib deleted file mode 100644 index a33f14ce64..0000000000 --- a/cmake/CMakeLists.zlib +++ /dev/null @@ -1,195 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -# When using CMake 3.4 and later, don't export symbols from executables unless -# the CMAKE_ENABLE_EXPORTS variable is set. -if(POLICY CMP0065) - cmake_policy(SET CMP0065 NEW) -endif() -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) - -project(zlib C) - -set(VERSION "1.2.11") - -option(ASM686 "Enable building i686 assembly implementation" OFF) -option(AMD64 "Enable building amd64 assembly implementation" OFF) - -set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") -set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") -set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") -set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") -set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") - -include(CheckTypeSize) -include(CheckFunctionExists) -include(CheckIncludeFile) -include(CheckCSourceCompiles) - -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(stdint.h HAVE_STDINT_H) -check_include_file(stddef.h HAVE_STDDEF_H) - -# -# Check to see if we have large file support -# -set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) -# We add these other definitions here because CheckTypeSize.cmake -# in CMake 2.4.x does not automatically do so and we want -# compatibility with CMake 2.4.x. -if(HAVE_SYS_TYPES_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) -endif() -if(HAVE_STDINT_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) -endif() -if(HAVE_STDDEF_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) -endif() -check_type_size(off64_t OFF64_T) -check_type_size(off64_t OFF64_T) -if(HAVE_OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1) -endif() -set(CMAKE_REQUIRED_DEFINITIONS) # clear variable - -# -# Check for fseeko -# -check_function_exists(fseeko HAVE_FSEEKO) -if(NOT HAVE_FSEEKO) - add_definitions(-DNO_FSEEKO) -endif() - -# -# Check for unistd.h -# -check_include_file(unistd.h Z_HAVE_UNISTD_H) - -if(MSVC) - set(CMAKE_DEBUG_POSTFIX "d") - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -endif() - -if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) - # If we're doing an out of source build and the user has a zconf.h - # in their source tree... - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) - file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included) - endif() -endif() - -set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein - ${ZLIB_PC} @ONLY) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) - - -#============================================================================ -# zlib -#============================================================================ - -set(ZLIB_PUBLIC_HDRS - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h - zlib.h -) -set(ZLIB_PRIVATE_HDRS - crc32.h - deflate.h - gzguts.h - inffast.h - inffixed.h - inflate.h - inftrees.h - trees.h - zutil.h -) -set(ZLIB_SRCS - adler32.c - compress.c - crc32.c - deflate.c - gzclose.c - gzlib.c - gzread.c - gzwrite.c - inflate.c - infback.c - inftrees.c - inffast.c - trees.c - uncompr.c - zutil.c -) - -if(NOT MINGW) - set(ZLIB_DLL_SRCS - win32/zlib1.rc # If present will override custom build rule below. - ) -endif() - -if(CMAKE_COMPILER_IS_GNUCC) - if(ASM686) - set(ZLIB_ASMS contrib/asm686/match.S) - elseif (AMD64) - set(ZLIB_ASMS contrib/amd64/amd64-match.S) - endif () - - if(ZLIB_ASMS) - add_definitions(-DASMV) - set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) - endif() -endif() - -if(MSVC) - if(ASM686) - ENABLE_LANGUAGE(ASM_MASM) - set(ZLIB_ASMS - contrib/masmx86/inffas32.asm - contrib/masmx86/match686.asm - ) - elseif (AMD64) - ENABLE_LANGUAGE(ASM_MASM) - set(ZLIB_ASMS - contrib/masmx64/gvmat64.asm - contrib/masmx64/inffasx64.asm - ) - endif() - - if(ZLIB_ASMS) - add_definitions(-DASMV -DASMINF) - endif() -endif() - -# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) -string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" - "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) - -if(MINGW) - # This gets us DLL resource information when compiling on MinGW. - if(NOT CMAKE_RC_COMPILER) - set(CMAKE_RC_COMPILER windres.exe) - endif() - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - COMMAND ${CMAKE_RC_COMPILER} - -D GCC_WINDRES - -I ${CMAKE_CURRENT_SOURCE_DIR} - -I ${CMAKE_CURRENT_BINARY_DIR} - -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) - set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) -endif(MINGW) - -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) - -if(UNIX) - # On unix-like platforms the library is almost always called libz - set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z) -endif() \ No newline at end of file diff --git a/cmake/CMakeSettings.json b/cmake/CMakeSettings.json index 205b443bf1..c880962535 100644 --- a/cmake/CMakeSettings.json +++ b/cmake/CMakeSettings.json @@ -63,6 +63,11 @@ "name": "ENABLE_TESTING", "value": "True", "type": "BOOL" + }, + { + "name": "BUILD_LAMMPS_GUI", + "value": "False", + "type": "BOOL" } ] }, @@ -303,6 +308,54 @@ "type": "STRING" } ] + }, + { + "name": "x64-GUI-MSVC", + "generator": "Ninja", + "configurationType": "Release", + "buildRoot": "${workspaceRoot}\\build\\${name}", + "installRoot": "${workspaceRoot}\\install\\${name}", + "cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows.cmake -D QT_DIR=C:\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake\\Qt5 -D Qt5_DIR=C:\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake\\Qt5", + "buildCommandArgs": "", + "ctestCommandArgs": "-V", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [ + { + "name": "BUILD_SHARED_LIBS", + "value": "True", + "type": "BOOL" + }, + { + "name": "BUILD_TOOLS", + "value": "True", + "type": "BOOL" + }, + { + "name": "LAMMPS_EXCEPTIONS", + "value": "True", + "type": "BOOL" + }, + { + "name": "ENABLE_TESTING", + "value": "False", + "type": "BOOL" + }, + { + "name": "BUILD_MPI", + "value": "False", + "type": "BOOL" + }, + { + "name": "WITH_PNG", + "value": "False", + "type": "BOOL" + }, + { + "name": "BUILD_LAMMPS_GUI", + "value": "True", + "type": "BOOL" + } + ] } ] } \ No newline at end of file diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 4efd373d22..94639c7771 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -1,19 +1,11 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.5 QUIET) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) - set(Python3_VERSION ${PYTHON_VERSION_STRING}) - endif() -else() - # use default (or custom) Python executable, if version is sufficient - if(Python_VERSION VERSION_GREATER_EQUAL 3.5) - set(Python3_EXECUTABLE ${Python_EXECUTABLE}) - endif() - find_package(Python3 COMPONENTS Interpreter QUIET) +# use default (or custom) Python executable, if version is sufficient +if(Python_VERSION VERSION_GREATER_EQUAL 3.6) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) endif() +find_package(Python3 COMPONENTS Interpreter) if(Python3_EXECUTABLE) - if(Python3_VERSION VERSION_GREATER_EQUAL 3.5) + if(Python3_VERSION VERSION_GREATER_EQUAL 3.6) add_custom_target( check-whitespace ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/whitespace.py . diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake index 0b01407cd9..400109067f 100644 --- a/cmake/Modules/Documentation.cmake +++ b/cmake/Modules/Documentation.cmake @@ -5,24 +5,18 @@ option(BUILD_DOC "Build LAMMPS HTML documentation" OFF) if(BUILD_DOC) # Current Sphinx versions require at least Python 3.8 - if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.8 REQUIRED) - set(VIRTUALENV ${PYTHON_EXECUTABLE} -m venv) - else() - # use default (or custom) Python executable, if version is sufficient - if(Python_VERSION VERSION_GREATER_EQUAL 3.8) - set(Python3_EXECUTABLE ${Python_EXECUTABLE}) - endif() - find_package(Python3 REQUIRED COMPONENTS Interpreter) - if(Python3_VERSION VERSION_LESS 3.8) - message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") - endif() - set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) + # use default (or custom) Python executable, if version is sufficient + if(Python_VERSION VERSION_GREATER_EQUAL 3.8) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter) + if(Python3_VERSION VERSION_LESS 3.8) + message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") + endif() + set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) + find_package(Doxygen 1.8.10 REQUIRED) - - file(GLOB DOC_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_DOC_DIR}/src/[^.]*.rst) - + file(GLOB DOC_SOURCES CONFIGURE_DEPENDS ${LAMMPS_DOC_DIR}/src/[^.]*.rst) add_custom_command( OUTPUT docenv @@ -80,7 +74,7 @@ if(BUILD_DOC) message(STATUS "Using already downloaded archive ${CMAKE_BINARY_DIR}/libpace.tar.gz") endif() execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf mathjax.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - file(GLOB MATHJAX_VERSION_DIR ${CONFIGURE_DEPENDS} ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*) + file(GLOB MATHJAX_VERSION_DIR CONFIGURE_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*) execute_process(COMMAND ${CMAKE_COMMAND} -E rename ${MATHJAX_VERSION_DIR} ${DOC_BUILD_STATIC_DIR}/mathjax) endif() diff --git a/cmake/Modules/FindClangFormat.cmake b/cmake/Modules/FindClangFormat.cmake index 80c3b0d0ae..3f0257f34f 100644 --- a/cmake/Modules/FindClangFormat.cmake +++ b/cmake/Modules/FindClangFormat.cmake @@ -1,5 +1,7 @@ # Find clang-format find_program(ClangFormat_EXECUTABLE NAMES clang-format + clang-format-17.0 + clang-format-16.0 clang-format-15.0 clang-format-14.0 clang-format-13.0 @@ -19,7 +21,7 @@ if(ClangFormat_EXECUTABLE) OUTPUT_VARIABLE clang_format_version ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(clang_format_version MATCHES "^(Ubuntu |)clang-format version .*") + if(clang_format_version MATCHES "^(Ubuntu |Debian |)clang-format version .*") # Arch Linux output: # clang-format version 10.0.0 # @@ -32,9 +34,15 @@ if(ClangFormat_EXECUTABLE) # Ubuntu 22.04 LTS output: # Ubuntu clang-format version 14.0.0-1ubuntu1 # + # Debian 11 output: + # Debian clang-format version 11.0.1-2 + # + # Debian 12 output: + # Debian clang-format version 14.0.6 + # # Fedora 36 output: # clang-format version 14.0.5 (Fedora 14.0.5-1.fc36) - string(REGEX REPLACE "^(Ubuntu |)clang-format version ([0-9.]+).*" + string(REGEX REPLACE "^(Ubuntu |Debian |)clang-format version ([0-9.]+).*" "\\2" ClangFormat_VERSION "${clang_format_version}") diff --git a/cmake/Modules/FindCythonize.cmake b/cmake/Modules/FindCythonize.cmake index 97f0304279..fe436aef28 100644 --- a/cmake/Modules/FindCythonize.cmake +++ b/cmake/Modules/FindCythonize.cmake @@ -7,15 +7,7 @@ # adapted from https://github.com/cmarshall108/cython-cmake-example/blob/master/cmake/FindCython.cmake #============================================================================= -if(CMAKE_VERSION VERSION_LESS 3.12) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - find_package(PythonInterp 3.6 QUIET) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python 3.6 COMPONENTS Interpreter QUIET) -endif() +find_package(Python 3.6 COMPONENTS Interpreter QUIET) # Use the Cython executable that lives next to the Python executable # if it is a local installation. diff --git a/cmake/Modules/LAMMPSInterfacePlugin.cmake b/cmake/Modules/LAMMPSInterfacePlugin.cmake index c1cc613496..151e0a04f7 100644 --- a/cmake/Modules/LAMMPSInterfacePlugin.cmake +++ b/cmake/Modules/LAMMPSInterfacePlugin.cmake @@ -28,9 +28,8 @@ if(MSVC) add_compile_options(/Zc:__cplusplus) add_compile_options(/wd4244) add_compile_options(/wd4267) - if(LAMMPS_EXCEPTIONS) - add_compile_options(/EHsc) - endif() + add_compile_options(/wd4250) + add_compile_options(/EHsc) endif() add_compile_definitions(_CRT_SECURE_NO_WARNINGS) endif() @@ -65,7 +64,7 @@ endfunction(validate_option) # helper function for getting the most recently modified file or folder from a glob pattern function(get_newest_file path variable) - file(GLOB _dirs ${CONFIGURE_DEPENDS} ${path}) + file(GLOB _dirs CONFIGURE_DEPENDS ${path}) set(_besttime 2000-01-01T00:00:00) set(_bestfile "") foreach(_dir ${_dirs}) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 1ceec7e06e..2ec9d1b706 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -41,7 +41,7 @@ endfunction() # helper function for getting the most recently modified file or folder from a glob pattern function(get_newest_file path variable) - file(GLOB _dirs ${CONFIGURE_DEPENDS} ${path}) + file(GLOB _dirs CONFIGURE_DEPENDS ${path}) set(_besttime 2000-01-01T00:00:00) set(_bestfile "") foreach(_dir ${_dirs}) @@ -80,20 +80,20 @@ endfunction() function(check_for_autogen_files source_dir) message(STATUS "Running check for auto-generated files from make-based build system") - file(GLOB SRC_AUTOGEN_FILES ${CONFIGURE_DEPENDS} ${source_dir}/style_*.h) - file(GLOB SRC_AUTOGEN_PACKAGES ${CONFIGURE_DEPENDS} ${source_dir}/packages_*.h) + file(GLOB SRC_AUTOGEN_FILES CONFIGURE_DEPENDS ${source_dir}/style_*.h) + file(GLOB SRC_AUTOGEN_PACKAGES CONFIGURE_DEPENDS ${source_dir}/packages_*.h) list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/lmpinstalledpkgs.h ${source_dir}/lmpgitversion.h) - list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/mliap_model_python_couple.h ${source_dir}/mliap_model_python_couple.cpp) + list(APPEND SRC_AUTOGEN_FILES ${source_dir}/mliap_model_python_couple.h ${source_dir}/mliap_model_python_couple.cpp) foreach(_SRC ${SRC_AUTOGEN_FILES}) get_filename_component(FILENAME "${_SRC}" NAME) if(EXISTS ${source_dir}/${FILENAME}) message(FATAL_ERROR "\n########################################################################\n" - "Found header file(s) generated by the make-based build system\n" - "\n" - "Please run\n" - "make -C ${source_dir} purge\n" - "to remove\n" - "########################################################################") + "Found header file ${source_dir}/${FILENAME} generated by the make-based build system\n" + "\n" + "Please run\n" + "make -C ${source_dir} purge\n" + "to remove\n" + "########################################################################") endif() endforeach() endfunction() diff --git a/cmake/Modules/Packages/COLVARS.cmake b/cmake/Modules/Packages/COLVARS.cmake index 325e0e205e..745c1de026 100644 --- a/cmake/Modules/Packages/COLVARS.cmake +++ b/cmake/Modules/Packages/COLVARS.cmake @@ -1,6 +1,6 @@ set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars) -file(GLOB COLVARS_SOURCES ${CONFIGURE_DEPENDS} ${COLVARS_SOURCE_DIR}/[^.]*.cpp) +file(GLOB COLVARS_SOURCES CONFIGURE_DEPENDS ${COLVARS_SOURCE_DIR}/[^.]*.cpp) option(COLVARS_DEBUG "Enable debugging messages for Colvars (quite verbose)" OFF) diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index 4a70eb7a1e..4c3288df84 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -39,7 +39,7 @@ if (PKG_AMOEBA) ${GPU_SOURCES_DIR}/amoeba_convolution_gpu.cpp) endif() -file(GLOB GPU_LIB_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp) +file(GLOB GPU_LIB_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp) file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) if(GPU_API STREQUAL "CUDA") @@ -64,11 +64,13 @@ if(GPU_API STREQUAL "CUDA") endif() set(GPU_CUDA_MPS_FLAGS "-DCUDA_MPS_SUPPORT") endif() + option(CUDA_BUILD_MULTIARCH "Enable building CUDA kernels for all supported GPU architectures" ON) + mark_as_advanced(GPU_BUILD_MULTIARCH) set(GPU_ARCH "sm_50" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)") # ensure that no *cubin.h files exist from a compile in the lib/gpu folder - file(GLOB GPU_LIB_OLD_CUBIN_HEADERS ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/*_cubin.h) + file(GLOB GPU_LIB_OLD_CUBIN_HEADERS CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/*_cubin.h) if(GPU_LIB_OLD_CUBIN_HEADERS) message(FATAL_ERROR "########################################################################\n" "Found file(s) generated by the make-based build system in lib/gpu\n" @@ -78,79 +80,81 @@ if(GPU_API STREQUAL "CUDA") "########################################################################") endif() - file(GLOB GPU_LIB_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${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 ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp) - file(GLOB GPU_LIB_CUDPP_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu) + file(GLOB GPU_LIB_CUDPP_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp) + file(GLOB GPU_LIB_CUDPP_CU CONFIGURE_DEPENDS ${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}") - # apply the following to build "fat" CUDA binaries only for known CUDA toolkits since version 8.0 - # only the Kepler achitecture and beyond is supported - # comparison chart according to: https://en.wikipedia.org/wiki/CUDA#GPUs_supported - if(CUDA_VERSION VERSION_LESS 8.0) - message(FATAL_ERROR "CUDA Toolkit version 8.0 or later is required") - elseif(CUDA_VERSION VERSION_GREATER_EQUAL "13.0") - message(WARNING "Untested CUDA Toolkit version ${CUDA_VERSION}. Use at your own risk") - set(GPU_CUDA_GENCODE "-arch=all") - elseif(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") - set(GPU_CUDA_GENCODE "-arch=all") - else() - # Kepler (GPU Arch 3.0) is supported by CUDA 5 to CUDA 10.2 - if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "11.0")) - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_30,code=[sm_30,compute_30] ") - endif() - # Kepler (GPU Arch 3.5) is supported by CUDA 5 to CUDA 11 - if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "12.0")) - string(APPEND GPU_CUDA_GENCODE " -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_EQUAL "6.0") - 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_EQUAL "8.0") - 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_EQUAL "9.0") - 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_EQUAL "10.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_75,code=[sm_75,compute_75]") - endif() - # Ampere (GPU Arch 8.0) is supported by CUDA 11 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") - endif() - # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") - endif() - # Lovelace (GPU Arch 8.9) is supported by CUDA 11.8 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.8") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_90,code=[sm_90,compute_90]") - endif() - # Hopper (GPU Arch 9.0) is supported by CUDA 12.0 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_90,code=[sm_90,compute_90]") + if(CUDA_BUILD_MULTIARCH) + # apply the following to build "fat" CUDA binaries only for known CUDA toolkits since version 8.0 + # only the Kepler achitecture and beyond is supported + # comparison chart according to: https://en.wikipedia.org/wiki/CUDA#GPUs_supported + if(CUDA_VERSION VERSION_LESS 8.0) + message(FATAL_ERROR "CUDA Toolkit version 8.0 or later is required") + elseif(CUDA_VERSION VERSION_GREATER_EQUAL "13.0") + message(WARNING "Untested CUDA Toolkit version ${CUDA_VERSION}. Use at your own risk") + set(GPU_CUDA_GENCODE "-arch=all") + elseif(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") + set(GPU_CUDA_GENCODE "-arch=all") + else() + # Kepler (GPU Arch 3.0) is supported by CUDA 5 to CUDA 10.2 + if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "11.0")) + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_30,code=[sm_30,compute_30] ") + endif() + # Kepler (GPU Arch 3.5) is supported by CUDA 5 to CUDA 11 + if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "12.0")) + string(APPEND GPU_CUDA_GENCODE " -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_EQUAL "6.0") + 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_EQUAL "8.0") + 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_EQUAL "9.0") + 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_EQUAL "10.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_75,code=[sm_75,compute_75]") + endif() + # Ampere (GPU Arch 8.0) is supported by CUDA 11 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") + endif() + # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") + endif() + # Lovelace (GPU Arch 8.9) is supported by CUDA 11.8 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.8") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_90,code=[sm_90,compute_90]") + endif() + # Hopper (GPU Arch 9.0) is supported by CUDA 12.0 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_90,code=[sm_90,compute_90]") + endif() endif() endif() cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS ${CUDA_REQUEST_PIC} - -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES}) + -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -allow-unsupported-compiler -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES}) 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} -DLAMMPS_${LAMMPS_SIZES}) + -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -allow-unsupported-compiler -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES}) foreach(CU_OBJ ${GPU_GEN_OBJS}) get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) @@ -201,7 +205,7 @@ elseif(GPU_API STREQUAL "OPENCL") 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 ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${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 @@ -331,7 +335,7 @@ elseif(GPU_API STREQUAL "HIP") endif() endif() - file(GLOB GPU_LIB_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${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 "") diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 995d2d9490..d724ec18fc 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -1,12 +1,7 @@ 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_link_libraries(lammps PRIVATE CURL::libcurl) 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) diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index 8b695667ae..0edd9a3baa 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -1,7 +1,8 @@ ######################################################################## -# As of version 3.3.0 Kokkos requires C++14 -if(CMAKE_CXX_STANDARD LESS 14) - message(FATAL_ERROR "The KOKKOS package requires the C++ standard to be set to at least C++14") +# As of version 4.0.0 Kokkos requires C++17 +if(CMAKE_CXX_STANDARD LESS 17) + message(FATAL_ERROR "The KOKKOS package requires the C++ standard to +be set to at least C++17") endif() ######################################################################## @@ -49,8 +50,8 @@ if(DOWNLOAD_KOKKOS) 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) - set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/3.7.02.tar.gz" CACHE STRING "URL for KOKKOS tarball") - set(KOKKOS_MD5 "34d7860d548c06a4040236d959c9f99a" CACHE STRING "MD5 checksum of KOKKOS tarball") + set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/4.2.00.tar.gz" CACHE STRING "URL for KOKKOS tarball") + set(KOKKOS_MD5 "731647b61a4233f568d583702e9cd6d1" CACHE STRING "MD5 checksum of KOKKOS tarball") mark_as_advanced(KOKKOS_URL) mark_as_advanced(KOKKOS_MD5) GetFallbackURL(KOKKOS_URL KOKKOS_FALLBACK) @@ -75,7 +76,7 @@ if(DOWNLOAD_KOKKOS) add_dependencies(LAMMPS::KOKKOSCORE kokkos_build) add_dependencies(LAMMPS::KOKKOSCONTAINERS kokkos_build) elseif(EXTERNAL_KOKKOS) - find_package(Kokkos 3.7.02 REQUIRED CONFIG) + find_package(Kokkos 4.2.00 REQUIRED CONFIG) target_link_libraries(lammps PRIVATE Kokkos::kokkos) else() set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos) @@ -88,7 +89,7 @@ else() if(CMAKE_REQUEST_PIC) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() - add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR}) + add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR} EXCLUDE_FROM_ALL) set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src ${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src @@ -155,7 +156,7 @@ if(PKG_ML-IAP) # Add KOKKOS version of ML-IAP Python coupling if non-KOKKOS version is included if(MLIAP_ENABLE_PYTHON AND Cythonize_EXECUTABLE) - file(GLOB MLIAP_KOKKOS_CYTHON_SRC ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/KOKKOS/*.pyx) + file(GLOB MLIAP_KOKKOS_CYTHON_SRC CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/KOKKOS/*.pyx) foreach(MLIAP_CYTHON_FILE ${MLIAP_KOKKOS_CYTHON_SRC}) get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_FILE} NAME_WE) add_custom_command(OUTPUT ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.cpp ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.h diff --git a/cmake/Modules/Packages/KSPACE.cmake b/cmake/Modules/Packages/KSPACE.cmake index de7e7e5b20..9c9c879cd4 100644 --- a/cmake/Modules/Packages/KSPACE.cmake +++ b/cmake/Modules/Packages/KSPACE.cmake @@ -46,6 +46,42 @@ else() target_compile_definitions(lammps PRIVATE -DFFT_KISS) endif() +option(FFT_USE_HEFFTE "Use heFFTe as the distributed FFT engine, overrides the FFT option." OFF) +if(FFT_USE_HEFFTE) + # if FFT_HEFFTE is enabled, switch the builtin FFT engine with Heffte + set(FFT_HEFFTE_BACKEND_VALUES FFTW MKL) + set(FFT_HEFFTE_BACKEND "" CACHE STRING "Select heFFTe backend, e.g., FFTW or MKL") + set_property(CACHE FFT_HEFFTE_BACKEND PROPERTY STRINGS ${FFT_HEFFTE_BACKEND_VALUES}) + + if(FFT_HEFFTE_BACKEND STREQUAL "FFTW") # respect the backend choice, FFTW or MKL + set(HEFFTE_COMPONENTS "FFTW") + set(Heffte_ENABLE_FFTW "ON" CACHE BOOL "Enables FFTW backend for heFFTe") + elseif(FFT_HEFFTE_BACKEND STREQUAL "MKL") + set(HEFFTE_COMPONENTS "MKL") + set(Heffte_ENABLE_MKL "ON" CACHE BOOL "Enables MKL backend for heFFTe") + else() + message(WARNING "FFT_HEFFTE_BACKEND not selected, defaulting to the builtin 'stock' backend, which is intended for testing and is not optimized for production runs") + endif() + + find_package(Heffte 2.4.0 QUIET COMPONENTS ${HEFFTE_COMPONENTS}) + if (NOT Heffte_FOUND) # download and build + include(FetchContent) + FetchContent_Declare(HEFFTE_PROJECT # using v2.4.0 + URL "https://github.com/icl-utk-edu/heffte/archive/refs/tags/v2.4.0.tar.gz" + URL_HASH SHA256=02310fb4f9688df02f7181667e61c3adb7e38baf79611d80919d47452ff7881d + ) + FetchContent_Populate(HEFFTE_PROJECT) + add_subdirectory(${heffte_project_SOURCE_DIR} ${heffte_project_BINARY_DIR}) + set_target_properties(lmp PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + set_target_properties(lammps PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + add_library(Heffte::Heffte INTERFACE IMPORTED GLOBAL) + target_link_libraries(Heffte::Heffte INTERFACE Heffte) + endif() + + target_compile_definitions(lammps PRIVATE -DFFT_HEFFTE "-DFFT_HEFFTE_${FFT_HEFFTE_BACKEND}") + target_link_libraries(lammps PRIVATE Heffte::Heffte) +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}) diff --git a/cmake/Modules/Packages/LEPTON.cmake b/cmake/Modules/Packages/LEPTON.cmake index 33e14d092c..b1944c2400 100644 --- a/cmake/Modules/Packages/LEPTON.cmake +++ b/cmake/Modules/Packages/LEPTON.cmake @@ -4,7 +4,7 @@ if(LEPTON_SOURCE_DIR) endif() set(LEPTON_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/lepton) -file(GLOB LEPTON_SOURCES ${CONFIGURE_DEPENDS} ${LEPTON_SOURCE_DIR}/src/[^.]*.cpp) +file(GLOB LEPTON_SOURCES CONFIGURE_DEPENDS ${LEPTON_SOURCE_DIR}/src/[^.]*.cpp) if((CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "amd64") OR (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64") OR @@ -15,7 +15,7 @@ else() endif() if(LEPTON_ENABLE_JIT) - file(GLOB ASMJIT_SOURCES ${CONFIGURE_DEPENDS} ${LEPTON_SOURCE_DIR}/asmjit/*/[^.]*.cpp) + file(GLOB ASMJIT_SOURCES CONFIGURE_DEPENDS ${LEPTON_SOURCE_DIR}/asmjit/*/[^.]*.cpp) endif() add_library(lepton STATIC ${LEPTON_SOURCES} ${ASMJIT_SOURCES}) diff --git a/cmake/Modules/Packages/MDI.cmake b/cmake/Modules/Packages/MDI.cmake index dc3af94a0a..447b941d99 100644 --- a/cmake/Modules/Packages/MDI.cmake +++ b/cmake/Modules/Packages/MDI.cmake @@ -26,29 +26,9 @@ if(DOWNLOAD_MDI) # detect if we have python development support and thus can enable python plugins set(MDI_USE_PYTHON_PLUGINS OFF) - if(CMAKE_VERSION VERSION_LESS 3.12) - if(NOT PYTHON_VERSION_STRING) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - # search for interpreter first, so we have a consistent library - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - endif() - # search for the library matching the selected interpreter - set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs QUIET) # Deprecated since version 3.12 - if(PYTHONLIBS_FOUND) - if(NOT (PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)) - message(FATAL_ERROR "Python Library version ${PYTHONLIBS_VERSION_STRING} does not match Interpreter version ${PYTHON_VERSION_STRING}") - endif() - set(MDI_USE_PYTHON_PLUGINS ON) - endif() - else() - find_package(Python QUIET COMPONENTS Development) - if(Python_Development_FOUND) - set(MDI_USE_PYTHON_PLUGINS ON) - endif() + find_package(Python QUIET COMPONENTS Development) + if(Python_Development_FOUND) + set(MDI_USE_PYTHON_PLUGINS ON) endif() # python plugins are not supported and thus must be always off on Windows if(CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -102,13 +82,9 @@ if(DOWNLOAD_MDI) # if compiling with python plugins we need # to add python libraries as dependency. if(MDI_USE_PYTHON_PLUGINS) - if(CMAKE_VERSION VERSION_LESS 3.12) - list(APPEND MDI_DEP_LIBS ${PYTHON_LIBRARIES}) - else() - list(APPEND MDI_DEP_LIBS Python::Python) - endif() - + list(APPEND MDI_DEP_LIBS Python::Python) endif() + # need to add support for dlopen/dlsym, except when compiling for Windows. if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) list(APPEND MDI_DEP_LIBS "${CMAKE_DL_LIBS}") diff --git a/cmake/Modules/Packages/ML-IAP.cmake b/cmake/Modules/Packages/ML-IAP.cmake index f8439be538..d6059c44b8 100644 --- a/cmake/Modules/Packages/ML-IAP.cmake +++ b/cmake/Modules/Packages/ML-IAP.cmake @@ -2,12 +2,7 @@ set(MLIAP_ENABLE_PYTHON_DEFAULT OFF) if(PKG_PYTHON) find_package(Cythonize QUIET) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) - find_package(Python COMPONENTS NumPy QUIET) - else() - # assume we have NumPy - set(Python_NumPy_FOUND ON) - endif() + find_package(Python COMPONENTS NumPy QUIET) if(Cythonize_FOUND AND Python_NumPy_FOUND) set(MLIAP_ENABLE_PYTHON_DEFAULT ON) endif() @@ -17,24 +12,16 @@ option(MLIAP_ENABLE_PYTHON "Build ML-IAP package with Python support" ${MLIAP_EN if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) - find_package(Python COMPONENTS NumPy REQUIRED) - endif() + find_package(Python COMPONENTS NumPy REQUIRED) if(NOT PKG_PYTHON) message(FATAL_ERROR "Must enable PYTHON package for including Python support in ML-IAP") endif() - if(CMAKE_VERSION VERSION_LESS 3.12) - if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") - endif() - else() - if(Python_VERSION VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") - endif() + if(Python_VERSION VERSION_LESS 3.6) + message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") endif() set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) - file(GLOB MLIAP_CYTHON_SRC ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/ML-IAP/*.pyx) + file(GLOB MLIAP_CYTHON_SRC CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/ML-IAP/*.pyx) file(MAKE_DIRECTORY ${MLIAP_BINARY_DIR}) foreach(MLIAP_CYTHON_FILE ${MLIAP_CYTHON_SRC}) get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_FILE} NAME_WE) diff --git a/cmake/Modules/Packages/ML-PACE.cmake b/cmake/Modules/Packages/ML-PACE.cmake index 6cdb751617..248b8eea76 100644 --- a/cmake/Modules/Packages/ML-PACE.cmake +++ b/cmake/Modules/Packages/ML-PACE.cmake @@ -1,33 +1,40 @@ -set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2023.01.3.fix.tar.gz" CACHE STRING "URL for PACE evaluator library sources") +set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2023.11.25.fix.tar.gz" CACHE STRING "URL for PACE evaluator library sources") -set(PACELIB_MD5 "4f0b3b5b14456fe9a73b447de3765caa" CACHE STRING "MD5 checksum of PACE evaluator library tarball") +set(PACELIB_MD5 "b45de9a633f42ed65422567e3ce56f9f" CACHE STRING "MD5 checksum of PACE evaluator library tarball") mark_as_advanced(PACELIB_URL) mark_as_advanced(PACELIB_MD5) GetFallbackURL(PACELIB_URL PACELIB_FALLBACK) -# download library sources to build folder -if(EXISTS ${CMAKE_BINARY_DIR}/libpace.tar.gz) - file(MD5 ${CMAKE_BINARY_DIR}/libpace.tar.gz DL_MD5) -endif() -if(NOT "${DL_MD5}" STREQUAL "${PACELIB_MD5}") - message(STATUS "Downloading ${PACELIB_URL}") - file(DOWNLOAD ${PACELIB_URL} ${CMAKE_BINARY_DIR}/libpace.tar.gz STATUS DL_STATUS SHOW_PROGRESS) - file(MD5 ${CMAKE_BINARY_DIR}/libpace.tar.gz DL_MD5) - if((NOT DL_STATUS EQUAL 0) OR (NOT "${DL_MD5}" STREQUAL "${PACELIB_MD5}")) - message(WARNING "Download from primary URL ${PACELIB_URL} failed\nTrying fallback URL ${PACELIB_FALLBACK}") - file(DOWNLOAD ${PACELIB_FALLBACK} ${CMAKE_BINARY_DIR}/libpace.tar.gz EXPECTED_HASH MD5=${PACELIB_MD5} SHOW_PROGRESS) - endif() +# LOCAL_ML-PACE points to top-level dir with local lammps-user-pace repo, +# to make it easier to check local build without going through the public github releases +if(LOCAL_ML-PACE) + set(lib-pace "${LOCAL_ML-PACE}") else() - message(STATUS "Using already downloaded archive ${CMAKE_BINARY_DIR}/libpace.tar.gz") -endif() + # download library sources to build folder + if(EXISTS ${CMAKE_BINARY_DIR}/libpace.tar.gz) + file(MD5 ${CMAKE_BINARY_DIR}/libpace.tar.gz DL_MD5) + endif() + if(NOT "${DL_MD5}" STREQUAL "${PACELIB_MD5}") + message(STATUS "Downloading ${PACELIB_URL}") + file(DOWNLOAD ${PACELIB_URL} ${CMAKE_BINARY_DIR}/libpace.tar.gz STATUS DL_STATUS SHOW_PROGRESS) + file(MD5 ${CMAKE_BINARY_DIR}/libpace.tar.gz DL_MD5) + if((NOT DL_STATUS EQUAL 0) OR (NOT "${DL_MD5}" STREQUAL "${PACELIB_MD5}")) + message(WARNING "Download from primary URL ${PACELIB_URL} failed\nTrying fallback URL ${PACELIB_FALLBACK}") + file(DOWNLOAD ${PACELIB_FALLBACK} ${CMAKE_BINARY_DIR}/libpace.tar.gz EXPECTED_HASH MD5=${PACELIB_MD5} SHOW_PROGRESS) + endif() + else() + message(STATUS "Using already downloaded archive ${CMAKE_BINARY_DIR}/libpace.tar.gz") + endif() -# uncompress downloaded sources -execute_process( - COMMAND ${CMAKE_COMMAND} -E remove_directory lammps-user-pace* - COMMAND ${CMAKE_COMMAND} -E tar xzf libpace.tar.gz - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -) -get_newest_file(${CMAKE_BINARY_DIR}/lammps-user-pace-* lib-pace) + + # uncompress downloaded sources + execute_process( + COMMAND ${CMAKE_COMMAND} -E remove_directory lammps-user-pace* + COMMAND ${CMAKE_COMMAND} -E tar xzf libpace.tar.gz + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + get_newest_file(${CMAKE_BINARY_DIR}/lammps-user-pace-* lib-pace) +endif() add_subdirectory(${lib-pace} build-pace) set_target_properties(pace PROPERTIES CXX_EXTENSIONS ON OUTPUT_NAME lammps_pace${LAMMPS_MACHINE}) diff --git a/cmake/Modules/Packages/MSCG.cmake b/cmake/Modules/Packages/MSCG.cmake deleted file mode 100644 index 2b8e8eda06..0000000000 --- a/cmake/Modules/Packages/MSCG.cmake +++ /dev/null @@ -1,28 +0,0 @@ -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) - set(MSCG_URL "https://github.com/uchicago-voth/MSCG-release/archive/491270a73539e3f6951e76f7dbe84e258b3ebb45.tar.gz" CACHE STRING "URL for MSCG tarball") - set(MSCG_MD5 "7ea50748fba5c3a372e0266bd31d2f11" CACHE STRING "MD5 checksum of MSCG tarball") - mark_as_advanced(MSCG_URL) - mark_as_advanced(MSCG_MD5) - - include(ExternalCMakeProject) - ExternalCMakeProject(mscg ${MSCG_URL} ${MSCG_MD5} MSCG-release src/CMake "") - - # set include and link library - target_include_directories(lammps PRIVATE "${CMAKE_BINARY_DIR}/_deps/mscg-src/src") - target_link_libraries(lammps PRIVATE mscg) -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_DIR, or set DOWNLOAD_MSCG=ON to download it") - endif() - target_link_libraries(lammps PRIVATE MSCG::MSCG) -endif() -target_link_libraries(lammps PRIVATE GSL::gsl ${LAPACK_LIBRARIES}) diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake index 4a2925fe31..e05edadbf3 100644 --- a/cmake/Modules/Packages/PYTHON.cmake +++ b/cmake/Modules/Packages/PYTHON.cmake @@ -1,29 +1,11 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - if(NOT PYTHON_VERSION_STRING) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - # search for interpreter first, so we have a consistent library - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() + +if(NOT Python_INTERPRETER) + # backward compatibility with CMake before 3.12 and older LAMMPS documentation + if(PYTHON_EXECUTABLE) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) endif() - # search for the library matching the selected interpreter - set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs REQUIRED) # Deprecated since version 3.12 - if(NOT (PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)) - message(FATAL_ERROR "Python Library version ${PYTHONLIBS_VERSION_STRING} does not match Interpreter version ${PYTHON_VERSION_STRING}") - endif() - target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARIES}) -else() - if(NOT Python_INTERPRETER) - # backward compatibility - if(PYTHON_EXECUTABLE) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - find_package(Python COMPONENTS Interpreter) - endif() - find_package(Python REQUIRED COMPONENTS Interpreter Development) - target_link_libraries(lammps PRIVATE Python::Python) + find_package(Python COMPONENTS Interpreter) endif() +find_package(Python REQUIRED COMPONENTS Interpreter Development) +target_link_libraries(lammps PRIVATE Python::Python) target_compile_definitions(lammps PRIVATE -DLMP_PYTHON) diff --git a/cmake/Modules/StyleHeaderUtils.cmake b/cmake/Modules/StyleHeaderUtils.cmake index 2a0a91e843..d4644bd042 100644 --- a/cmake/Modules/StyleHeaderUtils.cmake +++ b/cmake/Modules/StyleHeaderUtils.cmake @@ -1,5 +1,5 @@ function(FindStyleHeaders path style_class file_pattern headers) - file(GLOB files ${CONFIGURE_DEPENDS} "${path}/${file_pattern}*.h") + file(GLOB files CONFIGURE_DEPENDS "${path}/${file_pattern}*.h") get_property(hlist GLOBAL PROPERTY ${headers}) foreach(file_name ${files}) @@ -187,7 +187,7 @@ endfunction(DetectBuildSystemConflict) function(FindPackagesHeaders path style_class file_pattern headers) - file(GLOB files ${CONFIGURE_DEPENDS} "${path}/${file_pattern}*.h") + file(GLOB files CONFIGURE_DEPENDS "${path}/${file_pattern}*.h") get_property(plist GLOBAL PROPERTY ${headers}) foreach(file_name ${files}) diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index 5345211178..ff595d3c8f 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -6,7 +6,7 @@ if(ENABLE_TESTING) find_program(VALGRIND_BINARY NAMES valgrind) # generate custom suppression file file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/lammps.supp "\n") - file(GLOB VALGRIND_SUPPRESSION_FILES ${CONFIGURE_DEPENDS} ${LAMMPS_TOOLS_DIR}/valgrind/[^.]*.supp) + file(GLOB VALGRIND_SUPPRESSION_FILES CONFIGURE_DEPENDS ${LAMMPS_TOOLS_DIR}/valgrind/[^.]*.supp) foreach(SUPP ${VALGRIND_SUPPRESSION_FILES}) file(READ ${SUPP} SUPPRESSIONS) file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/lammps.supp "${SUPPRESSIONS}") @@ -19,7 +19,7 @@ if(ENABLE_TESTING) # we need to build and link a LOT of tester executables, so it is worth checking if # a faster linker is available. requires GNU or Clang compiler, newer CMake. # also only verified with Fedora Linux > 30 and Ubuntu 18.04 or 22.04+(Ubuntu 20.04 fails) - if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))) if(((CMAKE_LINUX_DISTRO STREQUAL "Ubuntu") AND ((CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04) OR (CMAKE_DISTRO_VERSION VERSION_GREATER_EQUAL 22.04))) @@ -66,16 +66,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) mark_as_advanced(ENABLE_COVERAGE) if(ENABLE_COVERAGE) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") - endif() - else() - target_compile_options(lammps PUBLIC --coverage) - target_link_options(lammps PUBLIC --coverage) - endif() + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) endif() endif() @@ -118,16 +110,8 @@ validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) if(NOT ENABLE_SANITIZER STREQUAL "none") if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - endif() - else() - target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - endif() + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) else() message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") set(ENABLE_SANITIZER "none") diff --git a/cmake/Modules/Tools.cmake b/cmake/Modules/Tools.cmake index 285c5f2405..133301c3d4 100644 --- a/cmake/Modules/Tools.cmake +++ b/cmake/Modules/Tools.cmake @@ -26,7 +26,7 @@ if(BUILD_TOOLS) enable_language(C) get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE) - file(GLOB MSI2LMP_SOURCES ${CONFIGURE_DEPENDS} ${MSI2LMP_SOURCE_DIR}/[^.]*.c) + file(GLOB MSI2LMP_SOURCES CONFIGURE_DEPENDS ${MSI2LMP_SOURCE_DIR}/[^.]*.c) add_executable(msi2lmp ${MSI2LMP_SOURCES}) if(STANDARD_MATH_LIB) target_link_libraries(msi2lmp PRIVATE ${STANDARD_MATH_LIB}) @@ -37,12 +37,13 @@ if(BUILD_TOOLS) add_subdirectory(${LAMMPS_TOOLS_DIR}/phonon ${CMAKE_BINARY_DIR}/phana_build) endif() +find_package(PkgConfig QUIET) if(BUILD_LAMMPS_SHELL) + if(NOT PkgConfig_FOUND) + message(FATAL_ERROR "Must have pkg-config installed for building LAMMPS shell") + endif() find_package(PkgConfig REQUIRED) pkg_check_modules(READLINE IMPORTED_TARGET REQUIRED readline) - if(NOT LAMMPS_EXCEPTIONS) - message(WARNING "The LAMMPS shell needs LAMMPS_EXCEPTIONS enabled for full functionality") - endif() # include resource compiler to embed icons into the executable on Windows if(CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -67,4 +68,8 @@ if(BUILD_LAMMPS_SHELL) install(FILES ${LAMMPS_TOOLS_DIR}/lammps-shell/lammps-shell.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications/) endif() - +if(BUILD_LAMMPS_GUI) + get_filename_component(LAMMPS_GUI_DIR ${LAMMPS_SOURCE_DIR}/../tools/lammps-gui ABSOLUTE) + get_filename_component(LAMMPS_GUI_BIN ${CMAKE_BINARY_DIR}/lammps-gui-build ABSOLUTE) + add_subdirectory(${LAMMPS_GUI_DIR} ${LAMMPS_GUI_BIN}) +endif() diff --git a/cmake/packaging/LAMMPS_DMG_Background.png b/cmake/packaging/LAMMPS_DMG_Background.png new file mode 100644 index 0000000000..978b7d1987 Binary files /dev/null and b/cmake/packaging/LAMMPS_DMG_Background.png differ diff --git a/cmake/packaging/MacOSXBundleInfo.plist.in b/cmake/packaging/MacOSXBundleInfo.plist.in new file mode 100644 index 0000000000..bc08591e97 --- /dev/null +++ b/cmake/packaging/MacOSXBundleInfo.plist.in @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en-US + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleDisplayName + The LAMMPS Molecular Dynamics Software + CFBundleIconFile + lammps + CFBundleIdentifier + org.lammps.gui + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + LAMMPS_GUI + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + + diff --git a/cmake/packaging/README.macos b/cmake/packaging/README.macos new file mode 100644 index 0000000000..d7583e7034 --- /dev/null +++ b/cmake/packaging/README.macos @@ -0,0 +1,69 @@ +LAMMPS and LAMMPS GUI universal binaries for macOS (arm64/x86_64) +================================================================= + +This package provides universal binaries of LAMMPS and LAMMPS GUI that should +run on macOS systems running running macOS version 11 (Big Sur) or newer. Note +the binaries are compiled without MPI support and contain a compatible subset +of the available packages. + +The following individual commands are included: +binary2txt lammps-gui lmp msi2lmp phana stl_bin2txt + +After copying the LAMMPS_GUI folder into your Applications folder, please follow +these steps: + +1. Open the Terminal app + +2. Type the following command and press ENTER: + + open ~/.zprofile + + This will open a text editor for modifying the .zprofile file in your home + directory. + +3. Add the following lines to the end of the file, save it, and close the editor + + LAMMPS_INSTALL_DIR=/Applications/LAMMPS_GUI.app/Contents + LAMMPS_POTENTIALS=${LAMMPS_INSTALL_DIR}/share/lammps/potentials + LAMMPS_BENCH_DIR=${LAMMPS_INSTALL_DIR}/share/lammps/bench + MSI2LMP_LIBRARY=${LAMMPS_INSTALL_DIR}/share/lammps/frc_files + PATH=${LAMMPS_INSTALL_DIR}/bin:$PATH + export LAMMPS_POTENTIALS LAMMPS_BENCH_DIR PATH + +4. In your existing terminal, type the following command make the settings active + + source ~/.zprofile + + Note, you don't have to type this in new terminals, since they will apply + the changes from .zprofile automatically. + + Note: the above assumes you use the default shell (zsh) that comes with + MacOS. If you customized MacOS to use a different shell, you'll need to + modify that shell's init file (.cshrc, .bashrc, etc.) instead with + appropiate commands to modify the same environment variables. + +5. Try running LAMMPS (which might fail, see step 7) + + lmp -in ${LAMMPS_BENCH_DIR}/in.lj + +6. Try running the LAMMPS GUI + + lammps-gui ${LAMMPS_BENCH_DIR}/in.rhodo + + Depending on the size and resolution of your screen, the fonts may be too + small to read. This can be adjusted by setting the environment variable + QT_FONT_DPI. The default value would be 72, so to increase the fonts by a + third, one can add to the .zprofile file the line + + export QT_FONT_DPI=96 + + and reload as shown above. + +7. Give permission to execute the commands (lmp, lammps-gui, msi2lmp, binary2txt, phana, stl_bin2txt) + + MacOS will likely block the initial run of the executables, since they were + downloaded from the internet and are missing a known signature from an + identified developer. Go to "Settings" and search for "Security settings". + It should display a message that an executable like "lmp" was blocked. Press + "Open anyway", which might prompt you for your admin credentials. Afterwards + "lmp" and the other executables should work as expected. diff --git a/cmake/packaging/build_linux_tgz.sh b/cmake/packaging/build_linux_tgz.sh new file mode 100755 index 0000000000..48e3017f61 --- /dev/null +++ b/cmake/packaging/build_linux_tgz.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +APP_NAME=lammps-gui +DESTDIR=${PWD}/../LAMMPS_GUI + +echo "Delete old files, if they exist" +rm -rf ${DESTDIR} ../LAMMPS_GUI-Linux-amd64.tar.gz + +echo "Create staging area for deployment and populate" +DESTDIR=${DESTDIR} cmake --install . --prefix "/" + +echo "Remove debug info" +for s in ${DESTDIR}/bin/* ${DESTDIR}/lib/liblammps* +do \ + test -f $s && strip --strip-debug $s +done + +echo "Remove libc, gcc, and X11 related shared libs" +rm -f ${DESTDIR}/lib/ld*.so ${DESTDIR}/lib/ld*.so.[0-9] +rm -f ${DESTDIR}/lib/lib{c,dl,rt,m,pthread}.so.? +rm -f ${DESTDIR}/lib/lib{c,dl,rt,m,pthread}-[0-9].[0-9]*.so +rm -f ${DESTDIR}/lib/libX* ${DESTDIR}/lib/libxcb* +rm -f ${DESTDIR}/lib/libgcc_s* +rm -f ${DESTDIR}/lib/libstdc++* + +# get qt dir +QTDIR=$(ldd ${DESTDIR}/bin/lammps-gui | grep libQt5Core | sed -e 's/^.*=> *//' -e 's/libQt5Core.so.*$/qt5/') +cat > ${DESTDIR}/bin/qt.conf < *//' -e 's/\(libQt5.*.so.*\) .*$/\1/') +for dep in ${QTDEPS} +do \ + cp ${dep} ${DESTDIR}/lib +done + +echo "Add additional plugins for Qt" +for dir in styles imageformats +do \ + cp -r ${QTDIR}/plugins/${dir} ${DESTDIR}/qt5plugins/ +done + +# get imageplugin dependencies +for s in ${DESTDIR}/qt5plugins/imageformats/*.so +do \ + QTDEPS=$(LD_LIBRARY_PATH=${DESTDIR}/lib ldd $s | grep -v ${DESTDIR} | grep -E '(libQt5|jpeg)' | sed -e 's/^.*=> *//' -e 's/\(lib.*.so.*\) .*$/\1/') + for dep in ${QTDEPS} + do \ + cp ${dep} ${DESTDIR}/lib + done +done + +echo "Set up wrapper script" +MYDIR=$(dirname "$0") +cp ${MYDIR}/linux_wrapper.sh ${DESTDIR}/bin +for s in ${DESTDIR}/bin/* +do \ + EXE=$(basename $s) + test ${EXE} = linux_wrapper.sh && continue + test ${EXE} = qt.conf && continue + ln -s bin/linux_wrapper.sh ${DESTDIR}/${EXE} +done + +pushd .. +tar -czvvf LAMMPS_GUI-Linux-amd64.tar.gz LAMMPS_GUI +popd + +echo "Cleanup dir" +rm -r ${DESTDIR} +exit 0 diff --git a/cmake/packaging/build_macos_dmg.sh b/cmake/packaging/build_macos_dmg.sh new file mode 100755 index 0000000000..4da3e40eaf --- /dev/null +++ b/cmake/packaging/build_macos_dmg.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +APP_NAME=lammps-gui + +echo "Delete old files, if they exist" +rm -f ${APP_NAME}.dmg ${APP_NAME}-rw.dmg LAMMPS_GUI-macOS-multiarch.dmg + +echo "Create initial dmg file with macdeployqt" +macdeployqt lammps-gui.app -dmg +echo "Create writable dmg file" +hdiutil convert ${APP_NAME}.dmg -format UDRW -o ${APP_NAME}-rw.dmg + +echo "Mount writeable DMG file in read-write mode. Keep track of device and volume names" +DEVICE=$(hdiutil attach -readwrite -noverify ${APP_NAME}-rw.dmg | grep '^/dev/' | sed 1q | awk '{print $1}') +VOLUME=$(df | grep ${DEVICE} | sed -e 's/^.*\(\/Volumes\/\)/\1/') +sleep 2 + +echo "Create link to Application folder and move README and background image files" + +pushd "${VOLUME}" +ln -s /Applications . +mv ${APP_NAME}.app/Contents/Resources/README.txt . +mkdir .background +mv ${APP_NAME}.app/Contents/Resources/LAMMPS_DMG_Background.png .background/background.png +mv ${APP_NAME}.app LAMMPS_GUI.app +cd LAMMPS_GUI.app/Contents + +echo "Attach icons to LAMMPS console and GUI executables" +echo "read 'icns' (-16455) \"Resources/lammps.icns\";" > icon.rsrc +Rez -a icon.rsrc -o bin/lmp +SetFile -a C bin/lmp +Rez -a icon.rsrc -o MacOS/lammps-gui +SetFile -a C MacOS/lammps-gui +rm icon.rsrc +popd + +echo 'Tell the Finder to resize the window, set the background,' +echo 'change the icon size, place the icons in the right position, etc.' +echo ' + tell application "Finder" + tell disk "'${APP_NAME}'" + + -- wait for the image to finish mounting + set open_attempts to 0 + repeat while open_attempts < 4 + try + open + delay 1 + set open_attempts to 5 + close + on error errStr number errorNumber + set open_attempts to open_attempts + 1 + delay 10 + end try + end repeat + delay 5 + + -- open the image the first time and save a .DS_Store + -- just the background and icon setup + open + set current view of container window to icon view + set theViewOptions to the icon view options of container window + set background picture of theViewOptions to file ".background:background.png" + set arrangement of theViewOptions to not arranged + set icon size of theViewOptions to 64 + delay 5 + close + + -- next set up the position of the app and Applications symlink + -- plus hide all window decorations + open + update without registering applications + tell container window + set sidebar width to 0 + set statusbar visible to false + set toolbar visible to false + set the bounds to { 100, 40, 868, 640 } + set position of item "'LAMMPS_GUI'.app" to { 190, 216 } + set position of item "Applications" to { 576, 216 } + set position of item "README.txt" to { 190, 400 } + end tell + update without registering applications + delay 5 + close + + -- one last open and close to check the results + open + delay 5 + close + end tell + delay 1 + end tell +' | osascript + +sync + +echo "Unmount modified disk image and convert to compressed read-only image" +hdiutil detach "${DEVICE}" +hdiutil convert "${APP_NAME}-rw.dmg" -format UDZO -o "LAMMPS_GUI-macOS-multiarch.dmg" + +echo "Attach icon to .dmg file" +echo "read 'icns' (-16455) \"lammps-gui.app/Contents/Resources/lammps.icns\";" > icon.rsrc +Rez -a icon.rsrc -o LAMMPS_GUI-macOS-multiarch.dmg +SetFile -a C LAMMPS_GUI-macOS-multiarch.dmg +rm icon.rsrc + +echo "Delete temporary disk images" +rm -f "${APP_NAME}-rw.dmg" +rm -f "${APP_NAME}.dmg" + +exit 0 diff --git a/cmake/packaging/build_windows_cross_zip.sh b/cmake/packaging/build_windows_cross_zip.sh new file mode 100755 index 0000000000..d02b9cf761 --- /dev/null +++ b/cmake/packaging/build_windows_cross_zip.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +APP_NAME=lammps-gui +DESTDIR=${PWD}/LAMMPS_GUI +SYSROOT="$1" + +echo "Delete old files, if they exist" +rm -rvf ${DESTDIR}/LAMMPS_GUI ${DESTDIR}/LAMMPS-Win10-amd64.zip + +echo "Create staging area for deployment and populate" +DESTDIR=${DESTDIR} cmake --install . --prefix "/" + +# no static libs needed +rm -rvf ${DESTDIR}/lib +# but the LAMMPS lib + +echo "Copying required DLL files" +for dll in $(objdump -p *.exe *.dll | sed -n -e '/DLL Name:/s/^.*DLL Name: *//p' | sort | uniq) +do \ + doskip=0 + for skip in ADVAPI32 CFGMGR32 GDI32 KERNEL32 MPR NETAPI32 PSAPI SHELL32 USER32 USERENV UxTheme VERSION WS2_32 WSOCK32 d3d11 dwmapi liblammps msvcrt_ole32 + do \ + test ${dll} = ${skip}.dll && doskip=1 + done + test ${doskip} -eq 1 && continue + test -f ${DESTDIR}/bin/${dll} || cp -v ${SYSROOT}/bin/${dll} ${DESTDIR}/bin +done + +echo "Copy required Qt plugins" +mkdir -p ${DESTDIR}/qt5plugins +for plugin in imageformats platforms styles +do \ + cp -r ${SYSROOT}/lib/qt5/plugins/${plugin} ${DESTDIR}/qt5plugins/ +done + +echo "Check dependencies of DLL files" +for dll in $(objdump -p ${DESTDIR}/bin/*.dll ${DESTDIR}/qt5plugins/*/*.dll | sed -n -e '/DLL Name:/s/^.*DLL Name: *//p' | sort | uniq) +do \ + doskip=0 + for skip in ADVAPI32 CFGMGR32 GDI32 KERNEL32 MPR NETAPI32 PSAPI SHELL32 USER32 USERENV UxTheme VERSION WS2_32 WSOCK32 d3d11 dwmapi liblammps msvcrt_ole32 + do \ + test ${dll} = ${skip}.dll && doskip=1 + done + test ${doskip} -eq 1 && continue + test -f ${DESTDIR}/bin/${dll} || cp -v ${SYSROOT}/bin/${dll} ${DESTDIR}/bin +done + +for dll in $(objdump -p ${DESTDIR}/bin/*.dll ${DESTDIR}/qt5plugins/*/*.dll | sed -n -e '/DLL Name:/s/^.*DLL Name: *//p' | sort | uniq) +do \ + doskip=0 + for skip in ADVAPI32 CFGMGR32 GDI32 KERNEL32 MPR NETAPI32 PSAPI SHELL32 USER32 USERENV UxTheme VERSION WS2_32 WSOCK32 d3d11 dwmapi liblammps msvcrt_ole32 + do \ + test ${dll} = ${skip}.dll && doskip=1 + done + test ${doskip} -eq 1 && continue + test -f ${DESTDIR}/bin/${dll} || cp -v ${SYSROOT}/bin/${dll} ${DESTDIR}/bin +done + +cat > ${DESTDIR}/bin/qt.conf < " + exit 1 +fi + +png="$1" +ico="$2" + +if [ ! -f ${png} ] +then + echo "PNG Image $1 not found" +fi + +rm -rf ${ico}.iconset +mkdir ${ico}.iconset +sips -z 16 16 ${png} --out ${ico}.iconset/icon_16x16.png +sips -z 32 32 ${png} --out ${ico}.iconset/icon_16x16@2x.png +sips -z 32 32 ${png} --out ${ico}.iconset/icon_32x32.png +sips -z 64 64 ${png} --out ${ico}.iconset/icon_32x32@2x.png +sips -z 128 128 ${png} --out ${ico}.iconset/icon_128x128.png +sips -z 256 256 ${png} --out ${ico}.iconset/icon_128x128@2x.png +sips -z 256 256 ${png} --out ${ico}.iconset/icon_256x256.png +sips -z 512 512 ${png} --out ${ico}.iconset/icon_256x256@2x.png +sips -z 512 512 ${png} --out ${ico}.iconset/icon_512x512.png +sips -z 1024 1024 ${png} --out ${ico}.iconset/icon_512x512@2x.png +iconutil -c icns ${ico}.iconset +rm -rf ${ico}.iconset diff --git a/cmake/presets/all_off.cmake b/cmake/presets/all_off.cmake index 2db615f533..e078879f70 100644 --- a/cmake/presets/all_off.cmake +++ b/cmake/presets/all_off.cmake @@ -63,8 +63,6 @@ set(ALL_PACKAGES MOFFF MOLECULE MOLFILE - MPIIO - MSCG NETCDF OPENMP OPT diff --git a/cmake/presets/all_on.cmake b/cmake/presets/all_on.cmake index 79444f96aa..3f44a863f7 100644 --- a/cmake/presets/all_on.cmake +++ b/cmake/presets/all_on.cmake @@ -65,8 +65,6 @@ set(ALL_PACKAGES MOFFF MOLECULE MOLFILE - MPIIO - MSCG NETCDF OPENMP OPT diff --git a/cmake/presets/download.cmake b/cmake/presets/download.cmake index 13b93569f9..d10214ca65 100644 --- a/cmake/presets/download.cmake +++ b/cmake/presets/download.cmake @@ -9,7 +9,6 @@ endforeach() set(DOWNLOAD_KIM ON CACHE BOOL "" FORCE) set(DOWNLOAD_MDI ON CACHE BOOL "" FORCE) -set(DOWNLOAD_MSCG ON CACHE BOOL "" FORCE) set(DOWNLOAD_VORO ON CACHE BOOL "" FORCE) set(DOWNLOAD_EIGEN3 ON CACHE BOOL "" FORCE) set(DOWNLOAD_PACE ON CACHE BOOL "" FORCE) diff --git a/cmake/presets/gpu-cuda.cmake b/cmake/presets/gpu-cuda.cmake new file mode 100644 index 0000000000..2ac6bd9ea6 --- /dev/null +++ b/cmake/presets/gpu-cuda.cmake @@ -0,0 +1,11 @@ +# preset that enables GPU and selects CUDA API + +set(PKG_GPU ON CACHE BOOL "Build GPU package" FORCE) +set(GPU_API "cuda" CACHE STRING "APU used by GPU package" FORCE) +set(GPU_PREC "mixed" CACHE STRING "" FORCE) + +set(CUDA_NVCC_FLAGS "-allow-unsupported-compiler" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS_DEBUG "-allow-unsupported-compiler" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS_MINSIZEREL "-allow-unsupported-compiler" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS_RELWITHDEBINFO "-allow-unsupported-compiler" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS_RELEASE "-allow-unsupported-compiler" CACHE STRING "" FORCE) diff --git a/cmake/presets/kokkos-cuda.cmake b/cmake/presets/kokkos-cuda.cmake index ace8ff0879..c3ee081898 100644 --- a/cmake/presets/kokkos-cuda.cmake +++ b/cmake/presets/kokkos-cuda.cmake @@ -6,6 +6,8 @@ set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE) set(Kokkos_ENABLE_CUDA ON CACHE BOOL "" FORCE) set(Kokkos_ARCH_PASCAL60 ON CACHE BOOL "" FORCE) set(BUILD_OMP ON CACHE BOOL "" FORCE) +get_filename_component(NVCC_WRAPPER_CMD ${CMAKE_CURRENT_SOURCE_DIR}/../lib/kokkos/bin/nvcc_wrapper ABSOLUTE) +set(CMAKE_CXX_COMPILER ${NVCC_WRAPPER_CMD} CACHE FILEPATH "" FORCE) # hide deprecation warnings temporarily for stable release set(Kokkos_ENABLE_DEPRECATION_WARNINGS OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/macos-multiarch.cmake b/cmake/presets/macos-multiarch.cmake new file mode 100644 index 0000000000..8ceaec11f8 --- /dev/null +++ b/cmake/presets/macos-multiarch.cmake @@ -0,0 +1,12 @@ +# preset that will build portable multi-arch binaries on macOS without MPI + +set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) +set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0 CACHE STRING "" FORCE) +set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE) + +set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE) +set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) + +set(BUILD_MPI FALSE CACHE BOOL "" FORCE) diff --git a/cmake/presets/mingw-cross.cmake b/cmake/presets/mingw-cross.cmake index 85f61be95b..f3565668b2 100644 --- a/cmake/presets/mingw-cross.cmake +++ b/cmake/presets/mingw-cross.cmake @@ -83,7 +83,6 @@ endforeach() # these two packages require a full MPI implementation if(BUILD_MPI) - set(PKG_MPIIO ON CACHE BOOL "" FORCE) set(PKG_LATBOLTZ ON CACHE BOOL "" FORCE) endif() diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake index 00c74c81b8..2356e24764 100644 --- a/cmake/presets/most.cmake +++ b/cmake/presets/most.cmake @@ -24,8 +24,8 @@ set(ALL_PACKAGES DPD-REACT DPD-SMOOTH DRUDE - ELECTRODE EFF + ELECTRODE EXTRA-COMPUTE EXTRA-DUMP EXTRA-FIX diff --git a/cmake/presets/nolib.cmake b/cmake/presets/nolib.cmake index 0e1b09b6cc..4a4a557505 100644 --- a/cmake/presets/nolib.cmake +++ b/cmake/presets/nolib.cmake @@ -19,8 +19,6 @@ set(PACKAGES_WITH_LIB ML-PACE ML-QUIP MOLFILE - MPIIO - MSCG NETCDF PLUMED PYTHON diff --git a/cmake/presets/oneapi.cmake b/cmake/presets/oneapi.cmake index 2aacf1a1f5..393d1d9b68 100644 --- a/cmake/presets/oneapi.cmake +++ b/cmake/presets/oneapi.cmake @@ -18,11 +18,11 @@ set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) unset(HAVE_OMP_H_INCLUDE CACHE) set(OpenMP_C "icx" CACHE STRING "" FORCE) -set(OpenMP_C_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE) +set(OpenMP_C_FLAGS "-qopenmp;-qopenmp-simd" CACHE STRING "" FORCE) set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) set(OpenMP_CXX "icpx" CACHE STRING "" FORCE) -set(OpenMP_CXX_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE) +set(OpenMP_CXX_FLAGS "-qopenmp;-qopenmp-simd" CACHE STRING "" FORCE) set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) -set(OpenMP_Fortran_FLAGS "-qopenmp -qopenmp-simd" CACHE STRING "" FORCE) +set(OpenMP_Fortran_FLAGS "-qopenmp;-qopenmp-simd" CACHE STRING "" FORCE) set(OpenMP_omp_LIBRARY "libiomp5.so" CACHE PATH "" FORCE) diff --git a/cmake/presets/windows.cmake b/cmake/presets/windows.cmake index aa9a4656af..9655134e7f 100644 --- a/cmake/presets/windows.cmake +++ b/cmake/presets/windows.cmake @@ -32,6 +32,7 @@ set(WIN_PACKAGES INTERLAYER KSPACE LEPTON + MACHDYN MANIFOLD MANYBODY MC @@ -45,6 +46,7 @@ set(WIN_PACKAGES MOLECULE MOLFILE OPENMP + OPT ORIENT PERI PHONON diff --git a/doc/Makefile b/doc/Makefile index 2a4edc70f3..b652c515e1 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -63,6 +63,7 @@ help: @echo " anchor_check scan for duplicate anchor labels" @echo " style_check check for complete and consistent style lists" @echo " package_check check for complete and consistent package lists" + @echo " role_check check for misformatted role keywords" @echo " spelling spell-check the manual" # ------------------------------------------ @@ -98,6 +99,7 @@ html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst ;\ + env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst ;\ $(PYTHON) $(BUILDDIR)/utils/check-styles.py -s ../src -d src ;\ echo "############################################" ;\ deactivate ;\ @@ -179,6 +181,7 @@ pdf: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) env LC_ALL=C grep -n '[^ -~]' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst ;\ + env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst ;\ $(PYTHON) utils/check-styles.py -s ../src -d src ;\ echo "############################################" ;\ deactivate ;\ @@ -227,6 +230,7 @@ char_check : role_check : @( env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst && exit 1 || : ) @( env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst && exit 1 || : ) + @( env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst && exit 1 || : ) link_check : $(VENV) html @(\ diff --git a/doc/github-development-workflow.md b/doc/github-development-workflow.md index fccd75d29a..e16ae82764 100644 --- a/doc/github-development-workflow.md +++ b/doc/github-development-workflow.md @@ -36,10 +36,10 @@ requests. MUST be submitted as a pull request to GitHub. All changes to the "develop" branch must be made exclusively through merging pull requests. The "release" and "stable" branches, respectively, are only to be -updated upon feature or stable releases based on the associated -tags. Updates to the stable release in between stable releases +updated upon "feature releases" or "stable releases" based on the +associated tags. Updates to the stable release in between stable releases (for example, back-ported bug fixes) are first merged into the "maintenance" -branch and then into the "stable" branch as update releases. +branch and then into the "stable" branch as "stable update releases". Pull requests may also be submitted to (long-running) feature branches created by LAMMPS developers inside the LAMMPS project, if needed. Those @@ -131,7 +131,7 @@ testing -- that the code in the branch "develop" does not get easily broken. These tests are run after every update to a pull request. More extensive and time-consuming tests (including regression testing) are performed after code is merged to the "develop" branch. There are feature -releases of LAMMPS made about every 4-6 weeks at a point, when the LAMMPS +releases of LAMMPS made about every 4-8 weeks at a point, when the LAMMPS developers feel, that a sufficient number of changes have been included and all post-merge testing has been successful. These feature releases are marked with a `patch_` tag and the "release" branch diff --git a/doc/graphviz/Makefile b/doc/graphviz/Makefile index a3e0c94c63..00b651e888 100644 --- a/doc/graphviz/Makefile +++ b/doc/graphviz/Makefile @@ -16,8 +16,11 @@ clean: rm -f $(IMGSVG) $(IMGPDF) $(IMGPNG) *~ ifeq ($(HAS_DOT),YES) -$(IMGDIR)/%.png: %.dot +$(IMGDIR)/lammps-classes.png : lammps-classes.dot dot -Tpng -Kneato -o $@ $< + +$(IMGDIR)/%.png: %.dot + dot -Tpng -Kdot -o $@ $< endif ifeq ($(HAS_DOT),NO) diff --git a/doc/graphviz/lammps-releases.dot b/doc/graphviz/lammps-releases.dot new file mode 100644 index 0000000000..f641cac029 --- /dev/null +++ b/doc/graphviz/lammps-releases.dot @@ -0,0 +1,34 @@ +// LAMMPS branches and releases +digraph releases { + rankdir="LR"; + github [shape="box" label="Pull Requests\non GitHub" height=0.75]; + github -> develop [label="Merge commits"]; + { + rank = "same"; + work [shape="none" label="Development branches:"] + develop [label="'develop' branch" height=0.75]; + maintenance [label="'maintenance' branch" height=0.75]; + }; + { + rank = "same"; + upload [shape="none" label="Release branches:"] + release [label="'release' branch" height=0.75]; + stable [label="'stable' branch" height=0.75]; + }; + develop -> release [label="Feature release\n(every 4-8 weeks)"]; + release -> stable [label="Stable release\n(once per year)"]; + stable -> maintenance [label="Reset on stable release" style="setlinewidth(2)"]; + develop -> maintenance [label="Backports of bugfixes" style="dashed"]; + maintenance -> stable [label="Updates to stable release"]; + { + rank = "same"; + tag [shape="none" label="Applied tags:"]; + patchtag [shape="box" label="patch_"]; + stabletag [shape="box" label="stable_"]; + updatetag [shape="box" label="stable__update"]; + }; + release -> patchtag [label="feature release" style="dotted"]; + stable -> stabletag [label="stable release" style="dotted"]; + stable -> updatetag [label="update release" style="dotted"]; +} + diff --git a/doc/lammps.1 b/doc/lammps.1 index b1be867e60..100ea9b663 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,7 +1,7 @@ -.TH LAMMPS "1" "28 March 2023" "2023-03-28" +.TH LAMMPS "1" "21 November 2023" "2023-11-21" .SH NAME .B LAMMPS -\- Molecular Dynamics Simulator. Version 28 March 2023 +\- Molecular Dynamics Simulator. Version 21 November 2023 .SH SYNOPSIS .B lmp diff --git a/doc/src/Bibliography.rst b/doc/src/Bibliography.rst index 2d27d2e6f9..4ed8e73dfe 100644 --- a/doc/src/Bibliography.rst +++ b/doc/src/Bibliography.rst @@ -203,7 +203,7 @@ Bibliography A Caro, DA Crowson, M Caro; Phys Rev Lett, 95, 075702 (2005) **(CasP)** - CasP webpage: https://www.helmholtz-berlin.de/people/gregor-schiwietz/casp_en.html + CasP webpage: http://www.casp-program.org/ **(Cawkwell2012)** A.\ M. N. Niklasson, M. J. Cawkwell, Phys. Rev. B, 86 (17), 174308 (2012). @@ -562,6 +562,9 @@ Bibliography **(Kumar)** Kumar and Skinner, J. Phys. Chem. B, 112, 8311 (2008) +**(Lafourcade)** + Lafourcade, Maillet, Denoual, Duval, Allera, Goryaeva, and Marinica, `Comp. Mat. Science, 230, 112534 (2023) `_ + **(Lamoureux and Roux)** G.\ Lamoureux, B. Roux, J. Chem. Phys 119, 3025 (2003) diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst index 0a0d4919a0..233b825d01 100644 --- a/doc/src/Build_basics.rst +++ b/doc/src/Build_basics.rst @@ -90,7 +90,7 @@ standard. A more detailed discussion of that is below. 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 ``LATBOLTZ``, + required by some LAMMPS packages, e.g. ``LATBOLTZ``, and thus is not compatible with those packages. .. note:: @@ -128,14 +128,13 @@ 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``, -``ML-SNAP``, ``DIFFRACTION``, and ``DPD-REACT`` packages. -Furthermore, some packages support OpenMP threading indirectly through -the libraries they interface to: e.g. ``KSPACE``, and ``COLVARS``. -See the :doc:`Packages details ` page for more info -on these packages, and the pages for their respective commands for -OpenMP threading info. +In addition, there are a few commands in LAMMPS that have native OpenMP +support included as well. These are commands in the ``ML-SNAP``, +``DIFFRACTION``, and ``DPD-REACT`` packages. Furthermore, some packages +support OpenMP threading indirectly through the libraries they interface +to: e.g. ``KSPACE``, and ``COLVARS``. See the :doc:`Packages details +` page for more info on these packages, and the 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 @@ -489,8 +488,9 @@ using CMake or Make. .. code-block:: bash - -D BUILD_TOOLS=value # yes or no (default) - -D BUILD_LAMMPS_SHELL=value # yes or no (default) + -D BUILD_TOOLS=value # yes or no (default). Build binary2txt, chain.x, micelle2d.x, msi2lmp, phana, stl_bin2txt + -D BUILD_LAMMPS_SHELL=value # yes or no (default). Build lammps-shell + -D BUILD_LAMMPS_GUI=value # yes or no (default). Build lammps-gui The generated binaries will also become part of the LAMMPS installation (see below). @@ -504,7 +504,6 @@ using CMake or Make. make binary2txt # build only binary2txt tool make chain # build only chain tool make micelle2d # build only micelle2d tool - make thermo_extract # build only thermo_extract tool cd lammps/tools/lammps-shell make # build LAMMPS shell diff --git a/doc/src/Build_cmake.rst b/doc/src/Build_cmake.rst index 9be2c33165..e622f9f208 100644 --- a/doc/src/Build_cmake.rst +++ b/doc/src/Build_cmake.rst @@ -16,8 +16,7 @@ environments is on a :doc:`separate page `. .. note:: - LAMMPS currently requires that CMake version 3.10 or later is available; - version 3.12 or later is preferred. + LAMMPS currently requires that CMake version 3.16 or later is available. .. warning:: @@ -34,19 +33,18 @@ 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. +through :doc:`(manually customized) makefiles `. 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 command line, text - mode, or graphical user interface. No knowledge of file formats or - complex command line syntax is required. + mode, or graphical user interface. No manual editing of files, + knowledge of file formats or complex command line syntax is 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 @@ -179,13 +177,13 @@ configuration is selected with the *-C* flag: ctest -C Debug -The CMake scripts in LAMMPS have basic support for being compiled using a -multi-config build system, but not all of it has been ported. This is in -particular applicable to compiling packages that require additional libraries -that would be downloaded and compiled by CMake. The "windows" preset file -tries to keep track of which packages can be compiled natively with the -MSVC compilers out-of-the box. Not all of those external libraries are -portable to Windows, either. +The CMake scripts in LAMMPS have basic support for being compiled using +a multi-config build system, but not all of it has been ported. This is +in particular applicable to compiling packages that require additional +libraries that would be downloaded and compiled by CMake. The +``windows.cmake`` preset file tries to keep track of which packages can +be compiled natively with the MSVC compilers out-of-the box. Not all of +the external libraries are portable to Windows, either. Installing CMake diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst index c75c7a6a41..c674b2c258 100644 --- a/doc/src/Build_development.rst +++ b/doc/src/Build_development.rst @@ -255,16 +255,18 @@ A test run is then a a collection multiple individual test runs each with many comparisons to reference results based on template input files, individual command settings, relative error margins, and reference data stored in a YAML format file with ``.yaml`` -suffix. Currently the programs ``test_pair_style``, ``test_bond_style``, and -``test_angle_style`` are implemented. They will compare forces, energies and -(global) stress for all atoms after a ``run 0`` calculation and after a -few steps of MD with :doc:`fix nve `, each in multiple variants -with different settings and also for multiple accelerated styles. If a -prerequisite style or package is missing, the individual tests are -skipped. All tests will be executed on a single MPI process, so using -the CMake option ``-D BUILD_MPI=off`` can significantly speed up testing, -since this will skip the MPI initialization for each test run. -Below is an example command and output: +suffix. Currently the programs ``test_pair_style``, ``test_bond_style``, +``test_angle_style``, ``test_dihedral_style``, and +``test_improper_style`` are implemented. They will compare forces, +energies and (global) stress for all atoms after a ``run 0`` calculation +and after a few steps of MD with :doc:`fix nve `, each in +multiple variants with different settings and also for multiple +accelerated styles. If a prerequisite style or package is missing, the +individual tests are skipped. All force style tests will be executed on +a single MPI process, so using the CMake option ``-D BUILD_MPI=off`` can +significantly speed up testing, since this will skip the MPI +initialization for each test run. Below is an example command and +output: .. code-block:: console @@ -416,15 +418,16 @@ When compiling LAMMPS with enabled tests, most test executables will need to be linked against the LAMMPS library. Since this can be a very large library with many C++ objects when many packages are enabled, link times can become very long on machines that use the GNU BFD linker (e.g. -Linux systems). Alternatives like the ``lld`` linker of the LLVM project -or the ``gold`` linker available with GNU binutils can speed up this step -substantially. CMake will by default test if any of the two can be -enabled and use it when ``ENABLE_TESTING`` is active. It can also be -selected manually through the ``CMAKE_CUSTOM_LINKER`` CMake variable. -Allowed values are ``lld``, ``gold``, ``bfd``, or ``default``. The -``default`` option will use the system default linker otherwise, the -linker is chosen explicitly. This option is only available for the -GNU or Clang C++ compiler. +Linux systems). Alternatives like the ``mold`` linker, the ``lld`` +linker of the LLVM project, or the ``gold`` linker available with GNU +binutils can speed up this step substantially (in this order). CMake +will by default test if any of the three can be enabled and use it when +``ENABLE_TESTING`` is active. It can also be selected manually through +the ``CMAKE_CUSTOM_LINKER`` CMake variable. Allowed values are +``mold``, ``lld``, ``gold``, ``bfd``, or ``default``. The ``default`` +option will use the system default linker otherwise, the linker is +chosen explicitly. This option is only available for the GNU or Clang +C++ compilers. Tests for other components and utility functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -518,6 +521,8 @@ The following options are available. make fix-errordocs # remove error docs in header files make check-permissions # search for files with permissions issues make fix-permissions # correct permissions issues in files + make check-docs # search for several issues in the manual + make check-version # list files with pending release version tags make check # run all check targets from above These should help to make source and documentation files conforming diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 0ecf54f744..1f643a9d14 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -52,7 +52,6 @@ This is the list of packages that may require additional steps. * :ref:`ML-POD ` * :ref:`ML-QUIP ` * :ref:`MOLFILE ` - * :ref:`MSCG ` * :ref:`NETCDF ` * :ref:`OPENMP ` * :ref:`OPT ` @@ -140,6 +139,8 @@ CMake build # value = yes or no (default) -D CUDA_MPS_SUPPORT=value # enables some tweaks required to run with active nvidia-cuda-mps daemon # value = yes or no (default) + -D CUDA_BUILD_MULTIARCH=value # enables building CUDA kernels for all supported GPU architectures + # value = yes (default) or no -D USE_STATIC_OPENCL_LOADER=value # downloads/includes OpenCL ICD loader library, no local OpenCL headers/libs needed # value = yes (default) or no @@ -158,41 +159,49 @@ CMake build 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 will try -to include support for **all** major GPU architectures supported by this toolkit. -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. +CMake can detect which version of the CUDA toolkit is used and thus will +try to include support for **all** major GPU architectures supported by +this toolkit. 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. This behavior can be turned off (e.g. to speed up compilation) by +setting :code:`CUDA_ENABLE_MULTIARCH` to :code:`no`. -When compiling for CUDA or HIP with CUDA, version 8.0 or later of the CUDA toolkit -is required and a GPU architecture of Kepler or later, which must *also* be -supported by the CUDA toolkit in use **and** the CUDA driver in use. -When compiling for OpenCL, OpenCL version 1.2 or later is required and the -GPU must be supported by the GPU driver and OpenCL runtime bundled with the driver. +When compiling for CUDA or HIP with CUDA, version 8.0 or later of the +CUDA toolkit is required and a GPU architecture of Kepler or later, +which must *also* be supported by the CUDA toolkit in use **and** the +CUDA driver in use. When compiling for OpenCL, OpenCL version 1.2 or +later is required and the GPU must be supported by the GPU driver and +OpenCL runtime bundled with the driver. -When building with CMake, you **must NOT** build the GPU library in ``lib/gpu`` -using the traditional build procedure. CMake will detect files generated by that -process and will terminate with an error and a suggestion for how to remove them. +When building with CMake, you **must NOT** build the GPU library in +``lib/gpu`` using the traditional build procedure. CMake will detect +files generated by that process and will terminate with an error and a +suggestion for how to remove them. -If you are compiling for OpenCL, the default setting is to download, build, and -link with a static OpenCL ICD loader library and standard OpenCL headers. This -way no local OpenCL development headers or library needs to be present and only -OpenCL compatible drivers need to be installed to use OpenCL. If this is not -desired, you can set :code:`USE_STATIC_OPENCL_LOADER` to :code:`no`. +If you are compiling for OpenCL, the default setting is to download, +build, and link with a static OpenCL ICD loader library and standard +OpenCL headers. This way no local OpenCL development headers or library +needs to be present and only OpenCL compatible drivers need to be +installed to use OpenCL. If this is not desired, you can set +:code:`USE_STATIC_OPENCL_LOADER` to :code:`no`. -The GPU library has some multi-thread support using OpenMP. If LAMMPS is built -with ``-D BUILD_OMP=on`` this will also be enabled. +The GPU library has some multi-thread support using OpenMP. If LAMMPS +is built with ``-D BUILD_OMP=on`` this will also be enabled. -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` (for ROCm <= 4.0) or :code:`CUDA_PATH` are necessary for :code:`hipcc` -and the linker to work correctly. +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` (for ROCm <= 4.0) or :code:`CUDA_PATH` are +necessary for :code:`hipcc` and the linker to work correctly. -Using CHIP-SPV implementation of HIP is now supported. It allows one to run HIP -code on Intel GPUs via the OpenCL or Level Zero backends. To use CHIP-SPV, you must -set :code:`-DHIP_USE_DEVICE_SORT=OFF` in your CMake command line as CHIP-SPV does not -yet support hipCUB. The use of HIP for Intel GPUs is still experimental so you -should only use this option in preparations to run on Aurora system at ANL. +.. versionadded:: 3Aug2022 + +Using the CHIP-SPV implementation of HIP is supported. It allows one to +run HIP code on Intel GPUs via the OpenCL or Level Zero backends. To use +CHIP-SPV, you must set :code:`-DHIP_USE_DEVICE_SORT=OFF` in your CMake +command line as CHIP-SPV does not yet support hipCUB. As of Summer 2022, +the use of HIP for Intel GPUs is experimental. You should only use this +option in preparations to run on Aurora system at Argonne. .. code:: bash @@ -617,18 +626,24 @@ They must be specified in uppercase. * - HOPPER90 - GPU - NVIDIA Hopper generation CC 9.0 GPU - * - VEGA900 + * - AMD_GFX906 - GPU - - AMD GPU MI25 GFX900 - * - VEGA906 + - AMD GPU MI50/MI60 + * - AMD_GFX908 - GPU - - AMD GPU MI50/MI60 GFX906 - * - VEGA908 + - AMD GPU MI100 + * - AMD_GFX90A - GPU - - AMD GPU MI100 GFX908 - * - VEGA90A + - AMD GPU MI200 + * - AMD_GFX942 - GPU - - AMD GPU MI200 GFX90A + - AMD GPU MI300 + * - AMD_GFX1030 + - GPU + - AMD GPU V620/W6800 + * - AMD_GFX1100 + - GPU + - AMD GPU RX7900XTX * - INTEL_GEN - GPU - SPIR64-based devices, e.g. Intel GPUs, using JIT @@ -651,7 +666,7 @@ They must be specified in uppercase. - GPU - Intel GPU Ponte Vecchio -This list was last updated for version 3.7.1 of the Kokkos library. +This list was last updated for version 4.2 of the Kokkos library. .. tabs:: @@ -707,9 +722,10 @@ This list was last updated for version 3.7.1 of the Kokkos library. ``cmake/presets`` folder, ``kokkos-serial.cmake``, ``kokkos-openmp.cmake``, ``kokkos-cuda.cmake``, ``kokkos-hip.cmake``, and ``kokkos-sycl.cmake``. They will enable - the KOKKOS package and enable some hardware choice. So to compile - with CUDA device parallelization (for GPUs with CC 5.0 and up) - with some common packages enabled, you can do the following: + the KOKKOS package and enable some hardware choices. For GPU + support those preset files must be customized to match the + hardware used. So to compile with CUDA device parallelization with + some common packages enabled, you can do the following: .. code-block:: bash @@ -871,6 +887,50 @@ included in the LAMMPS source distribution in the ``lib/lepton`` folder. ---------- +.. _machdyn: + +MACHDYN package +------------------------------- + +To build with this package, you must download the Eigen3 library. +Eigen3 is a template library, so you do not need to build it. + +.. tabs:: + + .. tab:: CMake build + + .. 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 inside the CMake build directory. If the Eigen3 + library is already on your system (in a location where CMake + cannot find it), set ``EIGEN3_INCLUDE_DIR`` to the directory the + ``Eigen3`` include file is in. + + .. tab:: Traditional make + + You can download the Eigen3 library manually if you prefer; follow + the instructions in ``lib/machdyn/README``. You can also do it in one + step from the ``lammps/src`` dir, using a command like these, + which simply invokes the ``lib/machdyn/Install.py`` script with the + specified args: + + .. code-block:: bash + + make lib-machdyn # print help message + make lib-machdyn args="-b" # download to lib/machdyn/eigen3 + make lib-machdyn 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/machdyn`` to point to the Eigen dir. When LAMMPS builds it + will use this link. You should not need to edit the + ``lib/machdyn/Makefile.lammps`` file. + +---------- + .. _mliap: ML-IAP package @@ -921,59 +981,6 @@ Python version 3.6 or later. ---------- -.. _mscg: - -MSCG package ------------------------ - -To build with this package, you must download and build the MS-CG -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. - -.. tabs:: - - .. tab:: CMake build - - .. 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 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 filename (plus path) of the MSCG library - file, not the directory the library file is in. - ``MSCG_INCLUDE_DIR`` is the directory the MSCG include file is in. - - .. tab:: 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 invokes the - ``lib/mscg/Install.py`` script with the specified args: - - .. code-block:: bash - - 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 - # 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 - - 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. - ----------- - .. _opt: OPT package @@ -1049,12 +1056,12 @@ additional details. .. code-block:: bash - -D PYTHON_EXECUTABLE=path # path to Python executable to use + -D Python_EXECUTABLE=path # path to Python executable to use Without this setting, CMake will guess the default Python version 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 + set the 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. @@ -1469,6 +1476,55 @@ ML-POD package ---------- +.. _ml-quip: + +ML-QUIP package +--------------------------------- + +To build with this package, you must download and build the QUIP +library. It can be obtained from GitHub. For support of GAP +potentials, additional files with specific licensing conditions need +to be downloaded and configured. The automatic download will from +within CMake will download the non-commercial use version. + +.. tabs:: + + .. tab:: CMake build + + .. code-block:: bash + + -D DOWNLOAD_QUIP=value # download QUIP library for build, value = no (default) or yes + -D QUIP_LIBRARY=path # path to libquip.a (only needed if a custom location) + -D USE_INTERNAL_LINALG=value # Use the internal linear algebra library instead of LAPACK + # value = no (default) or yes + + CMake will try to download and build the QUIP library from GitHub, + if it is not found on the local machine. This requires to have git + installed. It will use the same compilers and flags as used for + compiling LAMMPS. Currently this is only supported for the GNU + and the Intel compilers. Set the ``QUIP_LIBRARY`` variable if you + want to use a previously compiled and installed QUIP library and + CMake cannot find it. + + The QUIP library requires LAPACK (and BLAS) and CMake can identify + their locations and pass that info to the QUIP build script. But + on some systems this triggers a (current) limitation of CMake and + the configuration will fail. Try enabling ``USE_INTERNAL_LINALG`` in + those cases to use the bundled linear algebra library and work around + the limitation. + + .. tab:: 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 ``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. + +---------- + .. _plumed: PLUMED package @@ -1990,55 +2046,6 @@ verified to work in February 2020 with Quantum Espresso versions 6.3 to ---------- -.. _ml-quip: - -ML-QUIP package ---------------------------------- - -To build with this package, you must download and build the QUIP -library. It can be obtained from GitHub. For support of GAP -potentials, additional files with specific licensing conditions need -to be downloaded and configured. The automatic download will from -within CMake will download the non-commercial use version. - -.. tabs:: - - .. tab:: CMake build - - .. code-block:: bash - - -D DOWNLOAD_QUIP=value # download QUIP library for build, value = no (default) or yes - -D QUIP_LIBRARY=path # path to libquip.a (only needed if a custom location) - -D USE_INTERNAL_LINALG=value # Use the internal linear algebra library instead of LAPACK - # value = no (default) or yes - - CMake will try to download and build the QUIP library from GitHub, - if it is not found on the local machine. This requires to have git - installed. It will use the same compilers and flags as used for - compiling LAMMPS. Currently this is only supported for the GNU - and the Intel compilers. Set the ``QUIP_LIBRARY`` variable if you - want to use a previously compiled and installed QUIP library and - CMake cannot find it. - - The QUIP library requires LAPACK (and BLAS) and CMake can identify - their locations and pass that info to the QUIP build script. But - on some systems this triggers a (current) limitation of CMake and - the configuration will fail. Try enabling ``USE_INTERNAL_LINALG`` in - those cases to use the bundled linear algebra library and work around - the limitation. - - .. tab:: 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 ``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. - ----------- - .. _scafacos: SCAFACOS package @@ -2086,50 +2093,6 @@ To build with this package, you must download and build the ---------- -.. _machdyn: - -MACHDYN package -------------------------------- - -To build with this package, you must download the Eigen3 library. -Eigen3 is a template library, so you do not need to build it. - -.. tabs:: - - .. tab:: CMake build - - .. 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 inside the CMake build directory. If the Eigen3 - library is already on your system (in a location where CMake - cannot find it), set ``EIGEN3_INCLUDE_DIR`` to the directory the - ``Eigen3`` include file is in. - - .. tab:: Traditional make - - You can download the Eigen3 library manually if you prefer; follow - the 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 invokes the ``lib/smd/Install.py`` script with the - specified args: - - .. code-block:: bash - - 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. - ----------- - .. _vtk: VTK package diff --git a/doc/src/Build_manual.rst b/doc/src/Build_manual.rst index e9a55134da..4b4bfa5a45 100644 --- a/doc/src/Build_manual.rst +++ b/doc/src/Build_manual.rst @@ -52,7 +52,7 @@ can be translated to different output format using the `Sphinx incorporates programmer documentation extracted from the LAMMPS C++ sources through the `Doxygen `_ program. Currently the translation to HTML, PDF (via LaTeX), ePUB (for many e-book readers) -and MOBI (for Amazon Kindle(tm) readers) are supported. For that to work a +and MOBI (for Amazon Kindle readers) are supported. For that to work a Python interpreter version 3.8 or later, the ``doxygen`` tools and internet access to download additional files and tools are required. This download is usually only required once or after the documentation diff --git a/doc/src/Build_package.rst b/doc/src/Build_package.rst index 2328e4d1e5..63ccac534d 100644 --- a/doc/src/Build_package.rst +++ b/doc/src/Build_package.rst @@ -55,7 +55,6 @@ packages: * :ref:`ML-POD ` * :ref:`ML-QUIP ` * :ref:`MOLFILE ` - * :ref:`MSCG ` * :ref:`NETCDF ` * :ref:`OPENMP ` * :ref:`OPT ` @@ -183,6 +182,7 @@ make a copy of one of them and modify it to suit 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 mingw64-cmake -C ../cmake/presets/mingw-cross.cmake [OPTIONS] ../cmake # compile with MinGW cross-compilers + cmake -C ../cmake/presets/macos-multiarch.cmake [OPTIONS] ../cmake # compile serial multi-arch binaries on macOS Presets that have names starting with "windows" are specifically for compiling LAMMPS :doc:`natively on Windows ` and diff --git a/doc/src/Build_settings.rst b/doc/src/Build_settings.rst index c2e7b94b0e..7fb7539506 100644 --- a/doc/src/Build_settings.rst +++ b/doc/src/Build_settings.rst @@ -44,6 +44,14 @@ 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. +.. versionadded:: TBD + +Alternatively, LAMMPS can use the `heFFTe +`_ library for the MPI +communication algorithms, which comes with many optimizations for +special cases, e.g. leveraging available 2D and 3D FFTs in the back end +libraries and better pipelining for packing and communication. + .. tabs:: .. tab:: CMake build @@ -53,6 +61,7 @@ LAMMPS can use them if they are available on your system. -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 -D FFT_PACK=value # array (default) or pointer or memcpy + -D FFT_USE_HEFFTE=value # yes or no (default), yes links to heFFTe .. note:: @@ -76,6 +85,16 @@ LAMMPS can use them if they are available on your system. -D MKL_INCLUDE_DIR=path # ditto for Intel MKL library -D FFT_MKL_THREADS=on # enable using threaded FFTs with MKL libraries -D MKL_LIBRARY=path # path to MKL libraries + -D FFT_HEFFTE_BACKEND=value # FFTW or MKL or empty/undefined for the stock heFFTe back end + -D Heffte_ROOT=path # path to an existing heFFTe installation + + .. note:: + + heFFTe comes with a builtin (= stock) back end for FFTs, i.e. a + default internal FFT implementation; however, this stock back + end is intended for testing purposes only and is not optimized + for production runs. + .. tab:: Traditional make @@ -111,6 +130,24 @@ LAMMPS can use them if they are available on your system. files in its default search path. You must specify ``FFT_LIB`` with the appropriate FFT libraries to include in the link. + Traditional make can also link to heFFTe using an existing installation + + .. code-block:: make + + include /share/heffte/HeffteMakefile.in + FFT_INC = -DFFT_HEFFTE -DFFT_HEFFTE_FFTW $(heffte_include) + FFT_PATH = + FFT_LIB = $(heffte_link) $(heffte_libs) + + The heFFTe install path will contain `HeffteMakefile.in`. + which will define the `heffte_` include variables needed to link to heFFTe from + an external project using traditional make. + The `-DFFT_HEFFTE` is required to switch to using heFFTe, while the optional `-DFFT_HEFFTE_FFTW` + selects the desired heFFTe back end, e.g., `-DFFT_HEFFTE_FFTW` or `-DFFT_HEFFTE_MKL`, + omitting the variable will default to the `stock` back end. + The heFFTe `stock` back end is intended to be used for testing and debugging, + but is not performance optimized for large scale production runs. + 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 @@ -170,6 +207,16 @@ 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. +When using ``-DFFT_HEFFTE`` CMake will first look for an existing +install with hints provided by ``-DHeffte_ROOT``, as recommended by the +CMake standard and note that the name is case sensitive. If CMake cannot +find a heFFTe installation with the correct back end (e.g., FFTW or +MKL), it will attempt to download and build the library automatically. +In this case, LAMMPS CMake will also accept all heFFTe specific +variables listed in the `heFFTe documentation +`_ +and those variables will be passed into the heFFTe build. + ---------- .. _size: @@ -459,27 +506,13 @@ those systems: .. _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 calling code. -Instead, the call stack is unwound and control returns to the caller, -e.g. to Python. Of course, the calling code has to be set up to -*catch* exceptions thrown from within LAMMPS. - -.. tabs:: - - .. tab:: CMake build - - .. code-block:: bash - - -D LAMMPS_EXCEPTIONS=value # yes or no (default) - - .. tab:: Traditional make - - .. code-block:: make - - LMP_INC = -DLAMMPS_EXCEPTIONS +LAMMPS errors do not kill the calling code, but throw an exception. In +the C-library interface, the call stack is unwound and control returns +to the caller, e.g. to Python or a code that is coupled to LAMMPS. The +error status can then be queried. When using C++ directly, the calling +code has to be set up to *catch* exceptions thrown from within LAMMPS. .. note:: diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 755000c976..0352ad5374 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -91,6 +91,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`ke/atom/eff ` * :doc:`ke/eff ` * :doc:`ke/rigid ` + * :doc:`composition/atom (k) ` * :doc:`mliap ` * :doc:`momentum ` * :doc:`msd ` @@ -99,6 +100,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`nbond/atom ` * :doc:`omega/chunk ` * :doc:`orientorder/atom (k) ` + * :doc:`pace ` * :doc:`pair ` * :doc:`pair/local ` * :doc:`pe ` @@ -114,12 +116,15 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`property/grid ` * :doc:`property/local ` * :doc:`ptm/atom ` + * :doc:`rattlers/atom ` * :doc:`rdf ` + * :doc:`reaxff/atom (k) ` * :doc:`reduce ` * :doc:`reduce/chunk ` * :doc:`reduce/region ` * :doc:`rigid/local ` * :doc:`saed ` + * :doc:`slcsa/atom ` * :doc:`slice ` * :doc:`smd/contact/radius ` * :doc:`smd/damage ` @@ -153,11 +158,11 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`sph/t/atom ` * :doc:`spin ` * :doc:`stress/atom ` - * :doc:`stress/cartesian ` - * :doc:`stress/cylinder ` + * :doc:`stress/cartesian ` + * :doc:`stress/cylinder ` * :doc:`stress/mop ` * :doc:`stress/mop/profile ` - * :doc:`stress/spherical ` + * :doc:`stress/spherical ` * :doc:`stress/tally ` * :doc:`tdpd/cc/atom ` * :doc:`temp (k) ` diff --git a/doc/src/Commands_dump.rst b/doc/src/Commands_dump.rst index 870cb168ef..d7c8e73b58 100644 --- a/doc/src/Commands_dump.rst +++ b/doc/src/Commands_dump.rst @@ -23,17 +23,14 @@ An alphabetic list of all LAMMPS :doc:`dump ` commands. * :doc:`atom ` * :doc:`atom/adios ` * :doc:`atom/gz ` - * :doc:`atom/mpiio ` * :doc:`atom/zstd ` * :doc:`cfg ` * :doc:`cfg/gz ` - * :doc:`cfg/mpiio ` * :doc:`cfg/uef ` * :doc:`cfg/zstd ` * :doc:`custom ` * :doc:`custom/adios ` * :doc:`custom/gz ` - * :doc:`custom/mpiio ` * :doc:`custom/zstd ` * :doc:`dcd ` * :doc:`grid ` @@ -51,7 +48,6 @@ An alphabetic list of all LAMMPS :doc:`dump ` commands. * :doc:`xtc ` * :doc:`xyz ` * :doc:`xyz/gz ` - * :doc:`xyz/mpiio ` * :doc:`xyz/zstd ` * :doc:`yaml ` diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index 6fe321e3c9..e89e302673 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -69,7 +69,7 @@ OPT. * :doc:`drude/transform/inverse ` * :doc:`dt/reset (k) ` * :doc:`edpd/source ` - * :doc:`efield ` + * :doc:`efield (k) ` * :doc:`efield/tip4p ` * :doc:`ehex ` * :doc:`electrode/conp (i) ` @@ -116,13 +116,13 @@ OPT. * :doc:`momentum (k) ` * :doc:`momentum/chunk ` * :doc:`move ` - * :doc:`mscg ` * :doc:`msst ` * :doc:`mvv/dpd ` * :doc:`mvv/edpd ` * :doc:`mvv/tdpd ` * :doc:`neb ` * :doc:`neb/spin ` + * :doc:`nonaffine/displacement ` * :doc:`nph (ko) ` * :doc:`nph/asphere (o) ` * :doc:`nph/body ` @@ -182,6 +182,7 @@ OPT. * :doc:`pour ` * :doc:`precession/spin ` * :doc:`press/berendsen ` + * :doc:`press/langevin ` * :doc:`print ` * :doc:`propel/self ` * :doc:`property/atom (k) ` @@ -233,15 +234,15 @@ OPT. * :doc:`spring ` * :doc:`spring/chunk ` * :doc:`spring/rg ` - * :doc:`spring/self ` + * :doc:`spring/self (k) ` * :doc:`srd ` * :doc:`store/force ` * :doc:`store/state ` * :doc:`tdpd/source ` - * :doc:`temp/berendsen ` + * :doc:`temp/berendsen (k) ` * :doc:`temp/csld ` * :doc:`temp/csvr ` - * :doc:`temp/rescale ` + * :doc:`temp/rescale (k) ` * :doc:`temp/rescale/eff ` * :doc:`tfmc ` * :doc:`tgnpt/drude ` diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index c45a1d778c..e7761e7bee 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -87,7 +87,7 @@ OPT. * :doc:`coul/long/soft (o) ` * :doc:`coul/msm (o) ` * :doc:`coul/slater/cut ` - * :doc:`coul/slater/long ` + * :doc:`coul/slater/long (g) ` * :doc:`coul/shield ` * :doc:`coul/streitz ` * :doc:`coul/tt ` @@ -110,7 +110,7 @@ OPT. * :doc:`eam/he ` * :doc:`edip (o) ` * :doc:`edip/multi ` - * :doc:`edpd ` + * :doc:`edpd (g) ` * :doc:`eff/cut ` * :doc:`eim (o) ` * :doc:`exp6/rx (k) ` @@ -158,14 +158,14 @@ OPT. * :doc:`lj/cut (gikot) ` * :doc:`lj/cut/coul/cut (gko) ` * :doc:`lj/cut/coul/cut/dielectric (o) ` - * :doc:`lj/cut/coul/cut/soft (o) ` + * :doc:`lj/cut/coul/cut/soft (go) ` * :doc:`lj/cut/coul/debye (gko) ` * :doc:`lj/cut/coul/debye/dielectric (o) ` * :doc:`lj/cut/coul/dsf (gko) ` * :doc:`lj/cut/coul/long (gikot) ` * :doc:`lj/cut/coul/long/cs ` * :doc:`lj/cut/coul/long/dielectric (o) ` - * :doc:`lj/cut/coul/long/soft (o) ` + * :doc:`lj/cut/coul/long/soft (go) ` * :doc:`lj/cut/coul/msm (go) ` * :doc:`lj/cut/coul/msm/dielectric ` * :doc:`lj/cut/coul/wolf (o) ` @@ -202,7 +202,7 @@ OPT. * :doc:`lubricate/poly (o) ` * :doc:`lubricateU ` * :doc:`lubricateU/poly ` - * :doc:`mdpd ` + * :doc:`mdpd (g) ` * :doc:`mdpd/rhosum ` * :doc:`meam (k) ` * :doc:`meam/ms (k) ` @@ -220,7 +220,8 @@ OPT. * :doc:`morse/soft ` * :doc:`multi/lucy ` * :doc:`multi/lucy/rx (k) ` - * :doc:`nb3b/harmonic ` + * :doc:`nb3b/harmonic ` + * :doc:`nb3b/screened ` * :doc:`nm/cut (o) ` * :doc:`nm/cut/coul/cut (o) ` * :doc:`nm/cut/coul/long (o) ` @@ -265,13 +266,13 @@ OPT. * :doc:`smd/tri_surface ` * :doc:`smd/ulsph ` * :doc:`smtbq ` - * :doc:`snap (k) ` + * :doc:`snap (ik) ` * :doc:`soft (go) ` - * :doc:`sph/heatconduction ` + * :doc:`sph/heatconduction (g) ` * :doc:`sph/idealgas ` - * :doc:`sph/lj ` + * :doc:`sph/lj (g) ` * :doc:`sph/rhosum ` - * :doc:`sph/taitwater ` + * :doc:`sph/taitwater (g) ` * :doc:`sph/taitwater/morris ` * :doc:`spin/dipole/cut ` * :doc:`spin/dipole/long ` @@ -305,5 +306,5 @@ OPT. * :doc:`wf/cut ` * :doc:`ylz ` * :doc:`yukawa (gko) ` - * :doc:`yukawa/colloid (go) ` + * :doc:`yukawa/colloid (gko) ` * :doc:`zbl (gko) ` diff --git a/doc/src/Commands_removed.rst b/doc/src/Commands_removed.rst index d50eab3a41..98a52fc2d7 100644 --- a/doc/src/Commands_removed.rst +++ b/doc/src/Commands_removed.rst @@ -41,7 +41,7 @@ warning. LATTE package ------------- -.. deprecated:: TBD +.. deprecated:: 15Jun2023 The LATTE package with the fix latte command was removed from LAMMPS. This functionality has been superseded by :doc:`fix mdi/qm ` @@ -85,6 +85,35 @@ The same functionality is available through :doc:`bond style mesocnt ` and :doc:`angle style mesocnt `. +MPIIO package +------------- + +.. deprecated:: 21Nov2023 + +The MPIIO package has been removed from LAMMPS since it was unmaintained +for many years and thus not updated to incorporate required changes that +had been applied to the corresponding non-MPIIO commands. As a +consequence the MPIIO commands had become unreliable and sometimes +crashing LAMMPS or corrupting data. Similar functionality is available +through the :ref:`ADIOS package ` and the :ref:`NETCDF +package `. Also, the :doc:`dump_modify nfile or dump_modify +fileper ` keywords may be used for an efficient way of +writing out dump files when running on large numbers of processors. +Similarly, the "nfile" and "fileper" keywords exist for restarts: +see :doc:`restart `, :doc:`read_restart `, +:doc:`write_restart `. + + +MSCG package +------------ + +.. deprecated:: 21Nov2023 + +The MSCG package has been removed from LAMMPS since it was unmaintained +for many years and instead superseded by the `OpenMSCG software +`_ of the Voth group at the +University of Chicago, which can be used independent from LAMMPS. + REAX package ------------ @@ -97,6 +126,17 @@ syntax compatible with the removed reax pair style, so input files will have to be adapted. The REAXFF package was originally called USER-REAXC. +USER-REAXC package +------------------ + +.. deprecated:: TBD + +The USER-REAXC package has been renamed to :ref:`REAXFF `. +In the process also the pair style and related fixes were renamed to use +the "reaxff" string instead of "reax/c". For a while LAMMPS was maintaining +backward compatibility by providing aliases for the styles. These have +been removed, so using "reaxff" is now *required*. + USER-CUDA package ----------------- diff --git a/doc/src/Developer_grid.rst b/doc/src/Developer_grid.rst index cd6d8d12ab..22eadd5da8 100644 --- a/doc/src/Developer_grid.rst +++ b/doc/src/Developer_grid.rst @@ -92,8 +92,8 @@ Arguments for these methods can be values returned by the *setup_grid()* method (described below), which define the extent of the grid cells (owned+ghost) the processor owns. These 4 methods allocate memory for 2d (first two) and 3d (second two) grid data. The -two methods that end in "_one" allocate an array which stores a single -value per grid cell. The two that end in "_multi" allocate an array +two methods that end in "_offset" allocate an array which stores a single +value per grid cell. The two that end in "_last" allocate an array which stores *Nvalues* per grid cell. .. code-block:: c++ diff --git a/doc/src/Developer_platform.rst b/doc/src/Developer_platform.rst index cdc4bb6770..9b05299146 100644 --- a/doc/src/Developer_platform.rst +++ b/doc/src/Developer_platform.rst @@ -70,6 +70,9 @@ File and path functions and global constants .. doxygenfunction:: is_console :project: progguide +.. doxygenfunction:: disk_free + :project: progguide + .. doxygenfunction:: path_is_directory :project: progguide diff --git a/doc/src/Developer_unittest.rst b/doc/src/Developer_unittest.rst index 9886e9e4b4..b48c3b4e17 100644 --- a/doc/src/Developer_unittest.rst +++ b/doc/src/Developer_unittest.rst @@ -121,7 +121,7 @@ will be suppressed and only a summary printed, but adding the '-V' option will then produce output from the tests above like the following: -.. code-block:: +.. code-block:: console [...] 1: [ RUN ] Tokenizer.empty_string @@ -180,19 +180,11 @@ discarded but by setting the verbose flag (via setting the ``TEST_ARGS`` environment variable, ``TEST_ARGS=-v``) it can be printed and used to understand why tests fail unexpectedly. -Another complexity of these tests stems from the need to capture -situations where LAMMPS will stop with an error, i.e. handle so-called -"death tests". Here the LAMMPS code will operate differently depending -on whether it was configured to throw C++ exceptions on errors or call -either ``exit()`` or ``MPI_Abort()``. In the latter case, the test code -also needs to detect whether LAMMPS was compiled with the OpenMPI -library, as OpenMPI is **only** compatible the death test options of the -GoogleTest library when C++ exceptions are enabled; otherwise those -"death tests" must be skipped to avoid reporting bogus failures. The -specifics of this step are implemented in the ``TEST_FAILURE()`` -macro. These tests operate by capturing the screen output when executing -the failing command and then comparing that with a provided regular -expression string pattern. Example: +The specifics of so-called "death tests", i.e. conditions where LAMMPS +should fail and throw an exception, are implemented in the +``TEST_FAILURE()`` macro. These tests operate by capturing the screen +output when executing the failing command and then comparing that with a +provided regular expression string pattern. Example: .. code-block:: c++ @@ -282,9 +274,7 @@ Tests for using the Fortran module are in the ``unittest/fortran`` folder. Since they are also using the GoogleTest library, they require to also implement test wrappers in C++ that will call fortran functions which provide a C function interface through ISO_C_BINDINGS that will in -turn call the functions in the LAMMPS Fortran module. This part of the -unit tests is incomplete since the Fortran module it is based on is -incomplete as well. +turn call the functions in the LAMMPS Fortran module. Tests for the C++-style library interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -405,10 +395,10 @@ compare with the reference and also start from the data file. A final check will use multi-cutoff r-RESPA (if supported by the pair style) at a 1:1 split and compare to the Verlet results. These sets of tests are run with multiple test fixtures for accelerated styles (OPT, OPENMP, -INTEL) and for the latter two with 4 OpenMP threads enabled. For -these tests the relative error (epsilon) is lowered by a common factor -due to the additional numerical noise, but the tests are still comparing -to the same reference data. +INTEL, KOKKOS (OpenMP only)) and for the latter three with 4 OpenMP +threads enabled. For these tests the relative error (epsilon) is lowered +by a common factor due to the additional numerical noise, but the tests +are still comparing to the same reference data. Additional tests will check whether all listed extract keywords are supported and have the correct dimensionality and the final set of tests @@ -442,17 +432,19 @@ The ``test_pair_style`` tester is used with 4 categories of test inputs: pair style is defined, but the computation of the pair style contributions is disabled. -The ``test_bond_style`` and ``test_angle_style`` are set up in a similar -fashion and share support functions with the pair style tester. The final -group of tests in this section is for fix styles that add/manipulate forces -and velocities, e.g. for time integration, thermostats and more. +The ``test_bond_style``, ``test_angle_style``, ``test_dihedral_style``, and +``test_improper_style`` tester programs are set up in a similar fashion and +share support functions with the pair style tester. The final group of +tests in this section is for fix styles that add/manipulate forces and +velocities, e.g. for time integration, thermostats and more. -Adding a new test is easiest done by copying and modifying an existing test -for a style that is similar to one to be tested. The file name should follow -the naming conventions described above and after copying the file, the first -step is to replace the style names where needed. The coefficient values -do not have to be meaningful, just in a reasonable range for the given system. -It does not matter if some forces are large, for as long as they do not diverge. +Adding a new test is easiest done by copying and modifying an existing YAML +file for a style that is similar to one to be tested. The file name should +follow the naming conventions described above and after copying the file, +the first step is to replace the style names where needed. The coefficient +values do not have to be meaningful, just in a reasonable range for the +given system. It does not matter if some forces are large, for as long as +they do not diverge. The template input files define a large number of index variables at the top that can be modified inside the YAML file to control the behavior. For example, @@ -480,7 +472,7 @@ Note that this disables computing the kspace contribution, but still will run the setup. The "gewald" parameter should be set explicitly to speed up the run. For styles with long-range electrostatics, typically two tests are added one using the (slower) analytic approximation of the erfc() function and the other using -the tabulated coulomb, to test both code paths. The reference results in the YAML +the tabulated coulomb, to test both code paths. The reference results in the YAML files then should be compared manually, if they agree well enough within the limits of those two approximations. @@ -534,3 +526,102 @@ The ``unittest/tools`` folder contains tests for programs in the shell, which are implemented as a python scripts using the ``unittest`` Python module and launching the tool commands through the ``subprocess`` Python module. + + +Troubleshooting failed unit tests +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The are by default no unit tests for newly added features (e.g. pair, fix, +or compute styles) unless your pull request also includes tests for the +added features. If you are modifying some features, you may see failures +for existing tests, if your modifications have some unexpected side effects +or your changes render the existing text invalid. If you are adding an +accelerated version of an existing style, then only tests for INTEL, +KOKKOS (with OpenMP only), OPENMP, and OPT will be run automatically. +Tests for the GPU package are time consuming and thus are only run +*after* a merge, or when a special label, ``gpu_unit_tests`` is added +to the pull request. After the test has started, it is often best to +remove the label since every PR activity will re-trigger the test (that +is a limitation of triggering a test with a label). Support for unit +tests with using KOKKOS with GPU acceleration is currently not supported. + +When you see a failed build on GitHub, click on ``Details`` to be taken +to the corresponding LAMMPS Jenkins CI web page. Click on the "Exit" +symbol near the ``Logout`` button on the top right of that page to go to +the "classic view". In the classic view, there is a list of the +individual runs that make up this test run (they are shown but cannot be +inspected in the default view). You can click on any of those. +Clicking on ``Test Result`` will display the list of failed tests. Click +on the "Status" column to sort the tests based on their Failed or Passed +status. Then click on the failed test to expand its output. + +For example, the following output snippet shows the failed unit test + +.. code-block:: console + + [ RUN ] PairStyle.gpu + /home/builder/workspace/dev/pull_requests/ubuntu_gpu/unit_tests/cmake_gpu_opencl_mixed_smallbig_clang_static/unittest/force-styles/test_main.cpp:63: Failure + Expected: (err) <= (epsilon) + Actual: 0.00018957912910606503 vs 0.0001 + Google Test trace: + /home/builder/workspace/dev/pull_requests/ubuntu_gpu/unit_tests/cmake_gpu_opencl_mixed_smallbig_clang_static/unittest/force-styles/test_main.cpp:56: EXPECT_FORCES: init_forces (newton off) + /home/builder/workspace/dev/pull_requests/ubuntu_gpu/unit_tests/cmake_gpu_opencl_mixed_smallbig_clang_static/unittest/force-styles/test_main.cpp:64: Failure + Expected: (err) <= (epsilon) + Actual: 0.00022892713393549854 vs 0.0001 + +The failed assertions provide line numbers in the test source +(e.g. ``test_main.cpp:56``), from which one can understand what +specific assertion failed. + +Note that the force style engine runs one of a small number of systems +in a rather off-equilibrium configuration with a few atoms for a few +steps, writes data and restart files, uses :doc:`the clear command +` to reset LAMMPS, and then runs from those files with different +settings (e.g. newton on/off) and integrators (e.g. verlet vs. respa). +Beyond potential issues/bugs in the source code, the mismatch between +the expected and actual values could be that force arrays are not +properly cleared between multiple run commands or that class members are +not correctly initialized or written to or read from a data or restart +file. + +While the epsilon (relative precision) for a single, `IEEE 754 compliant +`_, double precision floating +point operation is at about 2.2e-16, the achievable precision for the +tests is lower due to most numbers being sums over intermediate results +and the non-associativity of floating point math leading to larger +errors. In some cases specific properties of the tested style. As a +rule of thumb, the test epsilon can often be in the range 5.0e-14 to +1.0e-13. But for "noisy" force kernels, e.g. those a larger amount of +arithmetic operations involving `exp()`, `log()` or `sin()` functions, +and also due to the effect of compiler optimization or differences +between compilers or platforms, epsilon may need to be further relaxed, +sometimes epsilon can be relaxed to 1.0e-12. If interpolation or lookup +tables are used, epsilon may need to be set to 1.0e-10 or even higher. +For tests of accelerated styles, the per-test epsilon is multiplied +by empirical factors that take into account the differences in the order +of floating point operations or that some or most intermediate operations +may be done using approximations or with single precision floating point +math. + +To rerun the failed unit test individually, change to the ``build`` directory +and run the test with verbose output. For example, + +.. code-block:: bash + + env TEST_ARGS=-v ctest -R ^MolPairStyle:lj_cut_coul_long -V + +``ctest`` with the ``-V`` flag also shows the exact command line +of the test. One can then use ``gdb --args`` to further debug and +catch exceptions with the test command, for example, + +.. code-block:: bash + + gdb --args /path/to/lammps/build/test_pair_style /path/to/lammps/unittest/force-styles/tests/mol-pair-lj_cut_coul_long.yaml + + +It is recommended to configure the build with ``-D +BUILD_SHARED_LIBS=on`` and use a custom linker to shorten the build time +during recompilation. Installing `ccache` in your development +environment helps speed up recompilation by caching previous +compilations and detecting when the same compilation is being done +again. Please see :doc:`Build_development` for further details. diff --git a/doc/src/Errors_messages.rst b/doc/src/Errors_messages.rst index 293cf6ab53..bfdba4f6a1 100644 --- a/doc/src/Errors_messages.rst +++ b/doc/src/Errors_messages.rst @@ -7148,9 +7148,6 @@ keyword to allow for additional bonds to be formed *Read_dump xyz fields do not have consistent scaling/wrapping* Self-explanatory. -*Reading from MPI-IO filename when MPIIO package is not installed* - Self-explanatory. - *Reax_defs.h setting for NATDEF is too small* Edit the setting in the ReaxFF library and re-compile the library and re-build LAMMPS. @@ -8489,9 +8486,6 @@ keyword to allow for additional bonds to be formed The write_restart command cannot be used before a read_data, read_restart, or create_box command. -*Writing to MPI-IO filename when MPIIO package is not installed* - Self-explanatory. - *Zero length rotation vector with displace_atoms* Self-explanatory. diff --git a/doc/src/Examples.rst b/doc/src/Examples.rst index f2ca9a43ce..c5da4a498b 100644 --- a/doc/src/Examples.rst +++ b/doc/src/Examples.rst @@ -104,8 +104,6 @@ Lowercase directories +-------------+------------------------------------------------------------------+ | min | energy minimization of 2d LJ melt | +-------------+------------------------------------------------------------------+ -| mscg | parameterize a multi-scale coarse-graining (MSCG) model | -+-------------+------------------------------------------------------------------+ | msst | MSST shock dynamics | +-------------+------------------------------------------------------------------+ | multi | multi neighboring for systems with large interaction disparities | diff --git a/doc/src/Fortran.rst b/doc/src/Fortran.rst index 92a42997b8..76fdff753a 100644 --- a/doc/src/Fortran.rst +++ b/doc/src/Fortran.rst @@ -56,17 +56,6 @@ C++ in the ``examples/COUPLE/simple`` folder of the LAMMPS distribution. and Ubuntu 18.04 LTS and not compatible. Either newer compilers need to be installed or the Linux updated. -.. versionchanged:: 8Feb2023 - -.. note:: - - A contributed Fortran interface is available in the - ``examples/COUPLE/fortran2`` folder. However, since the completion - of the :f:mod:`LIBLAMMPS` module, this interface is now deprecated, - no longer actively maintained and will likely be removed in the - future. Please see the ``README`` file in that folder for more - information about it and how to contact its author and maintainer. - ---------- Creating or deleting a LAMMPS object @@ -203,40 +192,62 @@ Below is an example demonstrating some of the possible uses. .. code-block:: fortran - PROGRAM testprop - USE LIBLAMMPS - USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_double, c_int64_t - USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : OUTPUT_UNIT - TYPE(lammps) :: lmp - INTEGER(KIND=c_int64_t), POINTER :: natoms - REAL(KIND=c_double), POINTER :: dt - INTEGER(KIND=c_int64_t), POINTER :: ntimestep - REAL(KIND=c_double) :: pe, ke + PROGRAM testprop + USE LIBLAMMPS + USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_double, c_int64_t, c_int + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : OUTPUT_UNIT + TYPE(lammps) :: lmp + INTEGER(KIND=c_int64_t), POINTER :: natoms, ntimestep, bval + REAL(KIND=c_double), POINTER :: dt, dval + INTEGER(KIND=c_int), POINTER :: nfield, typ, ival + INTEGER(KIND=c_int) :: i + CHARACTER(LEN=11) :: key + REAL(KIND=c_double) :: pe, ke - lmp = lammps() - CALL lmp%file('in.sysinit') - natoms = lmp%extract_global('natoms') - WRITE(OUTPUT_UNIT,'(A,I0,A)') 'Running a simulation with ', natoms, ' atoms' - WRITE(OUTPUT_UNIT,'(I0,A,I0,A,I0,A)') lmp%extract_setting('nlocal'), & - ' local and ', lmp%extract_setting('nghost'), ' ghost atoms. ', & - lmp%extract_setting('ntypes'), ' atom types' + lmp = lammps() + CALL lmp%file('in.sysinit') + natoms = lmp%extract_global('natoms') + WRITE(OUTPUT_UNIT,'(A,I0,A)') 'Running a simulation with ', natoms, ' atoms' + WRITE(OUTPUT_UNIT,'(I0,A,I0,A,I0,A)') lmp%extract_setting('nlocal'), & + ' local and ', lmp%extract_setting('nghost'), ' ghost atoms. ', & + lmp%extract_setting('ntypes'), ' atom types' - CALL lmp%command('run 2 post no') - dt = lmp%extract_global('dt') - ntimestep = lmp%extract_global('ntimestep') - WRITE(OUTPUT_UNIT,'(A,I0,A,F4.1,A)') 'At step: ', ntimestep, & - ' Changing timestep from', dt, ' to 0.5' - dt = 0.5_c_double - CALL lmp%command('run 2 post no') + CALL lmp%command('run 2 post no') - WRITE(OUTPUT_UNIT,'(A,I0)') 'At step: ', ntimestep - pe = lmp%get_thermo('pe') - ke = lmp%get_thermo('ke') - PRINT*, 'PE = ', pe - PRINT*, 'KE = ', ke + ntimestep = lmp%last_thermo('step', 0) + nfield = lmp%last_thermo('num', 0) + WRITE(OUTPUT_UNIT,'(A,I0,A,I0)') 'Last thermo output on step: ', ntimestep, & + ', number of fields: ', nfield + DO i=1, nfield + key = lmp%last_thermo('keyword',i) + typ = lmp%last_thermo('type',i) + IF (typ == lmp%dtype%i32) THEN + ival = lmp%last_thermo('data',i) + WRITE(OUTPUT_UNIT,*) key, ':', ival + ELSE IF (typ == lmp%dtype%i64) THEN + bval = lmp%last_thermo('data',i) + WRITE(OUTPUT_UNIT,*) key, ':', bval + ELSE IF (typ == lmp%dtype%r64) THEN + dval = lmp%last_thermo('data',i) + WRITE(OUTPUT_UNIT,*) key, ':', dval + END IF + END DO - CALL lmp%close(.TRUE.) - END PROGRAM testprop + dt = lmp%extract_global('dt') + ntimestep = lmp%extract_global('ntimestep') + WRITE(OUTPUT_UNIT,'(A,I0,A,F4.1,A)') 'At step: ', ntimestep, & + ' Changing timestep from', dt, ' to 0.5' + dt = 0.5_c_double + CALL lmp%command('run 2 post no') + + WRITE(OUTPUT_UNIT,'(A,I0)') 'At step: ', ntimestep + pe = lmp%get_thermo('pe') + ke = lmp%get_thermo('ke') + WRITE(OUTPUT_UNIT,*) 'PE = ', pe + WRITE(OUTPUT_UNIT,*) 'KE = ', ke + + CALL lmp%close(.TRUE.) + END PROGRAM testprop --------------- @@ -262,6 +273,8 @@ of the contents of the :f:mod:`LIBLAMMPS` Fortran interface to LAMMPS. :ftype style: type(lammps_style) :f type: derived type to access lammps type constants :ftype type: type(lammps_type) + :f dtype: derived type to access lammps data type constants + :ftype dtype: type(lammps_dtype) :f close: :f:subr:`close` :ftype close: subroutine :f subroutine error: :f:subr:`error` @@ -278,6 +291,8 @@ of the contents of the :f:mod:`LIBLAMMPS` Fortran interface to LAMMPS. :ftype get_natoms: function :f get_thermo: :f:func:`get_thermo` :ftype get_thermo: function + :f last_thermo: :f:func:`last_thermo` + :ftype last_thermo: function :f extract_box: :f:subr:`extract_box` :ftype extract_box: subroutine :f reset_box: :f:subr:`reset_box` @@ -587,6 +602,96 @@ Procedures Bound to the :f:type:`lammps` Derived Type -------- +.. f:function:: last_thermo(what, index) + + This function will call :cpp:func:`lammps_last_thermo` and returns + either a string or a pointer to a cached copy of LAMMPS last thermodynamic + output, depending on the data requested through *what*. Note that *index* + uses 1-based indexing to access thermo output columns. + + .. versionadded:: 15Jun2023 + + Note that this function actually does not return a value, but rather + associates the pointer on the left side of the assignment to point to + internal LAMMPS data (with the exception of string data, which are + copied and returned as ordinary Fortran strings). Pointers must be + of the correct data type to point to said data (typically + ``INTEGER(c_int)``, ``INTEGER(c_int64_t)``, or ``REAL(c_double)``). + The pointer being associated with LAMMPS data is type-checked at + run-time via an overloaded assignment operator. The pointers + returned by this function point to temporary, read-only data that may + be overwritten at any time, so their target values need to be copied + to local storage if they are supposed to persist. + + For example, + + .. code-block:: fortran + + PROGRAM thermo + USE LIBLAMMPS + USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_double, c_int64_t, c_int + TYPE(lammps) :: lmp + INTEGER(KIND=c_int64_t), POINTER :: ntimestep, bval + REAL(KIND=c_double), POINTER :: dval + INTEGER(KIND=c_int), POINTER :: nfield, typ, ival + INTEGER(KIND=c_int) :: i + CHARACTER(LEN=11) :: key + + lmp = lammps() + CALL lmp%file('in.sysinit') + + ntimestep = lmp%last_thermo('step', 0) + nfield = lmp%last_thermo('num', 0) + PRINT*, 'Last thermo output on step: ', ntimestep, ' Number of fields: ', nfield + DO i=1, nfield + key = lmp%last_thermo('keyword',i) + typ = lmp%last_thermo('type',i) + IF (typ == lmp%dtype%i32) THEN + ival = lmp%last_thermo('data',i) + PRINT*, key, ':', ival + ELSE IF (typ == lmp%dtype%i64) THEN + bval = lmp%last_thermo('data',i) + PRINT*, key, ':', bval + ELSE IF (typ == lmp%dtype%r64) THEN + dval = lmp%last_thermo('data',i) + PRINT*, key, ':', dval + END IF + END DO + CALL lmp%close(.TRUE.) + END PROGRAM thermo + + would extract the last timestep where thermo output was done and the number + of columns it printed. Then it loops over the columns to print out column + header keywords and the corresponding data. + + .. note:: + + If :f:func:`last_thermo` returns a string, the string must have a length + greater than or equal to the length of the string (not including the + terminal ``NULL`` character) that LAMMPS returns. If the variable's + length is too short, the string will be truncated. As usual in Fortran, + strings are padded with spaces at the end. If you use an allocatable + string, the string **must be allocated** prior to calling this function. + + :p character(len=\*) what: string with the name of the thermo keyword + :p integer(c_int) index: 1-based column index + :to: :cpp:func:`lammps_last_thermo` + :r pointer [polymorphic]: pointer to LAMMPS data. The left-hand side of the + assignment should be either a string (if expecting string data) or a + C-compatible pointer (e.g., ``INTEGER(c_int), POINTER :: nlocal``) to the + extracted property. + + .. warning:: + + Modifying the data in the location pointed to by the returned pointer + may lead to inconsistent internal data and thus may cause failures, + crashes, or bogus simulations. In general, it is much better + to use a LAMMPS input command that sets or changes these parameters. + Using an input command will take care of all side effects and necessary + updates of settings derived from such settings. + +-------- + .. f:subroutine:: extract_box([boxlo][, boxhi][, xy][, yz][, xz][, pflags][, boxflag]) This subroutine will call :cpp:func:`lammps_extract_box`. All @@ -764,13 +869,14 @@ Procedures Bound to the :f:type:`lammps` Derived Type .. note:: - If :f:func:`extract_global` returns a string, the string must have length - greater than or equal to the length of the string (not including the - terminal ``NULL`` character) that LAMMPS returns. If the variable's - length is too short, the string will be truncated. As usual in Fortran, - strings are padded with spaces at the end. If you use an allocatable - string, the string **must be allocated** prior to calling this function, - but you can automatically reallocate it to the correct length after the + If :f:func:`extract_global` returns a string, the string must have + a length greater than or equal to the length of the string (not + including the terminal ``NULL`` character) that LAMMPS returns. If + the variable's length is too short, the string will be + truncated. As usual in Fortran, strings are padded with spaces at + the end. If you use an allocatable string, the string **must be + allocated** prior to calling this function, but you can + automatically reallocate it to the correct length after the function returns, viz., .. code-block :: fortran @@ -2172,19 +2278,13 @@ Procedures Bound to the :f:type:`lammps` Derived Type .. versionadded:: 3Nov2022 - In case of an error, LAMMPS will either abort or throw a C++ exception. - The latter has to be :ref:`enabled at compile time `. - This function checks if exceptions were enabled. - - When using the library interface with C++ exceptions enabled, the library - interface functions will "catch" them, and the error status can then be - checked by calling :f:func:`has_error`. The most recent error message can be - retrieved via :f:func:`get_last_error_message`. - This can allow one to restart a calculation or delete and recreate - the LAMMPS instance when a C++ exception occurs. One application - of using exceptions this way is the :ref:`lammps_shell`. If C++ - exceptions are disabled and an error happens during a call to - LAMMPS or the Fortran API, the application will terminate. + When using the library interface, the library interface functions + will "catch" exceptions, and then the error status can be checked by + calling :f:func:`has_error`. The most recent error message can be + retrieved via :f:func:`get_last_error_message`. This allows to + restart a calculation or delete and recreate the LAMMPS instance when + a C++ exception occurs. One application of using exceptions this way + is the :ref:`lammps_shell`. :to: :cpp:func:`lammps_config_has_exceptions` :r has_exceptions: @@ -2938,14 +3038,6 @@ Procedures Bound to the :f:type:`lammps` Derived Type This function can be used to query if an error inside of LAMMPS has thrown a :ref:`C++ exception `. - .. note:: - - This function will always report "no error" when the LAMMPS library - has been compiled without ``-DLAMMPS_EXCEPTIONS``, which turns fatal - errors aborting LAMMPS into C++ exceptions. You can use the library - function :cpp:func:`lammps_config_has_exceptions` to check if this is - the case. - :to: :cpp:func:`lammps_has_error` :r has_error: ``.TRUE.`` if there is an error. :rtype has_error: logical @@ -2968,13 +3060,6 @@ Procedures Bound to the :f:type:`lammps` Derived Type would happen only in a single MPI rank and thus may not be recoverable, as other MPI ranks may be waiting on the failing MPI rank(s) to send messages. - .. note:: - - This function will do nothing when the LAMMPS library has been - compiled without ``-DLAMMPS_EXCEPTIONS``, which turns errors aborting - LAMMPS into C++ exceptions. You can use the function - :f:func:`config_has_exceptions` to check whether this is the case. - :p character(len=\*) buffer: string buffer to copy the error message into :o integer(c_int) status [optional]: 1 when all ranks had the error, 2 on a single-rank error. diff --git a/doc/src/Howto.rst b/doc/src/Howto.rst index 4752cf6aea..85c98bd6de 100644 --- a/doc/src/Howto.rst +++ b/doc/src/Howto.rst @@ -100,6 +100,8 @@ Tutorials howto Howto_cmake Howto_github + Howto_lammps_gui + Howto_moltemplate Howto_pylammps Howto_wsl diff --git a/doc/src/Howto_2d.rst b/doc/src/Howto_2d.rst index be223c076a..ae58711063 100644 --- a/doc/src/Howto_2d.rst +++ b/doc/src/Howto_2d.rst @@ -13,9 +13,9 @@ box with a single z plane of atoms - e.g. .. code-block:: LAMMPS - create box 1 -10 10 -10 10 -0.25 0.25 + create_box 1 -10 10 -10 10 -0.25 0.25 -If using the :doc:`read data ` command to read in a file of +If using the :doc:`read_data ` command to read in a file of atom coordinates, set the "zlo zhi" values to be finite but narrow, similar to the create_box command settings just described. For each atom in the file, assign a z coordinate so it falls inside the diff --git a/doc/src/Howto_body.rst b/doc/src/Howto_body.rst index 88fa2d9c97..968e10edd8 100644 --- a/doc/src/Howto_body.rst +++ b/doc/src/Howto_body.rst @@ -170,9 +170,9 @@ with this body style to compute body/body and body/non-body interactions. The *rounded/polygon* body style represents body particles as a 2d polygon with a variable number of N vertices. This style can only be used for 2d models; see the :doc:`boundary ` command. See the -"pair_style body/rounded/polygon" page for a diagram of two -squares with rounded circles at the vertices. Special cases for N = 1 -(circle) and N = 2 (rod with rounded ends) can also be specified. +:doc:`pair_style body/rounded/polygon ` page for +a diagram of two squares with rounded circles at the vertices. Special cases +for N = 1 (circle) and N = 2 (rod with rounded ends) can also be specified. One use of this body style is for 2d discrete element models, as described in :ref:`Fraige `. @@ -335,7 +335,7 @@ faces are listed, so that M = 6 + 3\*N + 1. The integer line has three values: number of vertices (N), number of edges (E) and number of faces (F). The floating point line(s) list 6 moments of inertia followed by the coordinates of the N vertices (x1 -to zN) as 3N values, followed by 2N vertex indices corresponding to +to zN) as 3N values, followed by 2E vertex indices corresponding to the end points of the E edges, then 4\*F vertex indices defining F faces. The last value is the diameter value = the rounded diameter of the sphere that surrounds each vertex. The diameter value can be diff --git a/doc/src/Howto_bpm.rst b/doc/src/Howto_bpm.rst index 8b84e96b99..0ca4e85fbb 100644 --- a/doc/src/Howto_bpm.rst +++ b/doc/src/Howto_bpm.rst @@ -79,9 +79,9 @@ As bonds can be broken between neighbor list builds, the bond styles. There are two possible settings which determine how pair interactions work between bonded particles. First, one can overlay pair forces with bond forces such that all bonded particles also -feel pair interactions. This can be accomplished by using the *overlay/pair* -keyword present in all bpm bond styles and by using the following special -bond settings +feel pair interactions. This can be accomplished by setting the *overlay/pair* +keyword present in all bpm bond styles to *yes* and requires using the +following special bond settings .. code-block:: LAMMPS @@ -107,7 +107,17 @@ bond lists is expensive. By setting the lj weight for 1-2 bonds to zero, this turns off pairwise interactions. Even though there are no charges in BPM models, setting a nonzero coul weight for 1-2 bonds ensures all bonded neighbors are still included in the neighbor list -in case bonds break between neighbor list builds. +in case bonds break between neighbor list builds. If bond breakage is +disabled during a simulation run by setting the *break* keyword to *no*, +a zero coul weight for 1-2 bonds can be used to exclude bonded atoms +from the neighbor list builds + + .. code-block:: LAMMPS + + special_bonds lj 0 1 1 coul 0 1 1 + +This can be useful for post-processing, or to determine pair interaction +properties between distinct bonded particles. To monitor the fracture of bonds in the system, all BPM bond styles have the ability to record instances of bond breakage to output using diff --git a/doc/src/Howto_cmake.rst b/doc/src/Howto_cmake.rst index c997aa52bf..42324cf2f1 100644 --- a/doc/src/Howto_cmake.rst +++ b/doc/src/Howto_cmake.rst @@ -1,11 +1,11 @@ -Using CMake with LAMMPS tutorial -================================ +Using CMake with LAMMPS +======================= The support for building LAMMPS with CMake is a recent addition to LAMMPS thanks to the efforts of Christoph Junghans (LANL) and Richard -Berger (Temple U). One of the key strengths of CMake is that it is not -tied to a specific platform or build system and thus generate the files -necessary to build and develop for different build systems and on +Berger (LANL). One of the key strengths of CMake is that it is not +tied to a specific platform or build system. Instead it generates the +files necessary to build and develop for different build systems and on different platforms. Note, that this applies to the build system itself not the LAMMPS code. In other words, without additional porting effort, it is not possible - for example - to compile LAMMPS with Visual C++ on @@ -14,7 +14,7 @@ necessary to program LAMMPS as a project in integrated development environments (IDE) like Eclipse, Visual Studio, QtCreator, Xcode, CodeBlocks, Kate and others. -A second important feature of CMake is, that it can detect and validate +A second important feature of CMake is that it can detect and validate available libraries, optimal settings, available support tools and so on, so that by default LAMMPS will take advantage of available tools without requiring to provide the details about how to enable/integrate @@ -32,8 +32,8 @@ program ``cmake`` (or ``cmake3``), a text mode interactive user interface (TUI) program ``ccmake`` (or ``ccmake3``), or a graphical user interface (GUI) program ``cmake-gui``. All of them are portable software available on all supported platforms and can be used -interchangeably. The minimum supported CMake version is 3.10 (3.12 or -later is recommended). +interchangeably. As of LAMMPS version 2 August 2023, the minimum +required CMake version is 3.16. All details about features and settings for CMake are in the `CMake online documentation `_. We focus @@ -43,11 +43,20 @@ Prerequisites ------------- This tutorial assumes that you are operating in a command-line environment -using a shell like Bash. +using a shell like Bash or Zsh. -- Linux: any Terminal window will work -- macOS: launch the Terminal application. -- Windows 10: install and run the :doc:`Windows Subsystem for Linux ` +- Linux: any Terminal window will work or text console +- macOS: launch the Terminal application +- Windows 10 or 11: install and run the :doc:`Windows Subsystem for Linux ` +- other Unix-like operating systems like FreeBSD + +.. note:: + + It is also possible to use CMake on Windows 10 or 11 through either the Microsoft + Visual Studio IDE with the bundled CMake or from the Windows command prompt using + a separately installed CMake package, both using the native Microsoft Visual C++ + compilers and (optionally) the Microsoft MPI SDK. This tutorial, however, only + covers unix-like command line interfaces. We also assume that you have downloaded and unpacked a recent LAMMPS source code package or used Git to create a clone of the LAMMPS sources on your compilation machine. @@ -338,8 +347,6 @@ Some common LAMMPS specific variables - common compiler flags, for optimization or instrumentation (default:) * - ``LAMMPS_MACHINE`` - when set to ``name`` the LAMMPS executable and library will be called ``lmp_name`` and ``liblammps_name.a`` - * - ``LAMMPS_EXCEPTIONS`` - - when set to ``on`` errors will throw a C++ exception instead of aborting (default: ``off``) * - ``FFT`` - select which FFT library to use: ``FFTW3``, ``MKL``, ``KISS`` (default, unless FFTW3 is found) * - ``FFT_SINGLE`` @@ -412,9 +419,9 @@ interface (``ccmake`` or ``cmake-gui``). Using a preset to select a compiler package (``clang.cmake``, ``gcc.cmake``, ``intel.cmake``, ``oneapi.cmake``, or ``pgi.cmake``) - are an exception to the mechanism of updating the configuration incrementally, - as they will trigger a reset of cached internal CMake settings and thus - reset settings to their default values. + are an exception to the mechanism of updating the configuration + incrementally, as they will trigger a reset of cached internal CMake + settings and thus reset settings to their default values. Compilation and build targets ----------------------------- diff --git a/doc/src/Howto_github.rst b/doc/src/Howto_github.rst index cbe1264d52..b81716c09d 100644 --- a/doc/src/Howto_github.rst +++ b/doc/src/Howto_github.rst @@ -480,11 +480,11 @@ Some recent changes to the workflow are not captured in this tutorial. For example, in addition to the *develop* branch, to which all new features should be submitted, there is also a *release*, a *stable*, and a *maintenance* branch; the *release* branch is updated from the -*develop* as part of a feature release, and *stable* (together with -*release*) are updated from *develop* when a stable release is made. In -between stable releases, selected bug fixes and infrastructure updates -are back-ported from the *develop* branch to the *maintenance* branch -and occasionally merged to *stable* as an update release. +*develop* branch as part of a "feature release", and *stable* (together +with *release*) are updated from *develop* when a "stable release" is +made. In between stable releases, selected bug fixes and infrastructure +updates are back-ported from the *develop* branch to the *maintenance* +branch and occasionally merged to *stable* as an update release. Furthermore, the naming of the release tags now follow the pattern "patch_" to simplify comparisons between releases. diff --git a/doc/src/Howto_lammps_gui.rst b/doc/src/Howto_lammps_gui.rst new file mode 100644 index 0000000000..165ed84d95 --- /dev/null +++ b/doc/src/Howto_lammps_gui.rst @@ -0,0 +1,700 @@ +Using the LAMMPS GUI +==================== + +This document describes **LAMMPS GUI version 1.5**. + +----- + +LAMMPS GUI is a graphical text editor customized for editing LAMMPS +input files that is linked to the :ref:`LAMMPS library ` +and thus can run LAMMPS directly using the contents of the editor's text +buffer as input. It can retrieve and display information from LAMMPS +while it is running, display visualizations created with the :doc:`dump +image command `, and is adapted specifically for editing +LAMMPS input files through text completion and reformatting, and linking +to the online LAMMPS documentation for known LAMMPS commands and styles. + +.. note:: + + Pre-compiled, ready-to-use LAMMPS GUI executables for Linux (Ubuntu + 20.04LTS or later and compatible), macOS (version 11 aka Big Sur or + later), and Windows (version 10 or later) :ref:`are available + ` for download. They may be linked to a + development version of LAMMPS in case they need features not yet + available in a released version. Serial LAMMPS executables of the + same LAMMPS version are included as well. The source code for the + LAMMPS GUI is included in the LAMMPS source code and can be found in + the ``tools/lammps-gui`` folder. It can be compiled alongside LAMMPS + when :doc:`compiling with CMake `. + +LAMMPS GUI tries to provide an experience similar to what people +traditionally would do to run LAMMPS using a command line window: + +- editing inputs with a text editor +- run LAMMPS on the input with selected command line flags +- and then use or extract data from the created files and visualize it + +That procedure is quite effective for people proficient in using the +command line, as that allows them to use tools for the individual steps +which they are most comfortable with. It is often required when running +LAMMPS on high-performance computing facilities. + +The main benefit of using the LAMMPS GUI application instead is that +many basic tasks can be done directly from the GUI without switching to +a text console window or using external programs, let alone writing +scripts to extract data from the generated output. It also integrates +well with graphical desktop environments. + +LAMMPS GUI thus makes it easier for beginners to get started running +simple LAMMPS simulations. It is very suitable for tutorials on LAMMPS +since you only need to learn how to use a single program for most tasks +and thus time can be saved and people can focus on learning LAMMPS. It +is also designed to keep the barrier low when you decide to switch to a +full featured, standalone programming editor and more sophisticated +visualization and analysis tools and run LAMMPS from a command line. + +The following text provides a detailed tour of the features and +functionality of the LAMMPS GUI. + +Suggestions for new features and reports of bugs are always welcome. +You can use the :doc:`the same channels as for LAMMPS itself +` for that purpose. + +----- + +Main window +----------- + +When LAMMPS GUI starts, it will show a main window with either an +empty buffer or the contents of a loaded file. In the latter case it +may look like the following: + +.. image:: JPG/lammps-gui-main.png + :align: center + :scale: 50% + +There is the typical menu bar at the top, then the main editor buffer, +and a status bar at the bottom. The input file contents are shown +with line numbers on the left and the input is colored according to +the LAMMPS input file syntax. The status bar shows the status of +LAMMPS execution on the left (e.g. "Ready." when idle) and the current +working directory on the right. The name of the current file in the +buffer is shown in the window title; the word `*modified*` is added if +the buffer edits have not yet saved to a file. The size of the main +window will be stored when exiting and restored when starting again. + +Opening Files +^^^^^^^^^^^^^ + +The LAMMPS GUI application will try to open the first command line +argument as a LAMMPS input script, further arguments are ignored. +When no argument is given, LAMMPS GUI will start with an empty buffer. +Files can also be opened via the ``File`` menu or by drag-and-drop of +a file from a graphical file manager into the editor window. Only one +file can be open at a time, so opening a new file with a filled buffer +will close the buffer. If the buffer has unsaved modifications, you +will be asked to either cancel the operation, discard the changes, or +save them. + +Running LAMMPS +^^^^^^^^^^^^^^ + +From within the LAMMPS GUI main window LAMMPS can be started either from +the ``Run`` menu using the ``Run LAMMPS from Editor Buffer`` entry, by +the keyboard shortcut `Ctrl-Enter` (`Command-Enter` on macOS), or by +clicking on the green "Run" button in the status bar. All of these +operations will cause LAMMPS to process the entire input script, which +may contain multiple :doc:`run ` or :doc:`minimize ` +commands. + +LAMMPS runs in a separate thread, so the GUI stays responsive and is +able to interact with the running calculation and access data it +produces. It is important to note that running LAMMPS this way is +using the contents of the input buffer for the run (via the +:cpp:func:`lammps_commands_string()` function of the LAMMPS C-library +interface), and **not** the original file it was read from. Thus, if +there are unsaved changes in the buffer, they *will* be used. As an +alternative, it is also possible to run LAMMPS by reading the contents +of a file from the ``Run LAMMPS from File`` menu entry or with +`Ctrl-Shift-Enter`. This option may be required in some rare cases +where the input uses some functionality that is not compatible with +running LAMMPS from a string buffer. For consistency, any unsaved +changes in the buffer must be either saved to the file or undone +before LAMMPS can be run from a file. + +.. image:: JPG/lammps-gui-running.png + :align: center + :scale: 75% + +While LAMMPS is running, the contents of the status bar change. On +the left side there is a text indicating that LAMMPS is running, which +will also show the number of active threads, if thread-parallel +acceleration was selected in the ``Preferences`` dialog. On the right +side, a progress bar is shown that displays the estimated progress for +the current :doc:`run command `. + +Also, the line number of the currently executed command will be +highlighted in green. + +.. image:: JPG/lammps-gui-run-highlight.png + :align: center + :scale: 75% + +If an error occurs (in the example below the command :doc:`label +