add support for building the LAMMPS shell in CMake

This commit is contained in:
Axel Kohlmeyer
2020-10-03 22:01:57 -04:00
parent acf53ff55e
commit 4e8feff52c

View File

@ -90,6 +90,7 @@ if(BUILD_SHARED_LIBS) # for all pkg libs, mpi_stubs and linalg
endif()
option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF)
option(BUILD_SHELL "Build and install the LAMMPS shell" OFF)
include(GNUInstallDirs)
file(GLOB ALL_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp)
@ -642,6 +643,23 @@ if(BUILD_TOOLS)
install(FILES ${LAMMPS_DOC_DIR}/msi2lmp.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
endif()
if(BUILD_SHELL)
include(FindPkgConfig)
pkg_check_modules(READLINE IMPORTED_TARGET readline)
if(PKG_CONFIG_FOUND AND READLINE_FOUND)
if(NOT LAMMPS_EXCEPTIONS)
message(FATAL_ERROR "The LAMMPS shell requires LAMMPS_EXCEPTIONS enabled")
endif()
add_executable(lammps-shell ${LAMMPS_TOOLS_DIR}/lammps-shell/lammps-shell.cpp)
target_compile_definitions(lammps-shell PRIVATE -DLAMMPS_LIB_NO_MPI)
target_link_libraries(lammps-shell PRIVATE lammps)
target_link_libraries(lammps-shell PRIVATE PkgConfig::READLINE)
install(TARGETS lammps-shell DESTINATION ${CMAKE_INSTALL_BINDIR})
else()
message(WARNING "PkgConfig info for readline library not found, skipping build of 'lammps-shell'")
endif()
endif()
include(Documentation)
###############################################################################