diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 669bff1533..d599a500c7 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -404,9 +404,11 @@ endif() if(PKG_MSCG OR PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_LATTE OR PKG_ELECTRODE) enable_language(C) - find_package(LAPACK) - find_package(BLAS) - if(NOT LAPACK_FOUND OR NOT BLAS_FOUND) + if (NOT USE_INTERNAL_LINALG) + find_package(LAPACK) + find_package(BLAS) + endif() + if(NOT LAPACK_FOUND OR NOT BLAS_FOUND OR USE_INTERNAL_LINALG) include(CheckGeneratorSupport) if(NOT CMAKE_GENERATOR_SUPPORT_FORTRAN) status(FATAL_ERROR "Cannot build internal linear algebra library as CMake build tool lacks Fortran support") diff --git a/cmake/Modules/Packages/LATTE.cmake b/cmake/Modules/Packages/LATTE.cmake index a96e850f7e..d7793fa257 100644 --- a/cmake/Modules/Packages/LATTE.cmake +++ b/cmake/Modules/Packages/LATTE.cmake @@ -23,8 +23,9 @@ if(DOWNLOAD_LATTE) # CMake cannot pass BLAS or LAPACK library variable to external project if they are a list list(LENGTH BLAS_LIBRARIES} NUM_BLAS) list(LENGTH LAPACK_LIBRARIES NUM_LAPACK) - if((NUM_BLAS GREATER 1) OR (NUM_LAPACK GREATER 1)) - message(FATAL_ERROR "Cannot compile downloaded LATTE library due to a technical limitation") + if((NUM_BLAS GREATER 1) OR (NUM_LAPACK GREATER 1) AND NOT USE_INTERNAL_LINALG) + message(FATAL_ERROR "Cannot compile downloaded LATTE library due to a technical limitation. " + "Try to configure LAMMPS with '-D USE_INTERNAL_LINALG=on' added as a workaround.") endif() include(ExternalProject) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 14d0e290aa..3dad393a52 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -788,8 +788,10 @@ library. .. code-block:: bash - -D DOWNLOAD_LATTE=value # download LATTE for build, value = no (default) or yes - -D LATTE_LIBRARY=path # LATTE library file (only needed if a custom location) + -D DOWNLOAD_LATTE=value # download LATTE for build, value = no (default) or yes + -D LATTE_LIBRARY=path # LATTE library file (only needed if a custom location) + -D USE_INTERNAL_LINALG=value # Use the internal linear algebra library instead of LAPACK + # value = no (default) or yes If ``DOWNLOAD_LATTE`` is set, the LATTE library will be downloaded and built inside the CMake build directory. If the LATTE library @@ -797,6 +799,13 @@ library. ``LATTE_LIBRARY`` is the filename (plus path) of the LATTE library file, not the directory the library file is in. + The LATTE library requires LAPACK (and BLAS) and CMake can identify + their locations and pass that info to the LATTE build script. But + on some systems this triggers a (current) limitation of CMake and + the configuration will fail. Try enabling ``USE_INTERNAL_LINALG`` in + those cases to use the bundled linear algebra library and work around + the limitation. + .. tab:: Traditional make You can download and build the LATTE library manually if you @@ -1913,14 +1922,25 @@ within CMake will download the non-commercial use version. .. code-block:: bash - -D DOWNLOAD_QUIP=value # download OpenKIM API v2 for build, value = no (default) or yes - -D QUIP_LIBRARY=path # path to libquip.a (only needed if a custom location) + -D DOWNLOAD_QUIP=value # download QUIP library for build, value = no (default) or yes + -D QUIP_LIBRARY=path # path to libquip.a (only needed if a custom location) + -D USE_INTERNAL_LINALG=value # Use the internal linear algebra library instead of LAPACK + # value = no (default) or yes - CMake will try to download and build the QUIP library from GitHub, if it is not - found on the local machine. This requires to have git installed. It will use the same compilers - and flags as used for compiling LAMMPS. Currently this is only supported for the GNU and the - Intel compilers. Set the ``QUIP_LIBRARY`` variable if you want to use a previously compiled - and installed QUIP library and CMake cannot find it. + CMake will try to download and build the QUIP library from GitHub, + if it is not found on the local machine. This requires to have git + installed. It will use the same compilers and flags as used for + compiling LAMMPS. Currently this is only supported for the GNU + and the Intel compilers. Set the ``QUIP_LIBRARY`` variable if you + want to use a previously compiled and installed QUIP library and + CMake cannot find it. + + The QUIP library requires LAPACK (and BLAS) and CMake can identify + their locations and pass that info to the QUIP build script. But + on some systems this triggers a (current) limitation of CMake and + the configuration will fail. Try enabling ``USE_INTERNAL_LINALG`` in + those cases to use the bundled linear algebra library and work around + the limitation. .. tab:: Traditional make