diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index fe158f512f..690ac40957 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -11,6 +11,10 @@ get_filename_component(LAMMPS_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib get_filename_component(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib ABSOLUTE) get_filename_component(LAMMPS_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../doc ABSOLUTE) +# 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() # To avoid conflicts with the conventional Makefile build system, we build everything here file(GLOB LIB_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) diff --git a/cmake/README.md b/cmake/README.md index 90aba19a41..ae9ea8d1f7 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -195,6 +195,7 @@ cmake -C ../cmake/presets/std_nolib.cmake -D PKG_GPU=on ../cmake
CMAKE_INSTALL_PREFIX
$HOME/.local
.