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 Install location where LAMMPS files will be copied to. In the Unix/Linux case with Makefiles this controls what `make install` will do. + Default setting is $HOME/.local. diff --git a/doc/src/Build_cmake.txt b/doc/src/Build_cmake.txt index 1406d290f5..5c29e11280 100644 --- a/doc/src/Build_cmake.txt +++ b/doc/src/Build_cmake.txt @@ -44,7 +44,7 @@ LAMMPS or need to re-compile LAMMPS repeatedly, installation of the ccache (= Compiler Cache) software may speed up compilation even more. After compilation, you can optionally copy the LAMMPS executable and -library into your system folders (by default under /usr/local) with: +library into your system folders (by default under $HOME/.local) with: make install # optional, copy LAMMPS executable & library elsewhere :pre