Commit 1d3116d7 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

Merge branch 'master' into less-compiler-warnings

parents 9e03bf7d c9cf3fba
Loading
Loading
Loading
Loading
+70 −14
Original line number Diff line number Diff line
@@ -43,6 +43,29 @@ function(validate_option name values)
    endif()
endfunction(validate_option)

function(get_lammps_version version_header variable)
    file(READ ${version_header} line)
    set(MONTHS x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
    string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\1" day "${line}")
    string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\2" month "${line}")
    string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\3" year "${line}")
    string(STRIP ${day} day)
    string(STRIP ${month} month)
    string(STRIP ${year} year)
    list(FIND MONTHS "${month}" month)
    string(LENGTH ${day} day_length)
    string(LENGTH ${month} month_length)
    if(day_length EQUAL 1)
        set(day "0${day}")
    endif()
    if(month_length EQUAL 1)
        set(month "0${month}")
    endif()
    set(${variable} "${year}${month}${day}" PARENT_SCOPE)
endfunction()

get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION)

# Cmake modules/macros are in a subdirectory to keep this file cleaner
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)

@@ -121,10 +144,10 @@ if(BUILD_LIB)
  if(BUILD_SHARED_LIBS) # for all pkg libs, mpi_stubs and linalg
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  endif()
  set(LIB_SUFFIX "" CACHE STRING "Suffix to append to liblammps and pkg-config file")
  mark_as_advanced(LIB_SUFFIX)
  if(LIB_SUFFIX)
    set(LIB_SUFFIX "_${LIB_SUFFIX}")
  set(LAMMPS_LIB_SUFFIX "" CACHE STRING "Suffix to append to liblammps and pkg-config file")
  mark_as_advanced(LAMMPS_LIB_SUFFIX)
  if(LAMMPS_LIB_SUFFIX)
    set(LAMMPS_LIB_SUFFIX "_${LAMMPS_LIB_SUFFIX}")
  endif()
endif()

@@ -188,7 +211,7 @@ if(ENABLE_TESTING)
endif(ENABLE_TESTING)

set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE GRANULAR
  KSPACE MANYBODY MC MEAM MISC MOLECULE PERI REAX REPLICA RIGID SHOCK SPIN SNAP
  KSPACE MANYBODY MC MEAM MESSAGE MISC MOLECULE PERI REAX REPLICA RIGID SHOCK SPIN SNAP
  SRD KIM PYTHON MSCG MPIIO VORONOI POEMS LATTE USER-ATC USER-AWPMD USER-BOCS
  USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE
  USER-EFF USER-FEP USER-H5MD USER-LB USER-MANIFOLD USER-MEAMC USER-MGPT USER-MISC
@@ -481,6 +504,39 @@ if(PKG_KIM)
  include_directories(${KIM_INCLUDE_DIRS})
endif()

if(PKG_MESSAGE)
  option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
  file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/*.F
      ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/*.c ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/*.cpp)

  if(BUILD_SHARED_LIBS)
      add_library(cslib SHARED ${cslib_SOURCES})
  else()
      add_library(cslib STATIC ${cslib_SOURCES})
  endif()

  if(BUILD_MPI)
    target_compile_definitions(cslib PRIVATE -DMPI_YES)
    set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi")
  else()
    target_compile_definitions(cslib PRIVATE -DMPI_NO)
    set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi")
  endif()

  if(MESSAGE_ZMQ)
    target_compile_definitions(cslib PRIVATE -DZMQ_YES)
    find_package(ZMQ REQUIRED)
    target_include_directories(cslib PRIVATE ${ZMQ_INCLUDE_DIRS})
    target_link_libraries(cslib PUBLIC ${ZMQ_LIBRARIES})
  else()
    target_compile_definitions(cslib PRIVATE -DZMQ_NO)
    target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ)
  endif()

  list(APPEND LAMMPS_LINK_LIBS cslib)
  include_directories(${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src)
endif()

if(PKG_MSCG)
  find_package(GSL REQUIRED)
  option(DOWNLOAD_MSCG "Download latte (instead of using the system's one)" OFF)
@@ -1040,14 +1096,14 @@ if(BUILD_LIB)
  if(LAMMPS_DEPS)
    add_dependencies(lammps ${LAMMPS_DEPS})
  endif()
  set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LIB_SUFFIX})
  if(BUILD_SHARED_LIBS)
  set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_LIB_SUFFIX})
  set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION})
  install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
  install(FILES ${LAMMPS_SOURCE_DIR}/library.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
    configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LIB_SUFFIX}.pc @ONLY)
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LIB_SUFFIX}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
  endif()
  configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc @ONLY)
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
  configure_file(FindLAMMPS.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindLAMMPS${LAMMPS_LIB_SUFFIX}.cmake @ONLY)
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FindLAMMPS${LAMMPS_LIB_SUFFIX}.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Module)
else()
  list(APPEND LMP_SOURCES ${LIB_SOURCES})
endif()
@@ -1177,7 +1233,7 @@ endif()
###############################################################################
# Print package summary
###############################################################################
foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES})
foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES} ${OTHER_PACKAGES})
  if(PKG_${PKG})
    message(STATUS "Building package: ${PKG}")
  endif()
+48 −0
Original line number Diff line number Diff line
# - Find liblammps
# Find the native liblammps headers and libraries.
#
# The following variables will set:
#  LAMMPS_INCLUDE_DIRS - where to find lammps/library.h, etc.
#  LAMMPS_LIBRARIES    - List of libraries when using lammps.
#  LAMMPS_API_DEFINES  - lammps library api defines
#  LAMMPS_VERSION      - lammps library version 
#  LAMMPS_FOUND        - True if liblammps found.
#
# In addition a LAMMPS::LAMMPS imported target is getting created.
#
#  LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
#  http://lammps.sandia.gov, Sandia National Laboratories
#  Steve Plimpton, sjplimp@sandia.gov
#
#  Copyright (2003) Sandia Corporation.  Under the terms of Contract
#  DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
#  certain rights in this software.  This software is distributed under
#  the GNU General Public License.
#
#  See the README file in the top-level LAMMPS directory.
#

find_package(PkgConfig)

pkg_check_modules(PC_LAMMPS liblammps@LAMMPS_LIB_SUFFIX@)
find_path(LAMMPS_INCLUDE_DIR lammps/library.h HINTS ${PC_LAMMPS_INCLUDE_DIRS} @CMAKE_INSTALL_FULL_INCLUDEDIR@)

set(LAMMPS_VERSION @LAMMPS_VERSION@)
set(LAMMPS_API_DEFINES @LAMMPS_API_DEFINES@)

find_library(LAMMPS_LIBRARY NAMES lammps@LAMMPS_LIB_SUFFIX@ HINTS ${PC_LAMMPS_LIBRARY_DIRS} @CMAKE_INSTALL_FULL_LIBDIR@)

set(LAMMPS_INCLUDE_DIRS "${LAMMPS_INCLUDE_DIR}")
set(LAMMPS_LIBRARIES "${LAMMPS_LIBRARY}")

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LAMMPS_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(LAMMPS REQUIRED_VARS LAMMPS_LIBRARY LAMMPS_INCLUDE_DIR VERSION_VAR LAMMPS_VERSION)

mark_as_advanced(LAMMPS_INCLUDE_DIR LAMMPS_LIBRARY)

if(LAMMPS_FOUND AND NOT TARGET LAMMPS::LAMMPS)
  add_library(LAMMPS::LAMMPS UNKNOWN IMPORTED)
  set_target_properties(LAMMPS::LAMMPS PROPERTIES IMPORTED_LOCATION "${LAMMPS_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${LAMMPS_INCLUDE_DIR}" INTERFACE_COMPILE_DEFINITIONS "${LAMMPS_API_DEFINES}")
endif()
+8 −0
Original line number Diff line number Diff line
find_path(ZMQ_INCLUDE_DIR zmq.h)
find_library(ZMQ_LIBRARY NAMES zmq)

set(ZMQ_LIBRARIES ${ZMQ_LIBRARY})
set(ZMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZMQ DEFAULT_MSG ZMQ_LIBRARY ZMQ_INCLUDE_DIR)
+3 −3
Original line number Diff line number Diff line
@@ -4,15 +4,15 @@
# after you added @CMAKE_INSTALL_FULL_LIBDIR@/pkg-config to PKG_CONFIG_PATH,
# e.g. export PKG_CONFIG_PATH=@CMAKE_INSTALL_FULL_LIBDIR@/pkgconfig

prefix=@CMAKE_INSTALL_FULL_PREFIX@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

Name: liblammps@LAMMPS_MACHINE@
Description: Large-scale Atomic/Molecular Massively Parallel Simulator Library
URL: http://lammps.sandia.gov
Version:
Version: @LAMMPS_VERSION@
Requires:
Libs: -L${libdir} -llammps@LIB_SUFFIX@@
Libs: -L${libdir} -llammps@LAMMPS_LIB_SUFFIX@
Libs.private: -lm
Cflags: -I${includedir} @LAMMPS_API_DEFINES@
+34 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ This is the list of packages that may require additional steps.
"KOKKOS"_#kokkos,
"LATTE"_#latte,
"MEAM"_#meam,
"MESSAGE"_#message,
"MSCG"_#mscg,
"OPT"_#opt,
"POEMS"_#poems,
@@ -361,6 +362,10 @@ make lib-meam args="-m mpi" # build with default Fortran compiler compatible
make lib-meam args="-m serial" # build with compiler compatible with "make serial" (GNU Fortran)
make lib-meam args="-m ifort"  # build with Intel Fortran compiler using Makefile.ifort :pre

NOTE: You should test building the MEAM library with both the Intel
and GNU compilers to see if a simulation runs faster with one versus
the other on your system.

The build should produce two files: lib/meam/libmeam.a and
lib/meam/Makefile.lammps.  The latter is copied from an existing
Makefile.lammps.* and has settings needed to link C++ (LAMMPS) with
@@ -373,6 +378,35 @@ file.

:line
 
MESSAGE package :h4,link(message)

This package can optionally include support for messaging via sockets,
using the open-source "ZeroMQ library"_http://zeromq.org, which must
be installed on your system.

[CMake build]:

-D MESSAGE_ZMQ=value    # build with ZeroMQ support, value = no (default) or yes

[Traditional make]:

Before building LAMMPS, you must build the CSlib library in
lib/message.  You can build the CSlib library manually if you prefer;
follow the instructions in lib/message/README.  You can also do it in
one step from the lammps/src dir, using a command like these, which
simply invoke the lib/message/Install.py script with the specified args:

make lib-message               # print help message
make lib-message args="-m -z"  # build with MPI and socket (ZMQ) support
make lib-message args="-s"     # build as serial lib with no ZMQ support

The build should produce two files: lib/message/cslib/src/libmessage.a
and lib/message/Makefile.lammps.  The latter is copied from an
existing Makefile.lammps.* and has settings to link with the ZeroMQ
library if requested in the build.

:line
 
MSCG package :h4,link(mscg)

To build with this package, you must download and build the MS-CG
Loading