dftd3 / simple-dftd3

reimplementation of the DFT-D3 program
https://dftd3.readthedocs.io
GNU Lesser General Public License v3.0
51 stars 24 forks source link

Building with cmake with no internet connection #13

Closed pfebrer closed 2 years ago

pfebrer commented 2 years ago

This is probably a cmake question, but I have no idea how to do it.

I'm trying to compile simple-dftd3 with cmake and ninja in a computer that doesn't allow connections to the outside world. Therefore, I've had to copy the sources of mctc-lib and compile them myself. I have already compiled mctc-lib, and trying to compile simple-dftd3 tells me that it can not find mctc-lib because of missing mctc-lib_DIR:

Screenshot from 2022-02-04 19-25-43

How can I specify mctc-lib_DIR?

Thanks!

awvwgk commented 2 years ago

I uploaded a release bundling all dependency sources in at https://github.com/awvwgk/simple-dftd3/releases/download/v0.5.1/s-dftd3-0.5.1-source.tar.xz

CMake tries to find dependencies via four different methods, the download from the upstream repo is the last option. The following methods are used:

  1. find via CMake config file (config file must be findable in CMAKE_PREFIX_PATH environment variable or specified via -D<name>_DIR=/path/to/install at the configure step)
  2. find via pkg-config file (pc file must be findable in PKG_CONFIG_PATH environment variable)
  3. use source from subprojects/<name> (provided in bundled source)
  4. download project from upstream repo
pfebrer commented 2 years ago

Thank you very much! No problems building now, except for some undefined references:

icn46769@login2:~/scratch/s-dftd3-0.5.1> cmake -B _build -G Ninja

-- The Fortran compiler identification is Intel 18.0.5.20180823
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /apps/INTEL/2018.4.057/bin/ifort - skipped
-- Checking whether /apps/INTEL/2018.4.057/bin/ifort supports Fortran 90
-- Checking whether /apps/INTEL/2018.4.057/bin/ifort supports Fortran 90 - yes
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Found OpenMP_Fortran: -qopenmp (found version "5.0") 
-- Found OpenMP: TRUE (found version "5.0")  
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
-- Could NOT find BLAS (missing: BLAS_LIBRARIES) 
-- mctc-lib: Find installed package
-- Could NOT find mctc-lib (missing: mctc-lib_DIR)
-- Include mctc-lib from subprojects
-- mstore: Find installed package
-- Could NOT find mstore (missing: mstore_DIR)
-- Include mstore from subprojects
-- toml-f: Find installed package
-- Could NOT find toml-f (missing: toml-f_DIR)
-- Include toml-f from subprojects
-- Configuring done
-- Generating done
-- Build files have been written to: /home/icn46/icn46769/scratch/s-dftd3-0.5.1/_build

icn46769@login2:~/scratch/s-dftd3-0.5.1> cmake --build _build

[186/318] Building Fortran object subprojects/toml-f/CMakeFiles/toml-f-lib.dir/src/tomlf/type/keyval.f90.o
../subprojects/toml-f/src/tomlf/type/keyval.f90(48): warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value.   [SELF]
subroutine new_keyval(self)
----------------------^
[315/318] Linking Fortran executable app/s-dftd3
FAILED: app/s-dftd3 
: && /apps/INTEL/2018.4.057/bin/ifort  -O2 -g app/CMakeFiles/s-dftd3-exe.dir/argument.f90.o app/CMakeFiles/s-dftd3-exe.dir/cli.f90.o app/CMakeFiles/s-dftd3-exe.dir/driver.f90.o app/CMakeFiles/s-dftd3-exe.dir/help.f90.o app/CMakeFiles/s-dftd3-exe.dir/main.f90.o app/CMakeFiles/s-dftd3-exe.dir/toml.f90.o -o app/s-dftd3  libs-dftd3.a  subprojects/mctc-lib/libmctc-lib.a  /gpfs/apps/MN4/INTEL/2018.4.057/compilers_and_libraries_2018.5.274/linux/compiler/lib/intel64_lin/libiomp5.so  subprojects/toml-f/libtoml-f.a && :
libs-dftd3.a(blas.F90.o): In function `dftd3_blas_mp_d3_sgemv_':
/gpfs/scratch/icn46/icn46769/s-dftd3-0.5.1/_build/../src/dftd3/blas.F90:219: undefined reference to `sgemv_'
libs-dftd3.a(blas.F90.o): In function `dftd3_blas_mp_d3_dgemv_':
/gpfs/scratch/icn46/icn46769/s-dftd3-0.5.1/_build/../src/dftd3/blas.F90:253: undefined reference to `dgemv_'
[316/318] Building Fortran object test/unit/CMakeFiles/s-dftd3-tester.dir/test_dftd3.f90.o
ninja: build stopped: subcommand failed.

Providing a blas implementation is optional, right?

awvwgk commented 2 years ago

Yes, you don't need BLAS for building s-dftd3, set -DWITH_BLAS=OFF in the configure step and you should be fine (it is actually not performance critical for s-dftd3, so no worries).

pfebrer commented 2 years ago

Nice, thanks!! Problem solved :)