diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index dec20095ca..6a0b6b7cc9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -644,19 +644,15 @@ if(BUILD_TOOLS) endif() if(BUILD_LAMMPS_SHELL) - include(FindPkgConfig) - pkg_check_modules(READLINE IMPORTED_TARGET readline) - if(PKG_CONFIG_FOUND AND READLINE_FOUND) - if(NOT LAMMPS_EXCEPTIONS) - message(WARNING "The LAMMPS shell needs LAMMPS_EXCEPTIONS enabled for full functionality") - 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;PkgConfig::READLINE) - install(TARGETS lammps-shell DESTINATION ${CMAKE_INSTALL_BINDIR}) - else() - message(FATAL_ERROR "pkg-config and readline library not found. Cannot build LAMMPS shell") + find_package(PkgConfig REQUIRED) + pkg_check_modules(READLINE IMPORTED_TARGET REQUIRED readline) + if(NOT LAMMPS_EXCEPTIONS) + message(WARNING "The LAMMPS shell needs LAMMPS_EXCEPTIONS enabled for full functionality") endif() + 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 PkgConfig::READLINE) + install(TARGETS lammps-shell EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() include(Documentation)