diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 0d041b2aa9..daa2a7d90a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -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) ###############################################################################