2017-07-20 08:34:07 +08:00
########################################
# CMake build system
# This file is part of LAMMPS
# Created by Christoph Junghans and Richard Berger
2018-06-09 06:18:02 +08:00
cmake_minimum_required ( VERSION 2.8.12 )
2017-07-13 05:54:44 +08:00
2018-06-09 06:18:02 +08:00
project ( lammps CXX )
2017-07-13 05:54:44 +08:00
set ( SOVERSION 0 )
2018-06-25 14:55:16 +08:00
get_filename_component ( LAMMPS_SOURCE_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /../src ABSOLUTE )
get_filename_component ( LAMMPS_LIB_SOURCE_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /../lib ABSOLUTE )
get_filename_component ( LAMMPS_LIB_BINARY_DIR ${ CMAKE_BINARY_DIR } /lib ABSOLUTE )
2018-07-27 14:46:36 +08:00
get_filename_component ( LAMMPS_DOC_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /../doc ABSOLUTE )
2018-06-25 14:55:16 +08:00
2019-03-05 21:35:53 +08:00
find_package ( Git )
2018-12-17 05:53:51 +08:00
# by default, install into $HOME/.local (not /usr/local), so that no root access (and sudo!!) is needed
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set ( CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "default install path" FORCE )
endif ( )
2017-07-13 05:54:44 +08:00
2018-06-29 12:56:35 +08:00
# To avoid conflicts with the conventional Makefile build system, we build everything here
2018-09-07 04:37:08 +08:00
file ( GLOB LIB_SOURCES ${ LAMMPS_SOURCE_DIR } /[^.]*.cpp )
2017-07-17 11:43:29 +08:00
file ( GLOB LMP_SOURCES ${ LAMMPS_SOURCE_DIR } /main.cpp )
list ( REMOVE_ITEM LIB_SOURCES ${ LMP_SOURCES } )
2019-06-08 00:18:49 +08:00
# Cmake modules/macros are in a subdirectory to keep this file cleaner
set ( CMAKE_MODULE_PATH ${ CMAKE_CURRENT_SOURCE_DIR } /Modules )
include ( LAMMPSUtils )
2018-08-30 04:12:16 +08:00
get_lammps_version ( ${ LAMMPS_SOURCE_DIR } /version.h LAMMPS_VERSION )
2017-07-15 06:49:05 +08:00
2018-09-28 02:18:43 +08:00
include ( PreventInSourceBuilds )
2017-07-26 09:09:20 +08:00
if ( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS )
2017-07-13 05:54:44 +08:00
#release comes with -O3 by default
set ( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE )
2017-07-26 09:09:20 +08:00
endif ( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS )
2018-12-17 05:53:51 +08:00
string ( TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE )
2017-07-13 05:54:44 +08:00
2018-06-22 19:57:03 +08:00
# check for files auto-generated by make-based buildsystem
# this is fast, so check for it all the time
message ( STATUS "Running check for auto-generated files from make-based build system" )
file ( GLOB SRC_AUTOGEN_FILES ${ LAMMPS_SOURCE_DIR } /style_*.h )
2019-04-09 05:14:59 +08:00
file ( GLOB SRC_AUTOGEN_PACKAGES ${ LAMMPS_SOURCE_DIR } /packages_*.h )
list ( APPEND SRC_AUTOGEN_FILES ${ SRC_AUTOGEN_PACKAGES } ${ LAMMPS_SOURCE_DIR } /lmpinstalledpkgs.h ${ LAMMPS_SOURCE_DIR } /lmpgitversion.h )
2018-06-22 19:57:03 +08:00
foreach ( _SRC ${ SRC_AUTOGEN_FILES } )
get_filename_component ( FILENAME "${_SRC}" NAME )
if ( EXISTS ${ LAMMPS_SOURCE_DIR } / ${ FILENAME } )
2018-06-25 14:55:16 +08:00
message ( FATAL_ERROR "\n########################################################################\n"
" F o u n d h e a d e r file ( s ) g e n e r a t e d b y t h e m a k e - b a s e d b u i l d s y s t e m \ n "
" \ n "
" P l e a s e r u n \ n "
" m a k e - C $ { L A M M P S _ S O U R C E _ D I R } p u r g e \ n "
" t o r e m o v e \ n "
" ########################################################################")
2018-06-22 19:57:03 +08:00
endif ( )
endforeach ( )
2017-07-18 01:52:06 +08:00
2017-07-13 05:54:44 +08:00
######################################################################
# compiler tests
# these need ot be done early (before further tests).
#####################################################################
include ( CheckCCompilerFlag )
2017-10-04 01:08:56 +08:00
if ( ${ CMAKE_CXX_COMPILER_ID } STREQUAL "Intel" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict" )
endif ( )
2018-06-29 12:56:35 +08:00
# GNU compiler features
if ( ${ CMAKE_CXX_COMPILER_ID } STREQUAL "GNU" )
option ( ENABLE_COVERAGE "Enable code coverage" OFF )
2018-06-29 13:00:20 +08:00
mark_as_advanced ( ENABLE_COVERAGE )
2018-06-29 12:56:35 +08:00
if ( ENABLE_COVERAGE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
endif ( )
option ( ENABLE_SANITIZE_ADDRESS "Enable address sanitizer" OFF )
2018-06-29 13:00:20 +08:00
mark_as_advanced ( ENABLE_SANITIZE_ADDRESS )
2018-06-29 12:56:35 +08:00
if ( ENABLE_SANITIZE_ADDRESS )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address" )
endif ( )
option ( ENABLE_SANITIZE_UNDEFINED "Enable undefined behavior sanitizer" OFF )
2018-06-29 13:00:20 +08:00
mark_as_advanced ( ENABLE_SANITIZE_UNDEFINED )
2018-06-29 12:56:35 +08:00
if ( ENABLE_SANITIZE_UNDEFINED )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined" )
endif ( )
option ( ENABLE_SANITIZE_THREAD "Enable thread sanitizer" OFF )
2018-06-29 13:00:20 +08:00
mark_as_advanced ( ENABLE_SANITIZE_THREAD )
2018-06-29 12:56:35 +08:00
if ( ENABLE_SANITIZE_THREAD )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread" )
endif ( )
2018-06-12 04:29:38 +08:00
endif ( )
2017-07-13 05:54:44 +08:00
########################################################################
# User input options #
########################################################################
2018-06-23 01:11:09 +08:00
option ( BUILD_EXE "Build lmp binary" ON )
if ( BUILD_EXE )
set ( LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary (WON'T enable any features automatically" )
mark_as_advanced ( LAMMPS_MACHINE )
if ( LAMMPS_MACHINE )
set ( LAMMPS_MACHINE "_${LAMMPS_MACHINE}" )
endif ( )
2018-09-05 00:12:49 +08:00
set ( LAMMPS_BINARY lmp ${ LAMMPS_MACHINE } )
2018-06-23 01:11:09 +08:00
endif ( )
2018-06-23 01:06:12 +08:00
option ( BUILD_LIB "Build LAMMPS library" OFF )
if ( BUILD_LIB )
option ( BUILD_SHARED_LIBS "Build shared library" OFF )
if ( BUILD_SHARED_LIBS ) # for all pkg libs, mpi_stubs and linalg
set ( CMAKE_POSITION_INDEPENDENT_CODE ON )
endif ( )
2018-08-30 01:31:28 +08:00
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}" )
2018-06-23 01:06:12 +08:00
endif ( )
2017-08-28 08:40:55 +08:00
endif ( )
2018-06-23 01:11:09 +08:00
if ( NOT BUILD_EXE AND NOT BUILD_LIB )
message ( FATAL_ERROR "You need to at least enable one of two following options: BUILD_LIB or BUILD_EXE" )
2017-08-28 08:40:55 +08:00
endif ( )
2018-06-23 01:11:09 +08:00
2018-05-12 07:50:50 +08:00
option ( CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF )
2017-07-13 05:54:44 +08:00
include ( GNUInstallDirs )
2017-07-15 04:21:21 +08:00
set ( LAMMPS_LINK_LIBS )
2017-09-21 02:01:26 +08:00
set ( LAMMPS_DEPS )
2017-08-29 04:11:21 +08:00
set ( LAMMPS_API_DEFINES )
2018-05-10 13:12:00 +08:00
2019-04-08 10:32:31 +08:00
set ( DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE
G R A N U L A R K S P A C E L A T T E M A N Y B O D Y M C M E S S A G E M I S C M O L E C U L E P E R I P O E M S Q E Q
R E P L I C A R I G I D S H O C K S P I N S N A P S R D K I M P Y T H O N M S C G M P I I O V O R O N O I
U S E R - A T C U S E R - A W P M D U S E R - B O C S U S E R - C G D N A U S E R - M E S O U S E R - C G S D K U S E R - C O L V A R S
U S E R - D I F F R A C T I O N U S E R - D P D U S E R - D R U D E U S E R - E F F U S E R - F E P U S E R - H 5 M D U S E R - L B
U S E R - M A N I F O L D U S E R - M E A M C U S E R - M G P T U S E R - M I S C U S E R - M O F F F U S E R - M O L F I L E
U S E R - N E T C D F U S E R - P H O N O N U S E R - P L U M E D U S E R - P T M U S E R - Q T B U S E R - R E A X C
U S E R - S C A F A C O S U S E R - S D P D U S E R - S M D U S E R - S M T B Q U S E R - S P H U S E R - T A L L Y U S E R - U E F
U S E R - V T K U S E R - Q U I P U S E R - Q M M M U S E R - Y A F F U S E R - A D I O S )
2018-08-07 05:58:53 +08:00
set ( ACCEL_PACKAGES USER-OMP KOKKOS OPT USER-INTEL GPU )
2019-04-08 10:32:31 +08:00
foreach ( PKG ${ DEFAULT_PACKAGES } ${ ACCEL_PACKAGES } )
2018-08-07 05:58:53 +08:00
option ( PKG_ ${ PKG } "Build ${PKG} Package" OFF )
endforeach ( )
######################################################
# packages with special compiler needs or external libs
######################################################
2018-12-11 01:14:03 +08:00
if ( PKG_USER-QUIP OR PKG_USER-QMMM OR PKG_LATTE OR PKG_USER-SCAFACOS )
2018-08-07 05:58:53 +08:00
enable_language ( Fortran )
endif ( )
2018-12-11 01:14:03 +08:00
if ( PKG_USER-H5MD OR PKG_USER-QMMM OR PKG_USER-SCAFACOS )
2018-08-07 05:58:53 +08:00
enable_language ( C )
endif ( )
2018-10-31 16:18:08 +08:00
include_directories ( ${ LAMMPS_SOURCE_DIR } )
2019-01-25 03:14:50 +08:00
if ( PKG_USER-ADIOS )
# The search for ADIOS2 must come before MPI because
# it includes its own MPI search with the latest FindMPI.cmake
2019-03-29 04:35:22 +08:00
# script that defines the MPI::MPI_C target
2019-01-25 03:14:50 +08:00
enable_language ( C )
find_package ( ADIOS2 REQUIRED )
list ( APPEND LAMMPS_LINK_LIBS adios2::adios2 )
endif ( )
2018-08-07 05:58:53 +08:00
# do MPI detection after language activation, if MPI for these language is required
2018-05-10 13:12:00 +08:00
find_package ( MPI QUIET )
option ( BUILD_MPI "Build MPI version" ${ MPI_FOUND } )
if ( BUILD_MPI )
2017-07-15 04:21:21 +08:00
find_package ( MPI REQUIRED )
2018-05-11 09:20:06 +08:00
include_directories ( ${ MPI_CXX_INCLUDE_PATH } )
2017-07-15 04:21:21 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ MPI_CXX_LIBRARIES } )
2017-07-18 03:28:34 +08:00
option ( LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF )
2017-07-18 03:26:46 +08:00
if ( LAMMPS_LONGLONG_TO_LONG )
add_definitions ( -DLAMMPS_LONGLONG_TO_LONG )
endif ( )
2017-07-17 12:53:53 +08:00
else ( )
2018-05-10 12:16:19 +08:00
enable_language ( C )
2017-07-17 12:53:53 +08:00
file ( GLOB MPI_SOURCES ${ LAMMPS_SOURCE_DIR } /STUBS/mpi.c )
2017-08-29 03:17:27 +08:00
add_library ( mpi_stubs STATIC ${ MPI_SOURCES } )
2017-07-17 12:53:53 +08:00
include_directories ( ${ LAMMPS_SOURCE_DIR } /STUBS )
2017-08-27 22:58:47 +08:00
list ( APPEND LAMMPS_LINK_LIBS mpi_stubs )
2017-07-13 05:54:44 +08:00
endif ( )
2018-12-17 05:53:51 +08:00
set ( LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)" )
2018-08-15 22:50:51 +08:00
set ( LAMMPS_SIZES_VALUES smallbig bigbig smallsmall )
set_property ( CACHE LAMMPS_SIZES PROPERTY STRINGS ${ LAMMPS_SIZES_VALUES } )
validate_option ( LAMMPS_SIZES LAMMPS_SIZES_VALUES )
string ( TOUPPER ${ LAMMPS_SIZES } LAMMPS_SIZES )
add_definitions ( -DLAMMPS_ ${ LAMMPS_SIZES } )
set ( LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_${LAMMPS_SIZES}" )
2017-07-18 02:22:28 +08:00
2018-08-02 18:38:25 +08:00
# posix_memalign is not available on Windows
if ( NOT ${ CMAKE_SYSTEM_NAME } STREQUAL "Windows" )
2018-08-10 22:33:20 +08:00
set ( LAMMPS_MEMALIGN "64" CACHE STRING "enables the use of the posix_memalign() call instead of malloc() when large chunks or memory are allocated by LAMMPS. Set to 0 to disable" )
if ( NOT ${ LAMMPS_MEMALIGN } STREQUAL "0" )
add_definitions ( -DLAMMPS_MEMALIGN= ${ LAMMPS_MEMALIGN } )
endif ( )
2018-08-02 18:38:25 +08:00
endif ( )
2017-07-18 03:26:46 +08:00
2017-08-01 01:48:22 +08:00
option ( LAMMPS_EXCEPTIONS "enable the use of C++ exceptions for error messages (useful for library interface)" OFF )
if ( LAMMPS_EXCEPTIONS )
add_definitions ( -DLAMMPS_EXCEPTIONS )
2017-10-01 05:44:15 +08:00
set ( LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_EXCEPTIONS" )
2017-08-01 01:48:22 +08:00
endif ( )
2017-07-13 05:54:44 +08:00
option ( CMAKE_VERBOSE_MAKEFILE "Verbose makefile" OFF )
2017-07-21 06:14:02 +08:00
2017-07-17 01:14:08 +08:00
2018-07-31 15:36:35 +08:00
# "hard" dependencies between packages resulting
# in an error instead of skipping over files
2017-07-17 01:14:08 +08:00
pkg_depends ( MPIIO MPI )
2017-07-17 06:18:58 +08:00
pkg_depends ( USER-ATC MANYBODY )
2017-07-17 07:01:28 +08:00
pkg_depends ( USER-LB MPI )
2017-07-17 07:52:43 +08:00
pkg_depends ( USER-PHONON KSPACE )
2018-08-07 05:58:53 +08:00
pkg_depends ( USER-SCAFACOS MPI )
2018-05-10 13:02:00 +08:00
2019-04-06 20:59:06 +08:00
include ( CheckIncludeFileCXX )
2018-05-10 13:09:23 +08:00
find_package ( OpenMP QUIET )
2019-05-31 10:23:50 +08:00
# TODO: this is a temporary workaround until a better solution is found. AK 2019-05-30
# GNU GCC 9.x uses settings incompatible with our use of 'default(none)' in OpenMP pragmas
# where we assume older GCC semantics. For the time being, we disable OpenMP by default
# for GCC 9.x and beyond. People may manually turn it on, but need to run the script
# src/USER-OMP/hack_openmp_for_pgi_gcc9.sh on all sources to make it compatible with gcc 9.
2019-06-04 07:50:48 +08:00
if ( ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) AND ( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.99.9 ) )
2019-05-31 10:23:50 +08:00
option ( BUILD_OMP "Build with OpenMP support" OFF )
else ( )
option ( BUILD_OMP "Build with OpenMP support" ${ OpenMP_FOUND } )
endif ( )
2019-04-01 02:59:20 +08:00
if ( BUILD_OMP )
2017-07-17 11:31:57 +08:00
find_package ( OpenMP REQUIRED )
2019-04-06 20:59:06 +08:00
check_include_file_cxx ( omp.h HAVE_OMP_H_INCLUDE )
if ( NOT HAVE_OMP_H_INCLUDE )
message ( FATAL_ERROR "Cannot find required 'omp.h' header file" )
endif ( )
2017-07-17 11:31:57 +08:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_KSPACE )
2018-05-11 02:52:04 +08:00
option ( FFT_SINGLE "Use single precision FFT instead of double" OFF )
set ( FFTW "FFTW3" )
if ( FFT_SINGLE )
set ( FFTW "FFTW3F" )
add_definitions ( -DFFT_SINGLE )
endif ( )
find_package ( ${ FFTW } QUIET )
if ( ${ FFTW } _FOUND )
2018-05-11 06:11:10 +08:00
set ( FFT "${FFTW}" CACHE STRING "FFT library for KSPACE package" )
2018-05-11 02:52:04 +08:00
else ( )
2018-08-14 03:53:50 +08:00
set ( FFT "KISS" CACHE STRING "FFT library for KSPACE package" )
2018-05-11 02:52:04 +08:00
endif ( )
2018-08-15 22:50:51 +08:00
set ( FFT_VALUES KISS ${ FFTW } MKL )
set_property ( CACHE FFT PROPERTY STRINGS ${ FFT_VALUES } )
validate_option ( FFT FFT_VALUES )
2018-08-16 06:26:54 +08:00
string ( TOUPPER ${ FFT } FFT )
2018-08-14 03:53:50 +08:00
if ( NOT FFT STREQUAL "KISS" )
2017-07-20 08:54:15 +08:00
find_package ( ${ FFT } REQUIRED )
2018-05-11 02:52:04 +08:00
if ( NOT FFT STREQUAL "FFTW3F" )
2018-05-12 05:27:24 +08:00
add_definitions ( -DFFT_FFTW )
2018-05-11 02:52:04 +08:00
else ( )
add_definitions ( -DFFT_ ${ FFT } )
endif ( )
2017-07-20 08:54:15 +08:00
include_directories ( ${ ${FFT } _INCLUDE_DIRS} )
list ( APPEND LAMMPS_LINK_LIBS ${ ${FFT } _LIBRARIES} )
2018-08-10 23:27:40 +08:00
else ( )
2018-08-14 03:53:50 +08:00
add_definitions ( -DFFT_KISS )
2017-07-20 08:54:15 +08:00
endif ( )
2018-08-14 03:53:50 +08:00
set ( FFT_PACK "array" CACHE STRING "Optimization for FFT" )
2018-08-15 22:50:51 +08:00
set ( FFT_PACK_VALUES array pointer memcpy )
set_property ( CACHE FFT_PACK PROPERTY STRINGS ${ FFT_PACK_VALUES } )
validate_option ( FFT_PACK FFT_PACK_VALUES )
2018-08-14 03:53:50 +08:00
if ( NOT FFT_PACK STREQUAL "array" )
2018-08-15 22:50:51 +08:00
string ( TOUPPER ${ FFT_PACK } FFT_PACK )
add_definitions ( -DFFT_PACK_ ${ FFT_PACK } )
2017-07-20 00:35:48 +08:00
endif ( )
2017-07-18 03:21:42 +08:00
endif ( )
2019-04-05 02:04:12 +08:00
if ( PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-PLUMED OR PKG_USER-QUIP OR PKG_LATTE )
2017-07-17 11:43:29 +08:00
find_package ( LAPACK )
2018-08-24 05:02:36 +08:00
find_package ( BLAS )
if ( NOT LAPACK_FOUND OR NOT BLAS_FOUND )
2017-07-17 11:43:29 +08:00
enable_language ( Fortran )
2018-09-07 04:37:08 +08:00
file ( GLOB LAPACK_SOURCES ${ LAMMPS_LIB_SOURCE_DIR } /linalg/[^.]*.[fF] )
2017-08-29 03:17:27 +08:00
add_library ( linalg STATIC ${ LAPACK_SOURCES } )
2017-08-27 15:54:40 +08:00
set ( LAPACK_LIBRARIES linalg )
2018-08-24 05:02:36 +08:00
else ( )
list ( APPEND LAPACK_LIBRARIES ${ BLAS_LIBRARIES } )
2017-07-17 11:43:29 +08:00
endif ( )
2017-07-17 06:18:58 +08:00
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_PYTHON )
2017-07-16 22:22:19 +08:00
find_package ( PythonLibs REQUIRED )
add_definitions ( -DLMP_PYTHON )
include_directories ( ${ PYTHON_INCLUDE_DIR } )
list ( APPEND LAMMPS_LINK_LIBS ${ PYTHON_LIBRARY } )
2017-07-16 07:29:33 +08:00
endif ( )
2018-05-10 05:54:04 +08:00
find_package ( JPEG QUIET )
2018-05-11 21:51:59 +08:00
option ( WITH_JPEG "Enable JPEG support" ${ JPEG_FOUND } )
if ( WITH_JPEG )
2018-05-10 05:54:04 +08:00
find_package ( JPEG REQUIRED )
2017-07-14 12:54:48 +08:00
add_definitions ( -DLAMMPS_JPEG )
include_directories ( ${ JPEG_INCLUDE_DIR } )
2017-07-15 04:21:21 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ JPEG_LIBRARIES } )
2017-07-14 12:54:48 +08:00
endif ( )
2018-05-10 05:54:04 +08:00
find_package ( PNG QUIET )
find_package ( ZLIB QUIET )
2017-07-15 04:44:44 +08:00
if ( PNG_FOUND AND ZLIB_FOUND )
2018-05-11 10:33:18 +08:00
option ( WITH_PNG "Enable PNG support" ON )
2018-05-10 05:54:04 +08:00
else ( )
2018-05-11 10:33:18 +08:00
option ( WITH_PNG "Enable PNG support" OFF )
2018-05-10 05:54:04 +08:00
endif ( )
2018-05-11 10:33:18 +08:00
if ( WITH_PNG )
2018-05-10 05:54:04 +08:00
find_package ( PNG REQUIRED )
find_package ( ZLIB REQUIRED )
2017-07-15 04:44:44 +08:00
include_directories ( ${ PNG_INCLUDE_DIRS } ${ ZLIB_INCLUDE_DIRS } )
list ( APPEND LAMMPS_LINK_LIBS ${ PNG_LIBRARIES } ${ ZLIB_LIBRARIES } )
2017-07-14 16:53:07 +08:00
add_definitions ( -DLAMMPS_PNG )
2017-07-15 04:44:44 +08:00
endif ( )
2017-07-14 16:53:07 +08:00
2017-07-23 03:57:15 +08:00
find_program ( GZIP_EXECUTABLE gzip )
find_package_handle_standard_args ( GZIP REQUIRED_VARS GZIP_EXECUTABLE )
2018-05-11 10:33:18 +08:00
option ( WITH_GZIP "Enable GZIP support" ${ GZIP_FOUND } )
if ( WITH_GZIP )
2018-05-10 05:54:04 +08:00
if ( NOT GZIP_FOUND )
message ( FATAL_ERROR "gzip executable not found" )
endif ( )
2017-07-15 04:49:53 +08:00
add_definitions ( -DLAMMPS_GZIP )
endif ( )
2017-07-23 03:57:15 +08:00
find_program ( FFMPEG_EXECUTABLE ffmpeg )
find_package_handle_standard_args ( FFMPEG REQUIRED_VARS FFMPEG_EXECUTABLE )
2018-05-11 10:33:18 +08:00
option ( WITH_FFMPEG "Enable FFMPEG support" ${ FFMPEG_FOUND } )
if ( WITH_FFMPEG )
2018-05-10 05:54:04 +08:00
if ( NOT FFMPEG_FOUND )
message ( FATAL_ERROR "ffmpeg executable not found" )
endif ( )
2017-07-18 04:01:05 +08:00
add_definitions ( -DLAMMPS_FFMPEG )
endif ( )
2018-12-17 05:53:51 +08:00
if ( BUILD_SHARED_LIBS )
set ( CONFIGURE_REQUEST_PIC "--with-pic" )
set ( CMAKE_REQUEST_PIC "-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}" )
set ( CUDA_REQUEST_PIC "-Xcompiler ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}" )
else ( )
set ( CONFIGURE_REQUEST_PIC )
set ( CMAKE_REQUEST_PIC )
set ( CUDA_REQUEST_PIC )
endif ( )
2019-06-09 15:23:23 +08:00
include ( Packages/VORONOI )
2017-07-17 01:29:31 +08:00
2018-05-11 21:51:59 +08:00
if ( PKG_LATTE )
2019-04-07 05:49:56 +08:00
find_package ( LATTE )
if ( LATTE_FOUND )
set ( DOWNLOAD_LATTE_DEFAULT OFF )
else ( )
set ( DOWNLOAD_LATTE_DEFAULT ON )
endif ( )
option ( DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${ DOWNLOAD_LATTE_DEFAULT } )
2018-05-11 01:09:15 +08:00
if ( DOWNLOAD_LATTE )
2018-11-05 23:24:02 +08:00
if ( CMAKE_VERSION VERSION_LESS "3.7" ) # due to SOURCE_SUBDIR
2018-08-21 00:07:49 +08:00
message ( FATAL_ERROR "For downlading LATTE you need at least cmake-3.7" )
endif ( )
2018-12-17 05:53:51 +08:00
message ( STATUS "LATTE download requested - we will build our own" )
2017-09-21 02:01:26 +08:00
include ( ExternalProject )
ExternalProject_Add ( latte_build
2018-06-26 04:23:44 +08:00
U R L h t t p s : / / g i t h u b . c o m / l a n l / L A T T E / a r c h i v e / v 1 . 2 . 1 . t a r . g z
2018-07-24 00:36:29 +08:00
U R L _ M D 5 8 5 a c 4 1 4 f d a d a 2 d 0 4 6 1 9 c 8 f 9 3 6 3 4 4 d f 1 4
2017-09-21 02:01:26 +08:00
S O U R C E _ S U B D I R c m a k e
2019-05-05 03:11:53 +08:00
C M A K E _ A R G S - D C M A K E _ I N S T A L L _ P R E F I X = < I N S T A L L _ D I R > $ { C M A K E _ R E Q U E S T _ P I C }
- D B L A S _ L I B R A R I E S = $ { B L A S _ L I B R A R I E S } - D L A P A C K _ L I B R A R I E S = $ { L A P A C K _ L I B R A R I E S }
- D C M A K E _ F o r t r a n _ C O M P I L E R = $ { C M A K E _ F o r t r a n _ C O M P I L E R } - D C M A K E _ F o r t r a n _ F L A G S = $ { C M A K E _ F o r t r a n _ F L A G S }
- D C M A K E _ F o r t r a n _ F L A G S _ $ { B T Y P E } = $ { C M A K E _ F o r t r a n _ F L A G S _ $ { B T Y P E } } - D C M A K E _ B U I L D _ T Y P E = $ { C M A K E _ B U I L D _ T Y P E }
2018-12-17 05:53:51 +08:00
)
2017-09-21 02:01:26 +08:00
ExternalProject_get_property ( latte_build INSTALL_DIR )
set ( LATTE_LIBRARIES ${ INSTALL_DIR } / ${ CMAKE_INSTALL_LIBDIR } /liblatte.a )
list ( APPEND LAMMPS_DEPS latte_build )
2018-05-11 01:09:15 +08:00
else ( )
find_package ( LATTE )
if ( NOT LATTE_FOUND )
2018-12-17 05:53:51 +08:00
message ( FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it" )
2018-05-11 01:09:15 +08:00
endif ( )
2017-09-21 02:01:26 +08:00
endif ( )
2018-06-09 06:14:28 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ LATTE_LIBRARIES } ${ LAPACK_LIBRARIES } )
2017-09-09 01:33:49 +08:00
endif ( )
2018-07-10 03:53:31 +08:00
if ( PKG_USER-SCAFACOS )
2018-08-07 05:58:53 +08:00
find_package ( GSL REQUIRED )
2019-04-07 18:10:39 +08:00
find_package ( PkgConfig QUIET )
set ( DOWNLOAD_SCAFACOS_DEFAULT ON )
if ( PKG_CONFIG_FOUND )
pkg_check_modules ( SCAFACOS QUIET scafacos )
if ( SCAFACOS_FOUND )
set ( DOWNLOAD_SCAFACOS_DEFAULT OFF )
endif ( )
endif ( )
option ( DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${ DOWNLOAD_SCAFACOS_DEFAULT } )
2018-08-07 05:58:53 +08:00
if ( DOWNLOAD_SCAFACOS )
2018-12-17 05:53:51 +08:00
message ( STATUS "ScaFaCoS download requested - we will build our own" )
2018-08-07 05:58:53 +08:00
include ( ExternalProject )
ExternalProject_Add ( scafacos_build
2018-08-09 04:05:28 +08:00
U R L h t t p s : / / g i t h u b . c o m / s c a f a c o s / s c a f a c o s / r e l e a s e s / d o w n l o a d / v 1 . 0 . 1 / s c a f a c o s - 1 . 0 . 1 . t a r . g z
U R L _ M D 5 b d 4 6 d 7 4 e 3 2 9 6 b d 8 a 4 4 4 d 7 3 1 b b 1 0 c 1 7 3 8
2018-12-17 05:53:51 +08:00
C O N F I G U R E _ C O M M A N D < S O U R C E _ D I R > / c o n f i g u r e - - p r e f i x = < I N S T A L L _ D I R > - - d i s a b l e - d o c
2018-08-08 04:26:53 +08:00
- - e n a b l e - f c s - s o l v e r s = f m m , p 2 n f f t , d i r e c t , e w a l d , p 3 m
2018-12-17 05:53:51 +08:00
- - w i t h - i n t e r n a l - f f t w - - w i t h - i n t e r n a l - p f f t
- - w i t h - i n t e r n a l - p n f f t $ { C O N F I G U R E _ R E Q U E S T _ P I C }
2018-11-05 23:24:02 +08:00
F C = $ { C M A K E _ M P I _ F o r t r a n _ C O M P I L E R }
C X X = $ { C M A K E _ M P I _ C X X _ C O M P I L E R }
2018-08-07 05:58:53 +08:00
C C = $ { C M A K E _ M P I _ C _ C O M P I L E R }
F 7 7 =
2018-12-17 05:53:51 +08:00
)
2018-08-07 05:58:53 +08:00
ExternalProject_get_property ( scafacos_build INSTALL_DIR )
set ( SCAFACOS_BUILD_DIR ${ INSTALL_DIR } )
set ( SCAFACOS_INCLUDE_DIRS ${ SCAFACOS_BUILD_DIR } /include )
list ( APPEND LAMMPS_DEPS scafacos_build )
# list and order from pkg_config file of ScaFaCoS build
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_direct.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_ewald.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_fmm.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_p2nfft.a )
2018-08-08 04:26:53 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_p3m.a )
2018-08-07 05:58:53 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ GSL_LIBRARIES } )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_near.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_gridsort.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_resort.a )
2018-08-09 04:05:28 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_redist.a )
2018-08-07 05:58:53 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_common.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_pnfft.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_pfft.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_fftw3_mpi.a )
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_BUILD_DIR } /lib/libfcs_fftw3.a )
list ( APPEND LAMMPS_LINK_LIBS ${ MPI_Fortran_LIBRARIES } )
list ( APPEND LAMMPS_LINK_LIBS ${ MPI_C_LIBRARIES } )
else ( )
2019-04-07 18:10:39 +08:00
find_package ( PkgConfig REQUIRED )
pkg_check_modules ( SCAFACOS REQUIRED scafacos )
2018-07-10 03:00:52 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ SCAFACOS_LDFLAGS } )
2018-08-07 05:58:53 +08:00
endif ( )
include_directories ( ${ SCAFACOS_INCLUDE_DIRS } )
2018-07-10 03:00:52 +08:00
endif ( )
2018-12-17 05:53:51 +08:00
if ( PKG_USER-PLUMED )
find_package ( GSL REQUIRED )
set ( PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library" )
set ( PLUMED_MODE_VALUES static shared runtime )
set_property ( CACHE PLUMED_MODE PROPERTY STRINGS ${ PLUMED_MODE_VALUES } )
validate_option ( PLUMED_MODE PLUMED_MODE_VALUES )
string ( TOUPPER ${ PLUMED_MODE } PLUMED_MODE )
2019-04-07 12:45:57 +08:00
find_package ( PkgConfig QUIET )
set ( DOWNLOAD_PLUMED_DEFAULT ON )
if ( PKG_CONFIG_FOUND )
pkg_check_modules ( PLUMED QUIET plumed )
if ( PLUMED_FOUND )
set ( DOWNLOAD_PLUMED_DEFAULT OFF )
endif ( )
endif ( )
option ( DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${ DOWNLOAD_PLUMED_DEFAULT } )
2018-12-17 05:53:51 +08:00
if ( DOWNLOAD_PLUMED )
2019-04-03 05:25:26 +08:00
if ( BUILD_MPI )
set ( PLUMED_CONFIG_MPI "--enable-mpi" )
set ( PLUMED_CONFIG_CC ${ CMAKE_MPI_C_COMPILER } )
set ( PLUMED_CONFIG_CXX ${ CMAKE_MPI_CXX_COMPILER } )
else ( )
set ( PLUMED_CONFIG_MPI "--disable-mpi" )
set ( PLUMED_CONFIG_CC ${ CMAKE_C_COMPILER } )
set ( PLUMED_CONFIG_CXX ${ CMAKE_CXX_COMPILER } )
endif ( )
if ( BUILD_OMP )
set ( PLUMED_CONFIG_OMP "--enable-openmp" )
else ( )
set ( PLUMED_CONFIG_OMP "--disable-openmp" )
endif ( )
2018-12-17 05:53:51 +08:00
message ( STATUS "PLUMED download requested - we will build our own" )
include ( ExternalProject )
ExternalProject_Add ( plumed_build
2019-04-05 02:04:12 +08:00
U R L h t t p s : / / g i t h u b . c o m / p l u m e d / p l u m e d 2 / r e l e a s e s / d o w n l o a d / v 2 . 5 . 1 / p l u m e d - s r c - 2 . 5 . 1 . t g z
U R L _ M D 5 c 2 a 7 b 5 1 9 e 3 2 1 9 7 a 1 2 0 c d f 4 7 e 0 f 1 9 4 f 8 1
2018-12-17 05:53:51 +08:00
B U I L D _ I N _ S O U R C E 1
2019-01-26 22:55:48 +08:00
C O N F I G U R E _ C O M M A N D < S O U R C E _ D I R > / c o n f i g u r e - - p r e f i x = < I N S T A L L _ D I R >
$ { C O N F I G U R E _ R E Q U E S T _ P I C }
2019-04-03 05:25:26 +08:00
- - e n a b l e - m o d u l e s = a l l
$ { P L U M E D _ C O N F I G _ M P I }
$ { P L U M E D _ C O N F I G _ O M P }
C X X = $ { P L U M E D _ C O N F I G _ C X X }
C C = $ { P L U M E D _ C O N F I G _ C C }
2019-01-26 22:55:48 +08:00
)
2018-12-17 05:53:51 +08:00
ExternalProject_get_property ( plumed_build INSTALL_DIR )
set ( PLUMED_INSTALL_DIR ${ INSTALL_DIR } )
list ( APPEND LAMMPS_DEPS plumed_build )
if ( PLUMED_MODE STREQUAL "STATIC" )
add_definitions ( -D__PLUMED_WRAPPER_CXX=1 )
2019-04-05 02:04:12 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ PLUMED_INSTALL_DIR } /lib/libplumed.a ${ GSL_LIBRARIES } ${ LAPACK_LIBRARIES } ${ CMAKE_DL_LIBS } )
2018-12-17 05:53:51 +08:00
elseif ( PLUMED_MODE STREQUAL "SHARED" )
2019-04-05 02:04:12 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ PLUMED_INSTALL_DIR } /lib/libplumed.so ${ PLUMED_INSTALL_DIR } /lib/libplumedKernel.so ${ CMAKE_DL_LIBS } )
2018-12-17 05:53:51 +08:00
elseif ( PLUMED_MODE STREQUAL "RUNTIME" )
add_definitions ( -D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL= ${ PLUMED_INSTALL_DIR } /lib/libplumedKernel.so )
list ( APPEND LAMMPS_LINK_LIBS ${ PLUMED_INSTALL_DIR } /lib/libplumedWrapper.a -rdynamic ${ CMAKE_DL_LIBS } )
endif ( )
set ( PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include" )
else ( )
find_package ( PkgConfig REQUIRED )
2019-04-07 12:45:57 +08:00
pkg_check_modules ( PLUMED REQUIRED plumed )
2018-12-17 05:53:51 +08:00
if ( PLUMED_MODE STREQUAL "STATIC" )
add_definitions ( -D__PLUMED_WRAPPER_CXX=1 )
include ( ${ PLUMED_LIBDIR } /plumed/src/lib/Plumed.cmake.static )
elseif ( PLUMED_MODE STREQUAL "SHARED" )
include ( ${ PLUMED_LIBDIR } /plumed/src/lib/Plumed.cmake.shared )
elseif ( PLUMED_MODE STREQUAL "RUNTIME" )
add_definitions ( -D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL= ${ PLUMED_LIBDIR } /libplumedKernel.so )
include ( ${ PLUMED_LIBDIR } /plumed/src/lib/Plumed.cmake.runtime )
endif ( )
list ( APPEND LAMMPS_LINK_LIBS ${ PLUMED_LOAD } )
endif ( )
include_directories ( ${ PLUMED_INCLUDE_DIRS } )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-MOLFILE )
2019-03-23 02:11:02 +08:00
set ( MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers" )
2017-08-28 02:23:30 +08:00
add_library ( molfile INTERFACE )
2019-03-23 02:11:02 +08:00
target_include_directories ( molfile INTERFACE ${ MOLFILE_INCLUDE_DIRS } )
2019-04-02 05:22:53 +08:00
# no need to link with -ldl on windows
if ( NOT ${ CMAKE_SYSTEM_NAME } STREQUAL "Windows" )
target_link_libraries ( molfile INTERFACE ${ CMAKE_DL_LIBS } )
endif ( )
2017-08-28 02:23:30 +08:00
list ( APPEND LAMMPS_LINK_LIBS molfile )
2017-07-17 07:52:43 +08:00
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-NETCDF )
2017-07-17 07:52:43 +08:00
find_package ( NetCDF REQUIRED )
2018-09-04 21:14:42 +08:00
include_directories ( ${ NETCDF_INCLUDE_DIRS } )
list ( APPEND LAMMPS_LINK_LIBS ${ NETCDF_LIBRARIES } )
2017-07-17 07:52:43 +08:00
add_definitions ( -DLMP_HAS_NETCDF -DNC_64BIT_DATA=0x0020 )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-SMD )
2019-04-07 12:45:57 +08:00
find_package ( Eigen3 NO_MODULE )
if ( EIGEN3_FOUND )
set ( DOWNLOAD_EIGEN3_DEFAULT OFF )
else ( )
set ( DOWNLOAD_EIGEN3_DEFAULT ON )
endif ( )
option ( DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${ DOWNLOAD_EIGEN3_DEFAULT } )
2018-08-15 05:44:25 +08:00
if ( DOWNLOAD_EIGEN3 )
2018-12-17 05:53:51 +08:00
message ( STATUS "Eigen3 download requested - we will build our own" )
2018-05-11 01:04:56 +08:00
include ( ExternalProject )
ExternalProject_Add ( Eigen3_build
2019-01-15 04:02:09 +08:00
U R L h t t p : / / b i t b u c k e t . o r g / e i g e n / e i g e n / g e t / 3 . 3 . 7 . t a r . g z
U R L _ M D 5 f 2 a 4 1 7 d 0 8 3 f e 8 c a 4 b 8 e d 2 b c 6 1 3 d 2 0 f 0 7
2018-05-18 10:07:43 +08:00
C O N F I G U R E _ C O M M A N D " " B U I L D _ C O M M A N D " " I N S T A L L _ C O M M A N D " "
)
ExternalProject_get_property ( Eigen3_build SOURCE_DIR )
set ( EIGEN3_INCLUDE_DIR ${ SOURCE_DIR } )
2018-05-11 01:04:56 +08:00
list ( APPEND LAMMPS_DEPS Eigen3_build )
else ( )
2018-09-10 12:35:55 +08:00
find_package ( Eigen3 NO_MODULE )
mark_as_advanced ( Eigen3_DIR )
2018-09-07 04:18:28 +08:00
if ( NOT EIGEN3_FOUND )
2018-08-15 05:44:25 +08:00
message ( FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it" )
2018-05-11 01:04:56 +08:00
endif ( )
endif ( )
2017-07-17 07:52:43 +08:00
include_directories ( ${ EIGEN3_INCLUDE_DIR } )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-QUIP )
2017-07-17 11:31:57 +08:00
find_package ( QUIP REQUIRED )
2018-06-09 06:14:28 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ QUIP_LIBRARIES } ${ LAPACK_LIBRARIES } )
2017-07-17 11:31:57 +08:00
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-QMMM )
2018-05-10 12:42:33 +08:00
message ( WARNING "Building QMMM with CMake is still experimental" )
2017-07-17 12:07:21 +08:00
find_package ( QE REQUIRED )
include_directories ( ${ QE_INCLUDE_DIRS } )
2018-06-09 06:14:28 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ QE_LIBRARIES } )
2017-07-17 12:07:21 +08:00
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-VTK )
2017-07-20 08:34:07 +08:00
find_package ( VTK REQUIRED NO_MODULE )
include ( ${ VTK_USE_FILE } )
add_definitions ( -DLAMMPS_VTK )
list ( APPEND LAMMPS_LINK_LIBS ${ VTK_LIBRARIES } )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_KIM )
2018-08-21 10:15:02 +08:00
find_package ( CURL )
if ( CURL_FOUND )
2019-03-29 04:35:22 +08:00
include_directories ( ${ CURL_INCLUDE_DIRS } )
2018-08-21 10:15:02 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ CURL_LIBRARIES } )
add_definitions ( -DLMP_KIM_CURL )
endif ( )
2019-04-07 04:47:48 +08:00
find_package ( KIM-API QUIET )
if ( KIM-API_FOUND )
2019-04-07 05:17:17 +08:00
set ( DOWNLOAD_KIM_DEFAULT OFF )
2019-04-07 04:47:48 +08:00
else ( )
2019-04-07 05:17:17 +08:00
set ( DOWNLOAD_KIM_DEFAULT ON )
2019-04-07 04:47:48 +08:00
endif ( )
2019-04-07 05:17:17 +08:00
option ( DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${ DOWNLOAD_KIM_DEFAULT } )
2018-05-12 23:48:15 +08:00
if ( DOWNLOAD_KIM )
2019-03-29 04:35:22 +08:00
message ( STATUS "KIM-API download requested - we will build our own" )
2018-11-06 05:39:10 +08:00
enable_language ( C )
enable_language ( Fortran )
2018-04-07 07:22:54 +08:00
include ( ExternalProject )
ExternalProject_Add ( kim_build
2019-03-29 04:35:22 +08:00
U R L h t t p s : / / s 3 . o p e n k i m . o r g / k i m - a p i / k i m - a p i - 2 . 0 . 2 . t x z
U R L _ M D 5 5 3 7 d 9 c 0 a b d 3 0 f 8 5 b 8 7 5 e b b 5 8 4 f 9 1 4 3 f a
2018-11-05 23:24:02 +08:00
B I N A R Y _ D I R b u i l d
2018-11-06 05:39:10 +08:00
C M A K E _ A R G S - D C M A K E _ C _ C O M P I L E R = $ { C M A K E _ C _ C O M P I L E R }
- D C M A K E _ C X X _ C O M P I L E R = $ { C M A K E _ C X X _ C O M P I L E R }
- D C M A K E _ F o r t r a n _ C O M P I L E R = $ { C M A K E _ F o r t r a n _ C O M P I L E R }
- D C M A K E _ I N S T A L L _ P R E F I X = < I N S T A L L _ D I R >
2019-02-15 16:53:09 +08:00
- D C M A K E _ B U I L D _ T Y P E = $ { C M A K E _ B U I L D _ T Y P E }
2018-04-07 07:22:54 +08:00
)
ExternalProject_get_property ( kim_build INSTALL_DIR )
2019-03-29 04:35:22 +08:00
set ( KIM-API_INCLUDE_DIRS ${ INSTALL_DIR } /include/kim-api )
set ( KIM-API_LDFLAGS ${ INSTALL_DIR } / ${ CMAKE_INSTALL_LIBDIR } /libkim-api ${ CMAKE_SHARED_LIBRARY_SUFFIX } )
2018-04-07 07:22:54 +08:00
list ( APPEND LAMMPS_DEPS kim_build )
2018-05-12 23:48:15 +08:00
else ( )
2019-04-07 04:47:48 +08:00
find_package ( KIM-API REQUIRED )
2018-04-07 07:22:54 +08:00
endif ( )
2019-03-29 04:35:22 +08:00
list ( APPEND LAMMPS_LINK_LIBS "${KIM-API_LDFLAGS}" )
include_directories ( ${ KIM-API_INCLUDE_DIRS } )
2017-07-20 08:34:07 +08:00
endif ( )
2018-08-23 01:21:14 +08:00
if ( PKG_MESSAGE )
option ( MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF )
2018-09-07 04:37:08 +08:00
file ( GLOB_RECURSE cslib_SOURCES ${ LAMMPS_LIB_SOURCE_DIR } /message/cslib/[^.]*.F
2018-09-07 20:40:06 +08:00
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / m e s s a g e / c s l i b / [ ^ . ] * . c
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / m e s s a g e / c s l i b / [ ^ . ] * . c p p )
2018-08-29 19:52:16 +08:00
2018-12-17 05:53:51 +08:00
add_library ( cslib STATIC ${ cslib_SOURCES } )
2018-08-23 01:21:14 +08:00
if ( BUILD_MPI )
target_compile_definitions ( cslib PRIVATE -DMPI_YES )
2018-08-29 19:30:53 +08:00
set_target_properties ( cslib PROPERTIES OUTPUT_NAME "csmpi" )
2018-08-23 01:21:14 +08:00
else ( )
target_compile_definitions ( cslib PRIVATE -DMPI_NO )
2019-04-03 12:41:03 +08:00
target_include_directories ( cslib PRIVATE ${ LAMMPS_LIB_SOURCE_DIR } /message/cslib/src/STUBS_MPI )
2018-08-29 19:30:53 +08:00
set_target_properties ( cslib PROPERTIES OUTPUT_NAME "csnompi" )
2018-08-23 01:21:14 +08:00
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 )
2018-08-29 18:51:20 +08:00
target_include_directories ( cslib PRIVATE ${ LAMMPS_LIB_SOURCE_DIR } /message/cslib/src/STUBS_ZMQ )
2018-08-23 01:21:14 +08:00
endif ( )
list ( APPEND LAMMPS_LINK_LIBS cslib )
include_directories ( ${ LAMMPS_LIB_SOURCE_DIR } /message/cslib/src )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_MSCG )
2017-07-20 08:34:07 +08:00
find_package ( GSL REQUIRED )
2019-04-07 12:45:57 +08:00
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 } )
2018-05-18 07:23:54 +08:00
if ( DOWNLOAD_MSCG )
2018-11-05 23:24:02 +08:00
if ( CMAKE_VERSION VERSION_LESS "3.7" ) # due to SOURCE_SUBDIR
2018-12-17 05:53:51 +08:00
message ( FATAL_ERROR "For downlading MSCG you need at least cmake-3.7" )
2018-08-21 00:07:49 +08:00
endif ( )
2018-05-18 07:23:54 +08:00
include ( ExternalProject )
if ( NOT LAPACK_FOUND )
set ( EXTRA_MSCG_OPTS "-DLAPACK_LIBRARIES=${CMAKE_CURRENT_BINARY_DIR}/liblinalg.a" )
endif ( )
ExternalProject_Add ( mscg_build
2018-05-18 10:01:33 +08:00
U R L h t t p s : / / g i t h u b . c o m / u c h i c a g o - v o t h / M S C G - r e l e a s e / a r c h i v e / 1 . 7 . 3 . 1 . t a r . g z
2018-05-18 07:23:54 +08:00
U R L _ M D 5 8 c 4 5 e 2 6 9 e e 1 3 f 6 0 b 3 0 3 e d d 7 8 2 3 8 6 6 a 9 1
S O U R C E _ S U B D I R s r c / C M a k e
2018-12-17 05:53:51 +08:00
C M A K E _ A R G S - D C M A K E _ I N S T A L L _ P R E F I X = < I N S T A L L _ D I R > $ { C M A K E _ R E Q U E S T _ P I C } $ { E X T R A _ M S C G _ O P T S }
2018-05-18 10:01:33 +08:00
B U I L D _ C O M M A N D m a k e m s c g I N S T A L L _ C O M M A N D " "
2018-05-18 07:23:54 +08:00
)
2018-05-18 10:01:33 +08:00
ExternalProject_get_property ( mscg_build BINARY_DIR )
set ( MSCG_LIBRARIES ${ BINARY_DIR } /libmscg.a )
ExternalProject_get_property ( mscg_build SOURCE_DIR )
set ( MSCG_INCLUDE_DIRS ${ SOURCE_DIR } /src )
2018-05-18 07:23:54 +08:00
list ( APPEND LAMMPS_DEPS mscg_build )
if ( NOT LAPACK_FOUND )
2018-05-19 05:06:54 +08:00
file ( MAKE_DIRECTORY ${ MSCG_INCLUDE_DIRS } )
2018-05-18 07:23:54 +08:00
add_dependencies ( mscg_build linalg )
endif ( )
else ( )
find_package ( MSCG )
if ( NOT MSCG_FOUND )
message ( FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it" )
2017-07-20 08:34:07 +08:00
endif ( )
endif ( )
2018-05-18 10:01:33 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ MSCG_LIBRARIES } ${ GSL_LIBRARIES } ${ LAPACK_LIBRARIES } )
2018-05-18 07:23:54 +08:00
include_directories ( ${ MSCG_INCLUDE_DIRS } )
2017-07-20 08:34:07 +08:00
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_COMPRESS )
2018-05-10 12:24:22 +08:00
find_package ( ZLIB REQUIRED )
include_directories ( ${ ZLIB_INCLUDE_DIRS } )
list ( APPEND LAMMPS_LINK_LIBS ${ ZLIB_LIBRARIES } )
endif ( )
2018-08-02 18:38:25 +08:00
# the windows version of LAMMPS requires a couple extra libraries
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Windows" )
list ( APPEND LAMMPS_LINK_LIBS -lwsock32 -lpsapi )
endif ( )
2017-07-13 05:54:44 +08:00
########################################################################
# Basic system tests (standard libraries, headers, functions, types) #
########################################################################
2019-01-09 22:18:55 +08:00
foreach ( HEADER cmath )
2018-05-10 12:16:19 +08:00
check_include_file_cxx ( ${ HEADER } FOUND_ ${ HEADER } )
2017-07-13 05:54:44 +08:00
if ( NOT FOUND_ ${ HEADER } )
message ( FATAL_ERROR "Could not find needed header - ${HEADER}" )
endif ( NOT FOUND_ ${ HEADER } )
endforeach ( HEADER )
set ( MATH_LIBRARIES "m" CACHE STRING "math library" )
mark_as_advanced ( MATH_LIBRARIES )
include ( CheckLibraryExists )
2018-06-23 07:05:55 +08:00
if ( CMAKE_VERSION VERSION_LESS "3.4" )
2018-12-17 05:53:51 +08:00
enable_language ( C ) # check_library_exists isn't supported without a C compiler before v3.4
2018-06-23 07:05:55 +08:00
endif ( )
2018-08-14 23:56:57 +08:00
# RB: disabled this check because it breaks with KOKKOS CUDA enabled
#foreach(FUNC sin cos)
# check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES})
# if(NOT FOUND_${FUNC}_${MATH_LIBRARIES})
# message(FATAL_ERROR "Could not find needed math function - ${FUNC}")
# endif(NOT FOUND_${FUNC}_${MATH_LIBRARIES})
#endforeach(FUNC)
2017-07-15 04:21:21 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ MATH_LIBRARIES } )
2017-07-13 05:54:44 +08:00
######################################
2017-09-09 10:20:47 +08:00
# Generate Basic Style files
2017-07-13 05:54:44 +08:00
######################################
2017-07-15 06:49:05 +08:00
include ( StyleHeaderUtils )
RegisterStyles ( ${ LAMMPS_SOURCE_DIR } )
2017-07-20 08:34:07 +08:00
##############################################
# add sources of enabled packages
############################################
2018-06-28 09:02:10 +08:00
foreach ( PKG ${ DEFAULT_PACKAGES } )
2017-08-19 18:33:27 +08:00
set ( ${ PKG } _SOURCES_DIR ${ LAMMPS_SOURCE_DIR } / ${ PKG } )
2018-09-07 04:37:08 +08:00
file ( GLOB ${ PKG } _SOURCES ${ ${PKG } _SOURCES_DIR}/[^.]*.cpp )
file ( GLOB ${ PKG } _HEADERS ${ ${PKG } _SOURCES_DIR}/[^.]*.h )
2017-07-15 06:49:05 +08:00
2018-06-25 14:55:16 +08:00
# check for package files in src directory due to old make system
DetectBuildSystemConflict ( ${ LAMMPS_SOURCE_DIR } ${ ${PKG } _SOURCES} ${ ${PKG } _HEADERS} )
2017-07-15 06:49:05 +08:00
2018-05-11 21:51:59 +08:00
if ( PKG_ ${ PKG } )
2017-07-15 06:49:05 +08:00
# detects styles in package and adds them to global list
RegisterStyles ( ${ ${PKG } _SOURCES_DIR} )
2017-07-14 12:54:48 +08:00
list ( APPEND LIB_SOURCES ${ ${PKG } _SOURCES} )
2017-07-15 06:49:05 +08:00
include_directories ( ${ ${PKG } _SOURCES_DIR} )
2017-07-14 12:54:48 +08:00
endif ( )
2019-04-08 10:32:31 +08:00
RegisterPackages ( ${ ${PKG } _SOURCES_DIR} )
2017-07-14 12:54:48 +08:00
endforeach ( )
2017-07-14 13:27:55 +08:00
2018-12-17 05:53:51 +08:00
# packages that need defines set
foreach ( PKG MPIIO )
if ( PKG_ ${ PKG } )
add_definitions ( -DLMP_ ${ PKG } )
endif ( )
endforeach ( )
2018-06-25 14:55:16 +08:00
# dedicated check for entire contents of accelerator packages
foreach ( PKG ${ ACCEL_PACKAGES } )
set ( ${ PKG } _SOURCES_DIR ${ LAMMPS_SOURCE_DIR } / ${ PKG } )
2018-09-07 04:37:08 +08:00
file ( GLOB ${ PKG } _SOURCES ${ ${PKG } _SOURCES_DIR}/[^.]*.cpp )
file ( GLOB ${ PKG } _HEADERS ${ ${PKG } _SOURCES_DIR}/[^.]*.h )
2018-06-25 14:55:16 +08:00
# check for package files in src directory due to old make system
DetectBuildSystemConflict ( ${ LAMMPS_SOURCE_DIR } ${ ${PKG } _SOURCES} ${ ${PKG } _HEADERS} )
2019-04-08 10:32:31 +08:00
RegisterPackages ( ${ ${PKG } _SOURCES_DIR} )
2018-06-25 14:55:16 +08:00
endforeach ( )
2017-07-20 08:34:07 +08:00
##############################################
# add lib sources of (simple) enabled packages
############################################
2018-12-11 01:14:03 +08:00
foreach ( SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD
2017-08-28 02:23:30 +08:00
U S E R - Q M M M )
2018-05-11 21:51:59 +08:00
if ( PKG_ ${ SIMPLE_LIB } )
2017-08-22 01:12:36 +08:00
string ( REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}" )
string ( TOLOWER "${PKG_LIB}" PKG_LIB )
2018-09-07 20:40:06 +08:00
file ( GLOB_RECURSE ${ PKG_LIB } _SOURCES
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / $ { P K G _ L I B } / [ ^ . ] * . F
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / $ { P K G _ L I B } / [ ^ . ] * . c
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / $ { P K G _ L I B } / [ ^ . ] * . c p p )
2017-08-29 03:17:27 +08:00
add_library ( ${ PKG_LIB } STATIC ${ ${PKG_LIB } _SOURCES} )
2017-08-28 02:23:30 +08:00
list ( APPEND LAMMPS_LINK_LIBS ${ PKG_LIB } )
if ( PKG_LIB STREQUAL awpmd )
target_include_directories ( awpmd PUBLIC ${ LAMMPS_LIB_SOURCE_DIR } /awpmd/systems/interact ${ LAMMPS_LIB_SOURCE_DIR } /awpmd/ivutils/include )
elseif ( PKG_LIB STREQUAL h5md )
2018-12-17 05:53:51 +08:00
target_include_directories ( h5md PUBLIC ${ LAMMPS_LIB_SOURCE_DIR } /h5md/include ${ HDF5_INCLUDE_DIRS } )
2018-01-14 04:57:24 +08:00
elseif ( PKG_LIB STREQUAL colvars )
target_compile_options ( colvars PRIVATE -DLEPTON )
2018-01-15 01:01:19 +08:00
target_include_directories ( colvars PRIVATE ${ LAMMPS_LIB_SOURCE_DIR } /colvars/lepton/include )
target_include_directories ( colvars PUBLIC ${ LAMMPS_LIB_SOURCE_DIR } /colvars )
2017-08-28 02:23:30 +08:00
else ( )
target_include_directories ( ${ PKG_LIB } PUBLIC ${ LAMMPS_LIB_SOURCE_DIR } / ${ PKG_LIB } )
2017-08-27 15:04:32 +08:00
endif ( )
2017-07-17 01:07:36 +08:00
endif ( )
endforeach ( )
2017-07-16 22:22:19 +08:00
2018-05-11 21:51:59 +08:00
if ( PKG_USER-AWPMD )
2017-08-27 15:54:40 +08:00
target_link_libraries ( awpmd ${ LAPACK_LIBRARIES } )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-ATC )
2018-12-17 05:53:51 +08:00
if ( LAMMPS_SIZES STREQUAL BIGBIG )
message ( FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG" )
endif ( )
2017-08-27 15:54:40 +08:00
target_link_libraries ( atc ${ LAPACK_LIBRARIES } )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-H5MD )
2017-08-22 05:04:03 +08:00
find_package ( HDF5 REQUIRED )
target_link_libraries ( h5md ${ HDF5_LIBRARIES } )
2017-08-27 15:04:32 +08:00
target_include_directories ( h5md PRIVATE ${ HDF5_INCLUDE_DIRS } )
2018-12-17 05:53:51 +08:00
include_directories ( ${ HDF5_INCLUDE_DIRS } )
2017-08-22 05:04:03 +08:00
endif ( )
2017-09-09 10:20:47 +08:00
2017-07-16 22:22:19 +08:00
######################################################################
2017-07-15 06:49:05 +08:00
# packages which selectively include variants based on enabled styles
# e.g. accelerator packages
2017-07-16 22:22:19 +08:00
######################################################################
2018-07-31 00:56:56 +08:00
if ( PKG_CORESHELL )
set ( CORESHELL_SOURCES_DIR ${ LAMMPS_SOURCE_DIR } /CORESHELL )
set ( CORESHELL_SOURCES )
set_property ( GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}" )
# detects styles which have a CORESHELL version
RegisterStylesExt ( ${ CORESHELL_SOURCES_DIR } cs CORESHELL_SOURCES )
get_property ( CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES )
list ( APPEND LIB_SOURCES ${ CORESHELL_SOURCES } )
include_directories ( ${ CORESHELL_SOURCES_DIR } )
endif ( )
2018-07-31 02:04:31 +08:00
# Fix qeq/fire requires MANYBODY (i.e. COMB and COMB3) to be installed
if ( PKG_QEQ )
set ( QEQ_SOURCES_DIR ${ LAMMPS_SOURCE_DIR } /QEQ )
file ( GLOB QEQ_HEADERS ${ QEQ_SOURCES_DIR } /fix*.h )
file ( GLOB QEQ_SOURCES ${ QEQ_SOURCES_DIR } /fix*.cpp )
if ( NOT PKG_MANYBODY )
list ( REMOVE_ITEM QEQ_HEADERS ${ QEQ_SOURCES_DIR } /fix_qeq_fire.h )
list ( REMOVE_ITEM QEQ_SOURCES ${ QEQ_SOURCES_DIR } /fix_qeq_fire.cpp )
endif ( )
set_property ( GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}" )
foreach ( MY_HEADER ${ QEQ_HEADERS } )
AddStyleHeader ( ${ MY_HEADER } FIX )
endforeach ( )
get_property ( QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES )
list ( APPEND LIB_SOURCES ${ QEQ_SOURCES } )
include_directories ( ${ QEQ_SOURCES_DIR } )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-OMP )
2017-07-17 10:19:20 +08:00
set ( USER-OMP_SOURCES_DIR ${ LAMMPS_SOURCE_DIR } /USER-OMP )
set ( USER-OMP_SOURCES ${ USER-OMP_SOURCES_DIR } /thr_data.cpp
$ { U S E R - O M P _ S O U R C E S _ D I R } / t h r _ o m p . c p p
2018-09-06 04:04:35 +08:00
$ { U S E R - O M P _ S O U R C E S _ D I R } / f i x _ o m p . c p p
2017-07-17 10:19:20 +08:00
$ { U S E R - O M P _ S O U R C E S _ D I R } / f i x _ n h _ o m p . c p p
2018-08-28 10:11:15 +08:00
$ { U S E R - O M P _ S O U R C E S _ D I R } / f i x _ n h _ s p h e r e _ o m p . c p p
$ { U S E R - O M P _ S O U R C E S _ D I R } / d o m a i n _ o m p . c p p )
2018-08-28 09:23:47 +08:00
add_definitions ( -DLMP_USER_OMP )
2017-07-17 10:19:20 +08:00
set_property ( GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}" )
2017-07-15 11:07:53 +08:00
# detects styles which have USER-OMP version
2017-07-17 10:19:20 +08:00
RegisterStylesExt ( ${ USER-OMP_SOURCES_DIR } omp OMP_SOURCES )
2019-04-01 05:17:07 +08:00
RegisterFixStyle ( ${ USER-OMP_SOURCES_DIR } /fix_omp.h )
2018-07-31 00:32:28 +08:00
2017-07-17 10:19:20 +08:00
get_property ( USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES )
2017-07-15 11:07:53 +08:00
2018-07-31 01:09:16 +08:00
# manually add package dependent source files from USER-OMP that do not provide styles
2018-08-02 18:38:25 +08:00
if ( PKG_ASPHERE )
list ( APPEND USER-OMP_SOURCES ${ USER-OMP_SOURCES_DIR } /fix_nh_asphere_omp.cpp )
endif ( )
2018-07-31 00:32:28 +08:00
if ( PKG_RIGID )
list ( APPEND USER-OMP_SOURCES ${ USER-OMP_SOURCES_DIR } /fix_rigid_nh_omp.cpp )
endif ( )
2018-07-31 01:09:16 +08:00
if ( PKG_USER-REAXC )
list ( APPEND USER-OMP_SOURCES ${ USER-OMP_SOURCES_DIR } /reaxc_bond_orders_omp.cpp
$ { U S E R - O M P _ S O U R C E S _ D I R } / r e a x c _ h y d r o g e n _ b o n d s _ o m p . c p p
$ { U S E R - O M P _ S O U R C E S _ D I R } / r e a x c _ n o n b o n d e d _ o m p . c p p
$ { U S E R - O M P _ S O U R C E S _ D I R } / r e a x c _ b o n d s _ o m p . c p p
$ { U S E R - O M P _ S O U R C E S _ D I R } / r e a x c _ i n i t _ m d _ o m p . c p p
$ { U S E R - O M P _ S O U R C E S _ D I R } / r e a x c _ t o r s i o n _ a n g l e s _ o m p . c p p
$ { U S E R - O M P _ S O U R C E S _ D I R } / r e a x c _ f o r c e s _ o m p . c p p
$ { U S E R - O M P _ S O U R C E S _ D I R } / r e a x c _ m u l t i _ b o d y _ o m p . c p p
$ { U S E R - O M P _ S O U R C E S _ D I R } / r e a x c _ v a l e n c e _ a n g l e s _ o m p . c p p )
endif ( )
2017-07-17 10:19:20 +08:00
list ( APPEND LIB_SOURCES ${ USER-OMP_SOURCES } )
include_directories ( ${ USER-OMP_SOURCES_DIR } )
2017-07-15 11:07:53 +08:00
endif ( )
2018-12-17 05:53:51 +08:00
# Fix rigid/meso requires RIGID to be installed
if ( PKG_USER-SDPD )
set ( USER-SDPD_SOURCES_DIR ${ LAMMPS_SOURCE_DIR } /USER-SDPD )
get_property ( hlist GLOBAL PROPERTY FIX )
if ( NOT PKG_RIGID )
list ( REMOVE_ITEM hlist ${ USER-SDPD_SOURCES_DIR } /fix_rigid_meso.h )
list ( REMOVE_ITEM LIB_SOURCES ${ USER-SDPD_SOURCES_DIR } /fix_rigid_meso.cpp )
endif ( )
set_property ( GLOBAL PROPERTY FIX "${hlist}" )
include_directories ( ${ USER-SDPD_SOURCES_DIR } )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_KOKKOS )
2017-07-20 08:34:07 +08:00
set ( LAMMPS_LIB_KOKKOS_SRC_DIR ${ LAMMPS_LIB_SOURCE_DIR } /kokkos )
set ( LAMMPS_LIB_KOKKOS_BIN_DIR ${ LAMMPS_LIB_BINARY_DIR } /kokkos )
add_definitions ( -DLMP_KOKKOS )
add_subdirectory ( ${ LAMMPS_LIB_KOKKOS_SRC_DIR } ${ LAMMPS_LIB_KOKKOS_BIN_DIR } )
set ( Kokkos_INCLUDE_DIRS ${ LAMMPS_LIB_KOKKOS_SRC_DIR } /core/src
$ { L A M M P S _ L I B _ K O K K O S _ S R C _ D I R } / c o n t a i n e r s / s r c
$ { L A M M P S _ L I B _ K O K K O S _ S R C _ D I R } / a l g o r i t h m s / s r c
$ { L A M M P S _ L I B _ K O K K O S _ B I N _ D I R } )
include_directories ( ${ Kokkos_INCLUDE_DIRS } )
list ( APPEND LAMMPS_LINK_LIBS kokkos )
set ( KOKKOS_PKG_SOURCES_DIR ${ LAMMPS_SOURCE_DIR } /KOKKOS )
set ( KOKKOS_PKG_SOURCES ${ KOKKOS_PKG_SOURCES_DIR } /kokkos.cpp
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / a t o m _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / a t o m _ v e c _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / c o m m _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / c o m m _ t i l e d _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / n e i g h b o r _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / n e i g h _ l i s t _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / n e i g h _ b o n d _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / f i x _ n h _ k o k k o s . c p p
2017-12-20 16:13:08 +08:00
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / n b i n _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / n p a i r _ k o k k o s . c p p
2017-07-20 08:34:07 +08:00
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / d o m a i n _ k o k k o s . c p p
$ { K O K K O S _ P K G _ S O U R C E S _ D I R } / m o d i f y _ k o k k o s . c p p )
2018-08-17 06:13:24 +08:00
if ( PKG_KSPACE )
list ( APPEND KOKKOS_PKG_SOURCES ${ KOKKOS_PKG_SOURCES_DIR } /gridcomm_kokkos.cpp )
endif ( )
2017-07-20 08:34:07 +08:00
set_property ( GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}" )
# detects styles which have KOKKOS version
RegisterStylesExt ( ${ KOKKOS_PKG_SOURCES_DIR } kokkos KOKKOS_PKG_SOURCES )
2017-12-20 16:13:08 +08:00
# register kokkos-only styles
2017-12-20 17:51:46 +08:00
RegisterNBinStyle ( ${ KOKKOS_PKG_SOURCES_DIR } /nbin_kokkos.h )
RegisterNPairStyle ( ${ KOKKOS_PKG_SOURCES_DIR } /npair_kokkos.h )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-DPD )
2017-12-20 17:51:46 +08:00
get_property ( KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES )
list ( APPEND KOKKOS_PKG_SOURCES ${ KOKKOS_PKG_SOURCES_DIR } /npair_ssa_kokkos.cpp )
RegisterNPairStyle ( ${ KOKKOS_PKG_SOURCES_DIR } /npair_ssa_kokkos.h )
set_property ( GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}" )
endif ( )
2017-12-20 16:13:08 +08:00
2017-07-20 08:34:07 +08:00
get_property ( KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES )
list ( APPEND LIB_SOURCES ${ KOKKOS_PKG_SOURCES } )
include_directories ( ${ KOKKOS_PKG_SOURCES_DIR } )
2017-07-16 04:33:36 +08:00
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_OPT )
2017-07-17 08:52:38 +08:00
set ( OPT_SOURCES_DIR ${ LAMMPS_SOURCE_DIR } /OPT )
set ( OPT_SOURCES )
set_property ( GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}" )
# detects styles which have OPT version
RegisterStylesExt ( ${ OPT_SOURCES_DIR } opt OPT_SOURCES )
get_property ( OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES )
list ( APPEND LIB_SOURCES ${ OPT_SOURCES } )
include_directories ( ${ OPT_SOURCES_DIR } )
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_USER-INTEL )
2019-06-06 01:13:48 +08:00
include ( CheckIncludeFile )
check_include_file ( immintrin.h FOUND_IMMINTRIN )
if ( NOT FOUND_IMMINTRIN )
message ( FATAL_ERROR "immintrin.h header not found, Intel package won't work without it" )
endif ( )
2019-04-01 05:17:07 +08:00
add_definitions ( -DLMP_USER_INTEL )
set ( INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)" )
set ( INTEL_ARCH_VALUES cpu knl )
set_property ( CACHE INTEL_ARCH PROPERTY STRINGS ${ INTEL_ARCH_VALUES } )
validate_option ( INTEL_ARCH INTEL_ARCH_VALUES )
string ( TOUPPER ${ INTEL_ARCH } INTEL_ARCH )
find_package ( Threads QUIET )
if ( Threads_FOUND )
set ( INTEL_LRT_MODE "threads" CACHE STRING "Long-range threads mode (none, threads, or c++11)" )
else ( )
set ( INTEL_LRT_MODE "none" CACHE STRING "Long-range threads mode (none, threads, or c++11)" )
endif ( )
set ( INTEL_LRT_VALUES none threads c++11 )
set_property ( CACHE INTEL_LRT_MODE PROPERTY STRINGS ${ INTEL_LRT_VALUES } )
validate_option ( INTEL_LRT_MODE INTEL_LRT_VALUES )
string ( TOUPPER ${ INTEL_LRT_MODE } INTEL_LRT_MODE )
if ( INTEL_LRT_MODE STREQUAL "THREADS" )
if ( Threads_FOUND )
add_definitions ( -DLMP_INTEL_USELRT )
list ( APPEND LAMMPS_LINK_LIBS ${ CMAKE_THREAD_LIBS_INIT } )
else ( )
message ( FATAL_ERROR "Must have working threads library for Long-range thread support" )
2018-08-14 07:51:06 +08:00
endif ( )
2019-04-01 05:17:07 +08:00
endif ( )
if ( INTEL_LRT_MODE STREQUAL "C++11" )
add_definitions ( -DLMP_INTEL_USERLRT -DLMP_INTEL_LRT11 )
endif ( )
2018-08-14 07:51:06 +08:00
2019-04-01 05:17:07 +08:00
if ( CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
2018-08-14 07:51:06 +08:00
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16 )
2019-04-01 05:17:07 +08:00
message ( FATAL_ERROR "USER-INTEL needs at least a 2016 Intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}" )
2018-05-12 01:53:34 +08:00
endif ( )
2019-04-01 05:17:07 +08:00
else ( )
message ( WARNING "USER-INTEL gives best performance with Intel compilers" )
endif ( )
2018-08-14 07:51:06 +08:00
2019-04-01 05:17:07 +08:00
find_package ( TBB QUIET )
if ( TBB_FOUND )
list ( APPEND LAMMPS_LINK_LIBS ${ TBB_MALLOC_LIBRARIES } )
else ( )
add_definitions ( -DLMP_INTEL_NO_TBB )
2019-04-03 03:06:56 +08:00
if ( CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
message ( WARNING "USER-INTEL with Intel compilers should use TBB malloc libraries" )
endif ( )
2019-04-01 05:17:07 +08:00
endif ( )
2018-08-14 07:51:06 +08:00
2019-04-01 05:17:07 +08:00
find_package ( MKL QUIET )
if ( MKL_FOUND )
add_definitions ( -DLMP_USE_MKL_RNG )
list ( APPEND LAMMPS_LINK_LIBS ${ MKL_LIBRARIES } )
2019-04-03 03:06:56 +08:00
else ( )
message ( STATUS "Pair style dpd/intel will be faster with MKL libraries" )
2019-04-01 05:17:07 +08:00
endif ( )
2018-08-14 07:51:06 +08:00
2019-04-02 05:46:25 +08:00
if ( ( NOT ${ CMAKE_SYSTEM_NAME } STREQUAL "Windows" ) AND ( NOT ${ LAMMPS_MEMALIGN } STREQUAL "64" ) AND ( NOT ${ LAMMPS_MEMALIGN } STREQUAL "128" ) AND ( NOT ${ LAMMPS_MEMALIGN } STREQUAL "256" ) )
2019-04-03 03:06:56 +08:00
message ( FATAL_ERROR "USER-INTEL only supports memory alignment of 64, 128 or 256 on this platform" )
2019-04-01 05:17:07 +08:00
endif ( )
if ( INTEL_ARCH STREQUAL "KNL" )
if ( NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
message ( FATAL_ERROR "Must use Intel compiler with USER-INTEL for KNL architecture" )
endif ( )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload" )
set ( MIC_OPTIONS "-qoffload-option,mic,compiler,\" -fp-model fast=2 -mGLOB_default_function_attrs=\\\ "gather_scatter_loop_unroll=4\\\" \"")
add_compile_options ( -xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${ MIC_OPTIONS } )
add_definitions ( -DLMP_INTEL_OFFLOAD )
else ( )
if ( CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
2018-05-12 07:48:31 +08:00
if ( CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4 )
2018-05-12 05:33:18 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xCOMMON-AVX512" )
else ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost" )
2018-05-12 05:27:24 +08:00
endif ( )
2018-05-12 05:33:18 +08:00
include ( CheckCXXCompilerFlag )
2018-08-14 07:51:06 +08:00
foreach ( _FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict )
2018-05-12 05:33:18 +08:00
check_cxx_compiler_flag ( "${__FLAG}" COMPILER_SUPPORTS ${ _FLAG } )
if ( COMPILER_SUPPORTS ${ _FLAG } )
2018-08-14 07:51:06 +08:00
add_compile_options ( ${ _FLAG } )
2018-05-12 05:33:18 +08:00
endif ( )
endforeach ( )
2019-04-01 05:17:07 +08:00
else ( )
add_compile_options ( -O3 -ffast-math )
2018-05-12 05:33:18 +08:00
endif ( )
2019-04-01 05:17:07 +08:00
endif ( )
2018-08-14 07:51:06 +08:00
2019-04-01 05:17:07 +08:00
# collect sources
set ( USER-INTEL_SOURCES_DIR ${ LAMMPS_SOURCE_DIR } /USER-INTEL )
set ( USER-INTEL_SOURCES ${ USER-INTEL_SOURCES_DIR } /fix_intel.cpp
$ { U S E R - I N T E L _ S O U R C E S _ D I R } / f i x _ n h _ i n t e l . c p p
$ { U S E R - I N T E L _ S O U R C E S _ D I R } / i n t e l _ b u f f e r s . c p p
$ { U S E R - I N T E L _ S O U R C E S _ D I R } / n b i n _ i n t e l . c p p
2019-05-01 20:20:24 +08:00
$ { U S E R - I N T E L _ S O U R C E S _ D I R } / n p a i r _ i n t e l . c p p )
2017-07-17 12:52:59 +08:00
2019-04-01 05:17:07 +08:00
set_property ( GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}" )
2017-07-17 12:52:59 +08:00
2019-04-01 05:17:07 +08:00
# detect styles which have a USER-INTEL version
RegisterStylesExt ( ${ USER-INTEL_SOURCES_DIR } intel USER-INTEL_SOURCES )
RegisterNBinStyle ( ${ USER-INTEL_SOURCES_DIR } /nbin_intel.h )
RegisterNPairStyle ( ${ USER-INTEL_SOURCES_DIR } /npair_intel.h )
RegisterFixStyle ( ${ USER-INTEL_SOURCES_DIR } /fix_intel.h )
2017-07-17 12:52:59 +08:00
2019-04-01 05:17:07 +08:00
get_property ( USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES )
2019-05-01 20:20:24 +08:00
if ( PKG_KSPACE )
list ( APPEND USER-INTEL_SOURCES ${ USER-INTEL_SOURCES_DIR } /verlet_lrt_intel.cpp )
RegisterIntegrateStyle ( ${ USER-INTEL_SOURCES_DIR } /verlet_lrt_intel.h )
endif ( )
2017-07-17 12:52:59 +08:00
2019-04-01 05:17:07 +08:00
list ( APPEND LIB_SOURCES ${ USER-INTEL_SOURCES } )
include_directories ( ${ USER-INTEL_SOURCES_DIR } )
2017-07-17 12:52:59 +08:00
endif ( )
2017-07-15 06:49:05 +08:00
2018-05-11 21:51:59 +08:00
if ( PKG_GPU )
2018-11-05 23:24:02 +08:00
if ( CMAKE_VERSION VERSION_LESS "3.1" )
2018-06-09 06:18:02 +08:00
message ( FATAL_ERROR "For the GPU package you need at least cmake-3.1" )
endif ( )
2017-09-09 10:20:47 +08:00
set ( GPU_SOURCES_DIR ${ LAMMPS_SOURCE_DIR } /GPU )
set ( GPU_SOURCES ${ GPU_SOURCES_DIR } /gpu_extra.h
$ { G P U _ S O U R C E S _ D I R } / f i x _ g p u . h
$ { G P U _ S O U R C E S _ D I R } / f i x _ g p u . c p p )
2017-08-28 04:58:19 +08:00
2018-08-15 05:44:25 +08:00
set ( GPU_API "opencl" CACHE STRING "API used by GPU package" )
2018-08-15 22:50:51 +08:00
set ( GPU_API_VALUES opencl cuda )
set_property ( CACHE GPU_API PROPERTY STRINGS ${ GPU_API_VALUES } )
validate_option ( GPU_API GPU_API_VALUES )
string ( TOUPPER ${ GPU_API } GPU_API )
2017-08-29 13:04:39 +08:00
2018-08-15 05:44:25 +08:00
set ( GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision" )
2018-08-15 22:50:51 +08:00
set ( GPU_PREC_VALUES double mixed single )
set_property ( CACHE GPU_PREC PROPERTY STRINGS ${ GPU_PREC_VALUES } )
validate_option ( GPU_PREC GPU_PREC_VALUES )
string ( TOUPPER ${ GPU_PREC } GPU_PREC )
2018-08-15 05:44:25 +08:00
2018-08-15 22:50:51 +08:00
if ( GPU_PREC STREQUAL "DOUBLE" )
2018-08-15 05:44:25 +08:00
set ( GPU_PREC_SETTING "DOUBLE_DOUBLE" )
2018-08-15 22:50:51 +08:00
elseif ( GPU_PREC STREQUAL "MIXED" )
2018-08-15 05:44:25 +08:00
set ( GPU_PREC_SETTING "SINGLE_DOUBLE" )
2018-08-15 22:50:51 +08:00
elseif ( GPU_PREC STREQUAL "SINGLE" )
2018-08-15 05:44:25 +08:00
set ( GPU_PREC_SETTING "SINGLE_SINGLE" )
endif ( )
2017-07-17 13:03:11 +08:00
2018-09-07 04:37:08 +08:00
file ( GLOB GPU_LIB_SOURCES ${ LAMMPS_LIB_SOURCE_DIR } /gpu/[^.]*.cpp )
2017-07-19 06:01:35 +08:00
file ( MAKE_DIRECTORY ${ LAMMPS_LIB_BINARY_DIR } /gpu )
2017-08-29 13:04:39 +08:00
2017-09-09 10:20:47 +08:00
if ( GPU_API STREQUAL "CUDA" )
find_package ( CUDA REQUIRED )
find_program ( BIN2C bin2c )
if ( NOT BIN2C )
2018-12-17 05:53:51 +08:00
message ( FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it." )
2017-09-09 10:20:47 +08:00
endif ( )
option ( CUDPP_OPT "Enable CUDPP_OPT" ON )
2019-03-29 05:15:05 +08:00
option ( CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF )
if ( CUDA_MPS_SUPPORT )
set ( GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY" )
endif ( )
2017-09-09 10:20:47 +08:00
2018-12-17 05:53:51 +08:00
set ( GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)" )
2017-09-09 10:20:47 +08:00
2018-09-07 04:37:08 +08:00
file ( GLOB GPU_LIB_CU ${ LAMMPS_LIB_SOURCE_DIR } /gpu/[^.]*.cu ${ CMAKE_CURRENT_SOURCE_DIR } /gpu/[^.]*.cu )
2017-09-09 10:20:47 +08:00
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 )
2018-09-07 04:37:08 +08:00
file ( GLOB GPU_LIB_CUDPP_SOURCES ${ LAMMPS_LIB_SOURCE_DIR } /gpu/cudpp_mini/[^.]*.cpp )
file ( GLOB GPU_LIB_CUDPP_CU ${ LAMMPS_LIB_SOURCE_DIR } /gpu/cudpp_mini/[^.]*.cu )
2017-09-09 10:20:47 +08:00
endif ( )
2018-12-17 05:53:51 +08:00
# build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
# --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
set ( GPU_CUDA_GENCODE "-arch=${GPU_ARCH} " )
# Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
if ( ( CUDA_VERSION VERSION_GREATER "3.1" ) AND ( CUDA_VERSION VERSION_LESS "9.0" ) )
string ( APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] " )
endif ( )
# Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
if ( CUDA_VERSION VERSION_GREATER "4.9" )
string ( APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] " )
endif ( )
# Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
if ( CUDA_VERSION VERSION_GREATER "5.9" )
string ( APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] " )
endif ( )
# Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
if ( CUDA_VERSION VERSION_GREATER "7.9" )
string ( APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] " )
endif ( )
# Volta (GPU Arch 7.0) is supported by CUDA 9 and later
if ( CUDA_VERSION VERSION_GREATER "8.9" )
string ( APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] " )
endif ( )
# Turing (GPU Arch 7.5) is supported by CUDA 10 and later
if ( CUDA_VERSION VERSION_GREATER "9.9" )
string ( APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] " )
endif ( )
cuda_compile_fatbin ( GPU_GEN_OBJS ${ GPU_LIB_CU } OPTIONS
- D U N I X - O 3 - - u s e _ f a s t _ m a t h - W n o - d e p r e c a t e d - g p u - t a r g e t s - D N V _ K E R N E L - D U C L _ C U D A D R $ { G P U _ C U D A _ G E N C O D E } - D _ $ { G P U _ P R E C _ S E T T I N G } )
2017-09-09 10:20:47 +08:00
2018-12-17 05:53:51 +08:00
cuda_compile ( GPU_OBJS ${ GPU_LIB_CUDPP_CU } OPTIONS ${ CUDA_REQUEST_PIC }
- D U N I X - O 3 - - u s e _ f a s t _ m a t h - W n o - d e p r e c a t e d - g p u - t a r g e t s - D U C L _ C U D A D R $ { G P U _ C U D A _ G E N C O D E } - D _ $ { G P U _ P R E C _ S E T T I N G } )
2017-09-09 10:20:47 +08:00
foreach ( CU_OBJ ${ GPU_GEN_OBJS } )
get_filename_component ( CU_NAME ${ CU_OBJ } NAME_WE )
string ( REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}" )
add_custom_command ( OUTPUT ${ LAMMPS_LIB_BINARY_DIR } /gpu/ ${ CU_NAME } _cubin.h
C O M M A N D $ { B I N 2 C } - c - n $ { C U _ N A M E } $ { C U _ O B J } > $ { L A M M P S _ L I B _ B I N A R Y _ D I R } / g p u / $ { C U _ N A M E } _ c u b i n . h
D E P E N D S $ { C U _ O B J }
C O M M E N T " G e n e r a t i n g $ { C U _ N A M E } _ c u b i n . h " )
list ( APPEND GPU_LIB_SOURCES ${ LAMMPS_LIB_BINARY_DIR } /gpu/ ${ CU_NAME } _cubin.h )
endforeach ( )
set_directory_properties ( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h" )
add_library ( gpu STATIC ${ GPU_LIB_SOURCES } ${ GPU_LIB_CUDPP_SOURCES } ${ GPU_OBJS } )
target_link_libraries ( gpu ${ CUDA_LIBRARIES } ${ CUDA_CUDA_LIBRARY } )
target_include_directories ( gpu PRIVATE ${ LAMMPS_LIB_BINARY_DIR } /gpu ${ CUDA_INCLUDE_DIRS } )
2019-03-29 05:15:05 +08:00
target_compile_definitions ( gpu PRIVATE -D_ ${ GPU_PREC_SETTING } -DMPI_GERYON -DUCL_NO_EXIT ${ GPU_CUDA_MPS_FLAGS } )
2017-09-09 10:20:47 +08:00
if ( CUDPP_OPT )
target_include_directories ( gpu PRIVATE ${ LAMMPS_LIB_SOURCE_DIR } /gpu/cudpp_mini )
target_compile_definitions ( gpu PRIVATE -DUSE_CUDPP )
endif ( )
list ( APPEND LAMMPS_LINK_LIBS gpu )
add_executable ( nvc_get_devices ${ LAMMPS_LIB_SOURCE_DIR } /gpu/geryon/ucl_get_devices.cpp )
target_compile_definitions ( nvc_get_devices PRIVATE -DUCL_CUDADR )
target_link_libraries ( nvc_get_devices PRIVATE ${ CUDA_LIBRARIES } ${ CUDA_CUDA_LIBRARY } )
target_include_directories ( nvc_get_devices PRIVATE ${ CUDA_INCLUDE_DIRS } )
2018-08-15 22:50:51 +08:00
elseif ( GPU_API STREQUAL "OPENCL" )
2017-09-09 10:20:47 +08:00
find_package ( OpenCL REQUIRED )
2018-08-15 05:44:25 +08:00
set ( OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning" )
2018-08-15 22:50:51 +08:00
set ( OCL_TUNE_VALUES intel fermi kepler cypress generic )
set_property ( CACHE OCL_TUNE PROPERTY STRINGS ${ OCL_TUNE_VALUES } )
validate_option ( OCL_TUNE OCL_TUNE_VALUES )
string ( TOUPPER ${ OCL_TUNE } OCL_TUNE )
2017-09-09 20:51:24 +08:00
include ( OpenCLUtils )
set ( OCL_COMMON_HEADERS ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_preprocessor.h ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_aux_fun1.h )
2018-09-07 04:37:08 +08:00
file ( GLOB GPU_LIB_CU ${ LAMMPS_LIB_SOURCE_DIR } /gpu/[^.]*.cu )
2019-04-30 13:37:27 +08:00
list ( REMOVE_ITEM GPU_LIB_CU
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / g p u / l a l _ g a y b e r n e . c u
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / g p u / l a l _ g a y b e r n e _ l j . c u
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / g p u / l a l _ r e _ s q u a r e d . c u
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / g p u / l a l _ r e _ s q u a r e d _ l j . c u
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / g p u / l a l _ t e r s o f f . c u
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / g p u / l a l _ t e r s o f f _ z b l . c u
$ { L A M M P S _ L I B _ S O U R C E _ D I R } / g p u / l a l _ t e r s o f f _ m o d . c u
)
2017-09-09 20:51:24 +08:00
foreach ( GPU_KERNEL ${ GPU_LIB_CU } )
get_filename_component ( basename ${ GPU_KERNEL } NAME_WE )
string ( SUBSTRING ${ basename } 4 -1 KERNEL_NAME )
GenerateOpenCLHeader ( ${ KERNEL_NAME } ${ CMAKE_CURRENT_BINARY_DIR } /gpu/ ${ KERNEL_NAME } _cl.h ${ OCL_COMMON_HEADERS } ${ GPU_KERNEL } )
list ( APPEND GPU_LIB_SOURCES ${ CMAKE_CURRENT_BINARY_DIR } /gpu/ ${ KERNEL_NAME } _cl.h )
endforeach ( )
GenerateOpenCLHeader ( gayberne ${ CMAKE_CURRENT_BINARY_DIR } /gpu/gayberne_cl.h ${ OCL_COMMON_HEADERS } ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_ellipsoid_extra.h ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_gayberne.cu )
GenerateOpenCLHeader ( gayberne_lj ${ CMAKE_CURRENT_BINARY_DIR } /gpu/gayberne_lj_cl.h ${ OCL_COMMON_HEADERS } ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_ellipsoid_extra.h ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_gayberne_lj.cu )
2019-04-30 13:37:27 +08:00
GenerateOpenCLHeader ( re_squared ${ CMAKE_CURRENT_BINARY_DIR } /gpu/re_squared_cl.h ${ OCL_COMMON_HEADERS } ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_ellipsoid_extra.h ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_re_squared.cu )
GenerateOpenCLHeader ( re_squared_lj ${ CMAKE_CURRENT_BINARY_DIR } /gpu/re_squared_lj_cl.h ${ OCL_COMMON_HEADERS } ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_ellipsoid_extra.h ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_re_squared_lj.cu )
GenerateOpenCLHeader ( tersoff ${ CMAKE_CURRENT_BINARY_DIR } /gpu/tersoff_cl.h ${ OCL_COMMON_HEADERS } ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_tersoff_extra.h ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_tersoff.cu )
GenerateOpenCLHeader ( tersoff_zbl ${ CMAKE_CURRENT_BINARY_DIR } /gpu/tersoff_zbl_cl.h ${ OCL_COMMON_HEADERS } ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_tersoff_zbl_extra.h ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_tersoff_zbl.cu )
GenerateOpenCLHeader ( tersoff_mod ${ CMAKE_CURRENT_BINARY_DIR } /gpu/tersoff_mod_cl.h ${ OCL_COMMON_HEADERS } ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_tersoff_mod_extra.h ${ LAMMPS_LIB_SOURCE_DIR } /gpu/lal_tersoff_mod.cu )
list ( APPEND GPU_LIB_SOURCES
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g p u / g a y b e r n e _ c l . h
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g p u / g a y b e r n e _ l j _ c l . h
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g p u / r e _ s q u a r e d _ c l . h
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g p u / r e _ s q u a r e d _ l j _ c l . h
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g p u / t e r s o f f _ c l . h
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g p u / t e r s o f f _ z b l _ c l . h
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g p u / t e r s o f f _ m o d _ c l . h
)
2017-09-09 20:51:24 +08:00
add_library ( gpu STATIC ${ GPU_LIB_SOURCES } )
target_link_libraries ( gpu ${ OpenCL_LIBRARIES } )
target_include_directories ( gpu PRIVATE ${ CMAKE_CURRENT_BINARY_DIR } /gpu ${ OpenCL_INCLUDE_DIRS } )
2018-08-15 22:50:51 +08:00
target_compile_definitions ( gpu PRIVATE -D_ ${ GPU_PREC_SETTING } -D ${ OCL_TUNE } _OCL -DMPI_GERYON -DUCL_NO_EXIT )
2017-09-09 20:51:24 +08:00
target_compile_definitions ( gpu PRIVATE -DUSE_OPENCL )
list ( APPEND LAMMPS_LINK_LIBS gpu )
add_executable ( ocl_get_devices ${ LAMMPS_LIB_SOURCE_DIR } /gpu/geryon/ucl_get_devices.cpp )
target_compile_definitions ( ocl_get_devices PRIVATE -DUCL_OPENCL )
target_link_libraries ( ocl_get_devices PRIVATE ${ OpenCL_LIBRARIES } )
target_include_directories ( ocl_get_devices PRIVATE ${ OpenCL_INCLUDE_DIRS } )
2017-09-09 10:20:47 +08:00
endif ( )
2017-08-28 04:58:19 +08:00
# GPU package
2017-08-29 13:04:39 +08:00
FindStyleHeaders ( ${ GPU_SOURCES_DIR } FIX_CLASS fix_ FIX )
2017-07-17 13:03:11 +08:00
set_property ( GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}" )
# detects styles which have GPU version
2017-08-29 13:04:39 +08:00
RegisterStylesExt ( ${ GPU_SOURCES_DIR } gpu GPU_SOURCES )
2017-07-17 13:03:11 +08:00
get_property ( GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES )
2017-08-28 04:58:19 +08:00
list ( APPEND LIB_SOURCES ${ GPU_SOURCES } )
2017-08-29 13:04:39 +08:00
include_directories ( ${ GPU_SOURCES_DIR } )
2017-07-17 13:03:11 +08:00
endif ( )
2017-07-15 06:49:05 +08:00
######################################################
# Generate style headers based on global list of
2017-09-09 10:20:47 +08:00
# styles registered during package selection
2019-04-08 18:40:39 +08:00
# Generate packages headers from all packages
2017-07-15 06:49:05 +08:00
######################################################
set ( LAMMPS_STYLE_HEADERS_DIR ${ CMAKE_CURRENT_BINARY_DIR } /styles )
GenerateStyleHeaders ( ${ LAMMPS_STYLE_HEADERS_DIR } )
2019-04-08 10:32:31 +08:00
GeneratePackagesHeaders ( ${ LAMMPS_STYLE_HEADERS_DIR } )
2017-07-15 06:49:05 +08:00
include_directories ( ${ LAMMPS_STYLE_HEADERS_DIR } )
2018-06-22 07:08:09 +08:00
######################################
# Generate lmpinstalledpkgs.h
######################################
2018-06-22 19:05:09 +08:00
set ( temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n" )
set ( temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] = {\n" )
2019-04-08 10:32:31 +08:00
set ( temp_PKG_LIST ${ DEFAULT_PACKAGES } ${ ACCEL_PACKAGES } )
2018-08-25 05:27:15 +08:00
list ( SORT temp_PKG_LIST )
foreach ( PKG ${ temp_PKG_LIST } )
2018-06-22 07:08:09 +08:00
if ( PKG_ ${ PKG } )
set ( temp "${temp} \" ${ PKG } \",\n")
endif ( )
endforeach ( )
2018-06-22 19:05:09 +08:00
set ( temp "${temp} NULL\n};\n#endif\n\n" )
2018-06-22 07:08:09 +08:00
message ( STATUS "Generating lmpinstalledpkgs.h..." )
file ( WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h.tmp" "${temp}" )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h" )
2019-03-05 21:35:53 +08:00
######################################
# Generate lmpgitversion.h
######################################
2019-03-23 22:01:41 +08:00
add_custom_target ( gitversion COMMAND ${ CMAKE_COMMAND }
- D C M A K E _ C U R R E N T _ S O U R C E _ D I R = " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
- D G I T _ E X E C U T A B L E = " $ { G I T _ E X E C U T A B L E } "
- D G I T _ F O U N D = " $ { G I T _ F O U N D } "
- D L A M M P S _ S T Y L E _ H E A D E R S _ D I R = " $ { L A M M P S _ S T Y L E _ H E A D E R S _ D I R } "
- P $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / M o d u l e s / g e n e r a t e _ l m p g i t v e r s i o n . c m a k e )
set_property ( DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${ LAMMPS_STYLE_HEADERS_DIR } /gitversion.h )
list ( APPEND LAMMPS_DEPS gitversion )
2019-03-05 21:35:53 +08:00
2017-07-20 08:34:07 +08:00
###########################################
# Actually add executable and lib to build
############################################
2018-06-19 06:11:31 +08:00
get_property ( LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES )
list ( FIND LANGUAGES "Fortran" _index )
if ( ${ _index } GREATER -1 )
list ( APPEND LAMMPS_LINK_LIBS ${ CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES } )
endif ( )
2018-05-10 12:24:22 +08:00
list ( REMOVE_DUPLICATES LAMMPS_LINK_LIBS )
2018-06-23 01:06:12 +08:00
if ( BUILD_LIB )
add_library ( lammps ${ LIB_SOURCES } )
target_link_libraries ( lammps ${ LAMMPS_LINK_LIBS } )
if ( LAMMPS_DEPS )
add_dependencies ( lammps ${ LAMMPS_DEPS } )
endif ( )
2018-08-30 01:31:28 +08:00
set_target_properties ( lammps PROPERTIES OUTPUT_NAME lammps ${ LAMMPS_LIB_SUFFIX } )
2018-08-30 00:58:09 +08:00
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 )
2018-08-30 01:31:28 +08:00
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 )
2018-12-29 08:57:13 +08:00
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /FindLAMMPS ${ LAMMPS_LIB_SUFFIX } .cmake DESTINATION ${ CMAKE_INSTALL_DATADIR } /cmake/Modules )
2018-06-23 01:06:12 +08:00
else ( )
list ( APPEND LMP_SOURCES ${ LIB_SOURCES } )
2017-07-15 08:33:27 +08:00
endif ( )
2017-07-13 05:54:44 +08:00
2018-06-23 01:11:09 +08:00
if ( BUILD_EXE )
add_executable ( lmp ${ LMP_SOURCES } )
if ( BUILD_LIB )
target_link_libraries ( lmp lammps )
else ( )
target_link_libraries ( lmp ${ LAMMPS_LINK_LIBS } )
if ( LAMMPS_DEPS )
add_dependencies ( lmp ${ LAMMPS_DEPS } )
endif ( )
2018-06-23 01:06:12 +08:00
endif ( )
2018-11-05 23:24:02 +08:00
2018-09-05 00:12:49 +08:00
set_target_properties ( lmp PROPERTIES OUTPUT_NAME ${ LAMMPS_BINARY } )
2018-06-23 01:11:09 +08:00
install ( TARGETS lmp DESTINATION ${ CMAKE_INSTALL_BINDIR } )
2018-09-05 00:12:49 +08:00
install ( FILES ${ LAMMPS_DOC_DIR } /lammps.1 DESTINATION ${ CMAKE_INSTALL_MANDIR } /man1 RENAME ${ LAMMPS_BINARY } .1 )
2018-06-23 01:11:09 +08:00
if ( ENABLE_TESTING )
2018-09-05 00:12:49 +08:00
add_test ( ShowHelp ${ LAMMPS_BINARY } -help )
2018-06-23 01:11:09 +08:00
endif ( )
2019-04-06 11:56:23 +08:00
enable_language ( C )
get_filename_component ( MSI2LMP_SOURCE_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /../tools/msi2lmp/src ABSOLUTE )
file ( GLOB MSI2LMP_SOURCES ${ MSI2LMP_SOURCE_DIR } /[^.]*.c )
add_executable ( msi2lmp ${ MSI2LMP_SOURCES } )
target_link_libraries ( msi2lmp m )
install ( TARGETS msi2lmp DESTINATION ${ CMAKE_INSTALL_BINDIR } )
2019-04-07 11:41:48 +08:00
install ( FILES ${ LAMMPS_DOC_DIR } /msi2lmp.1 DESTINATION ${ CMAKE_INSTALL_MANDIR } /man1 )
2019-04-06 11:56:23 +08:00
2017-07-21 06:14:02 +08:00
endif ( )
2017-07-15 07:41:13 +08:00
2019-06-08 00:16:01 +08:00
include ( Documentation )
2018-07-27 14:46:36 +08:00
2018-07-27 12:35:08 +08:00
###############################################################################
2019-04-07 08:41:00 +08:00
# Install potential and force field files in data directory
2018-07-27 12:35:08 +08:00
###############################################################################
2018-07-28 08:31:53 +08:00
set ( LAMMPS_POTENTIALS_DIR ${ CMAKE_INSTALL_FULL_DATADIR } /lammps/potentials )
2018-08-26 21:57:49 +08:00
install ( DIRECTORY ${ LAMMPS_SOURCE_DIR } /../potentials/ DESTINATION ${ LAMMPS_POTENTIALS_DIR } )
2018-07-28 08:31:53 +08:00
2019-04-07 08:41:00 +08:00
set ( LAMMPS_FRC_FILES_DIR ${ CMAKE_INSTALL_FULL_DATADIR } /lammps/frc_files )
install ( DIRECTORY ${ LAMMPS_SOURCE_DIR } /../tools/msi2lmp/frc_files/ DESTINATION ${ LAMMPS_FRC_FILES_DIR } )
2018-07-28 08:31:53 +08:00
configure_file ( etc/profile.d/lammps.sh.in ${ CMAKE_BINARY_DIR } /etc/profile.d/lammps.sh @ONLY )
configure_file ( etc/profile.d/lammps.csh.in ${ CMAKE_BINARY_DIR } /etc/profile.d/lammps.csh @ONLY )
install (
F I L E S $ { C M A K E _ B I N A R Y _ D I R } / e t c / p r o f i l e . d / l a m m p s . s h
$ { C M A K E _ B I N A R Y _ D I R } / e t c / p r o f i l e . d / l a m m p s . c s h
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ S Y S C O N F D I R } / p r o f i l e . d
)
2018-07-27 12:35:08 +08:00
2019-03-23 00:35:21 +08:00
###############################################################################
2019-03-27 04:00:48 +08:00
# Install LAMMPS lib and python module into site-packages folder with
# "install-python" target. Behaves exactly like "make install-python" for
# conventional build. Only available, if a shared library is built.
# This is primarily for people that only want to use the Python wrapper.
2019-03-23 00:35:21 +08:00
###############################################################################
if ( BUILD_LIB AND BUILD_SHARED_LIBS )
find_package ( PythonInterp )
2019-03-27 10:08:53 +08:00
if ( PYTHONINTERP_FOUND )
2019-03-27 04:00:48 +08:00
add_custom_target (
i n s t a l l - p y t h o n
$ { P Y T H O N _ E X E C U T A B L E } i n s t a l l . p y - v $ { L A M M P S _ S O U R C E _ D I R } / v e r s i o n . h
- m $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / . . / p y t h o n / l a m m p s . p y
- l $ { C M A K E _ B I N A R Y _ D I R } / l i b l a m m p s $ { C M A K E _ S H A R E D _ L I B R A R Y _ S U F F I X }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / . . / p y t h o n
C O M M E N T " I n s t a l l i n g L A M M P S P y t h o n m o d u l e " )
else ( )
add_custom_target (
i n s t a l l - p y t h o n
2019-03-27 10:08:53 +08:00
$ { C M A K E _ C O M M A N D } - E e c h o " M u s t h a v e P y t h o n i n s t a l l e d t o i n s t a l l t h e L A M M P S P y t h o n m o d u l e " )
2019-03-27 04:00:48 +08:00
endif ( )
2019-03-23 00:51:57 +08:00
else ( )
add_custom_target (
i n s t a l l - p y t h o n
2019-03-27 10:08:53 +08:00
$ { C M A K E _ C O M M A N D } - E e c h o " M u s t b u i l d L A M M P S a s a s h a r e d l i b r a r y t o u s e t h e P y t h o n m o d u l e " )
2019-03-27 04:00:48 +08:00
endif ( )
###############################################################################
# Add LAMMPS python module to "install" target. This is taylored for building
# LAMMPS for package managers and with different prefix settings.
# This requires either a shared library or that the PYTHON package is included.
###############################################################################
if ( ( BUILD_LIB AND BUILD_SHARED_LIBS ) OR ( PKG_PYTHON ) )
find_package ( PythonInterp )
2019-03-27 10:08:53 +08:00
if ( PYTHONINTERP_FOUND )
execute_process ( COMMAND ${ PYTHON_EXECUTABLE }
- c " i m p o r t d i s t u t i l s . s y s c o n f i g a s c g ; print ( cg.get_python_lib(1,0,prefix=' ${ CMAKE_INSTALL_PREFIX } ' ) ) "
O U T P U T _ V A R I A B L E P Y T H O N _ D E F A U L T _ I N S T D I R O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
set ( PYTHON_INSTDIR ${ PYTHON_DEFAULT_INSTDIR } CACHE PATH "Installation folder for LAMMPS Python module" )
2019-03-27 04:00:48 +08:00
install ( FILES ${ CMAKE_CURRENT_SOURCE_DIR } /../python/lammps.py DESTINATION ${ PYTHON_INSTDIR } )
endif ( )
2019-03-23 00:35:21 +08:00
endif ( )
2019-06-08 00:24:35 +08:00
include ( Testing )
2019-06-09 15:18:20 +08:00
include ( CodeCoverage )
2018-06-12 04:29:38 +08:00
###############################################################################
2017-07-20 08:34:07 +08:00
# Print package summary
2018-06-12 04:29:38 +08:00
###############################################################################
2019-04-08 10:32:31 +08:00
foreach ( PKG ${ DEFAULT_PACKAGES } ${ ACCEL_PACKAGES } )
2018-05-11 21:51:59 +08:00
if ( PKG_ ${ PKG } )
2017-07-15 07:41:13 +08:00
message ( STATUS "Building package: ${PKG}" )
endif ( )
endforeach ( )
2017-08-20 23:17:49 +08:00
2018-05-10 05:19:52 +08:00
get_directory_property ( CPPFLAGS DIRECTORY ${ CMAKE_SOURCE_DIR } COMPILE_DEFINITIONS )
include ( FeatureSummary )
2018-06-30 03:31:15 +08:00
feature_summary ( DESCRIPTION "The following packages have been found:" WHAT PACKAGES_FOUND )
2017-08-20 23:17:49 +08:00
message ( STATUS " <<< Build configuration >>>
B u i l d t y p e $ { C M A K E _ B U I L D _ T Y P E }
I n s t a l l p a t h $ { C M A K E _ I N S T A L L _ P R E F I X }
C o m p i l e r s a n d F l a g s :
C + + C o m p i l e r $ { C M A K E _ C X X _ C O M P I L E R }
T y p e $ { C M A K E _ C X X _ C O M P I L E R _ I D }
2018-05-10 05:19:52 +08:00
V e r s i o n $ { C M A K E _ C X X _ C O M P I L E R _ V E R S I O N }
C + + F l a g s $ { C M A K E _ C X X _ F L A G S } $ { C M A K E _ C X X _ F L A G S _ $ { B T Y P E } }
2018-05-11 04:30:45 +08:00
D e f i n e s $ { C P P F L A G S } " )
2017-08-20 23:17:49 +08:00
get_property ( LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES )
2018-05-11 04:30:45 +08:00
list ( FIND LANGUAGES "Fortran" _index )
if ( ${ _index } GREATER -1 )
2018-11-05 23:24:02 +08:00
message ( STATUS " Fortran Compiler ${ CMAKE_Fortran_COMPILER }
2017-08-20 23:17:49 +08:00
T y p e $ { C M A K E _ F o r t r a n _ C O M P I L E R _ I D }
2018-05-11 04:30:45 +08:00
V e r s i o n $ { C M A K E _ F o r t r a n _ C O M P I L E R _ V E R S I O N }
2017-08-20 23:17:49 +08:00
F o r t r a n F l a g s $ { C M A K E _ F o r t r a n _ F L A G S } $ { C M A K E _ F o r t r a n _ F L A G S _ $ { B T Y P E } } " )
endif ( )
2018-05-11 04:30:45 +08:00
list ( FIND LANGUAGES "C" _index )
if ( ${ _index } GREATER -1 )
2018-11-05 23:24:02 +08:00
message ( STATUS " C Compiler ${ CMAKE_C_COMPILER }
2018-05-11 04:30:45 +08:00
T y p e $ { C M A K E _ C _ C O M P I L E R _ I D }
V e r s i o n $ { C M A K E _ C _ C O M P I L E R _ V E R S I O N }
C F l a g s $ { C M A K E _ C _ F L A G S } $ { C M A K E _ C _ F L A G S _ $ { B T Y P E } } " )
endif ( )
if ( CMAKE_EXE_LINKER_FLAGS )
message ( STATUS " Linker flags:
2017-08-20 23:17:49 +08:00
E x e c u t a b l e $ { C M A K E _ E X E _ L I N K E R _ F L A G S } " )
2018-12-17 05:53:51 +08:00
endif ( )
2017-08-20 23:17:49 +08:00
if ( BUILD_SHARED_LIBS )
2018-05-10 05:19:52 +08:00
message ( STATUS "Shared libraries ${CMAKE_SHARED_LINKER_FLAGS}" )
2017-08-20 23:17:49 +08:00
else ( )
2018-05-10 05:19:52 +08:00
message ( STATUS "Static libraries ${CMAKE_STATIC_LINKER_FLAGS}" )
2017-08-20 23:17:49 +08:00
endif ( )
message ( STATUS "Link libraries: ${LAMMPS_LINK_LIBS}" )
2018-05-10 13:12:00 +08:00
if ( BUILD_MPI )
2018-05-11 09:20:06 +08:00
message ( STATUS "Using mpi with headers in ${MPI_CXX_INCLUDE_PATH} and ${MPI_CXX_LIBRARIES}" )
2018-05-10 05:19:52 +08:00
endif ( )
2018-06-28 03:23:35 +08:00
if ( PKG_GPU )
2018-05-11 02:36:09 +08:00
message ( STATUS "GPU Api: ${GPU_API}" )
if ( GPU_API STREQUAL "CUDA" )
message ( STATUS "GPU Arch: ${GPU_ARCH}" )
2018-08-15 22:50:51 +08:00
elseif ( GPU_API STREQUAL "OPENCL" )
2018-05-11 02:36:09 +08:00
message ( STATUS "OCL Tune: ${OCL_TUNE}" )
endif ( )
2018-06-22 23:02:10 +08:00
message ( STATUS "GPU Precision: ${GPU_PREC}" )
2018-05-11 02:36:09 +08:00
endif ( )
2018-06-28 03:25:56 +08:00
if ( PKG_KOKKOS )
message ( STATUS "Kokkos Arch: ${KOKKOS_ARCH}" )
2018-05-11 02:36:09 +08:00
endif ( )
2018-05-11 21:51:59 +08:00
if ( PKG_KSPACE )
2018-05-12 05:27:24 +08:00
message ( STATUS "Using ${FFT} as FFT" )
2018-05-11 06:11:10 +08:00
endif ( )